xref: /openbsd/gnu/usr.bin/gcc/gcc/gccbug.in (revision a67f0032)
1c87b03e5Sespie#!/bin/sh
2c87b03e5Sespie# Submit a problem report to a GNATS site.
3c87b03e5Sespie# Copyright (C) 1993, 2000, 2001, 2002 Free Software Foundation, Inc.
4c87b03e5Sespie# Contributed by Brendan Kehoe (brendan@cygnus.com), based on a
5c87b03e5Sespie# version written by Heinz G. Seidl (hgs@cygnus.com).
6c87b03e5Sespie#
7c87b03e5Sespie# This file is part of GNU GNATS.
8c87b03e5Sespie#
9c87b03e5Sespie# GNU GNATS is free software; you can redistribute it and/or modify
10c87b03e5Sespie# it under the terms of the GNU General Public License as published by
11c87b03e5Sespie# the Free Software Foundation; either version 2, or (at your option)
12c87b03e5Sespie# any later version.
13c87b03e5Sespie#
14c87b03e5Sespie# GNU GNATS is distributed in the hope that it will be useful,
15c87b03e5Sespie# but WITHOUT ANY WARRANTY; without even the implied warranty of
16c87b03e5Sespie# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17c87b03e5Sespie# GNU General Public License for more details.
18c87b03e5Sespie#
19c87b03e5Sespie# You should have received a copy of the GNU General Public License
20c87b03e5Sespie# along with GNU GNATS; see the file COPYING.  If not, write to
21c87b03e5Sespie# the Free Software Foundation, 59 Temple Place - Suite 330,
22c87b03e5Sespie# Boston, MA 02111-1307, USA.
23c87b03e5Sespie
24c87b03e5Sespie# The version of this send-pr.
25c87b03e5SespieVERSION=3.113
26c87b03e5Sespie
27c87b03e5Sespie# The submitter-id for your site.
28c87b03e5SespieSUBMITTER=net
29c87b03e5Sespie
30c87b03e5Sespie# The default mail address for PR submissions.
31c87b03e5SespieGNATS_ADDR=gcc-gnats@gcc.gnu.org
32c87b03e5Sespie
33c87b03e5Sespie# The default release for this host.
34c87b03e5SespieDEFAULT_RELEASE="@gcc_version_full@"
35c87b03e5Sespie
36c87b03e5Sespie# The default organization.
37c87b03e5SespieDEFAULT_ORGANIZATION=
38c87b03e5Sespie
39c87b03e5Sespie# What mailer to use.  This must come after the config file, since it is
40c87b03e5Sespie# host-dependent.
41c87b03e5Sespie# Copied from cvsbug
42c87b03e5Sespieif [ -f /usr/sbin/sendmail ]; then
43c87b03e5Sespie    MAIL_AGENT="/usr/sbin/sendmail -oi -t"
44c87b03e5Sespieelse
45c87b03e5Sespie    MAIL_AGENT="/usr/lib/sendmail -oi -t"
46c87b03e5Sespiefi
47c87b03e5SespieMAILER=`echo $MAIL_AGENT | sed -e 's, .*,,'`
48c87b03e5Sespieif [ ! -f "$MAILER" ] ; then
49c87b03e5Sespie    echo "$COMMAND: Cannot file mail program \"$MAILER\"."
50c87b03e5Sespie    echo "$COMMAND: Please fix the MAIL_AGENT entry in the $COMMAND file."
51c87b03e5Sespie    exit 1
52c87b03e5Sespiefi
53c87b03e5Sespie
54c87b03e5Sespie
55c87b03e5Sespie# How to read the passwd database.
56c87b03e5SespiePASSWD="cat /etc/passwd"
57c87b03e5Sespie
58c87b03e5SespieECHON=bsd
59c87b03e5Sespie
60c87b03e5Sespieif [ $ECHON = bsd ] ; then
61c87b03e5Sespie  ECHON1="echo -n"
62c87b03e5Sespie  ECHON2=
63c87b03e5Sespieelif [ $ECHON = sysv ] ; then
64c87b03e5Sespie  ECHON1=echo
65c87b03e5Sespie  ECHON2='\c'
66c87b03e5Sespieelse
67c87b03e5Sespie  ECHON1=echo
68c87b03e5Sespie  ECHON2=
69c87b03e5Sespiefi
70c87b03e5Sespie
71c87b03e5Sespie#
72c87b03e5Sespie
73c87b03e5Sespieif [ -z "$TMPDIR" ]; then
74c87b03e5Sespie  TMPDIR=/tmp
75c87b03e5Sespieelse
76c87b03e5Sespie  if [ "`echo $TMPDIR | grep '/$'`" != "" ]; then
77c87b03e5Sespie    TMPDIR="`echo $TMPDIR | sed -e 's,/$,,'`"
78c87b03e5Sespie  fi
79c87b03e5Sespiefi
80c87b03e5Sespie
81c87b03e5Sespieif [ @have_mktemp_command@ = yes ]; then
82c87b03e5Sespie	TEMP0=`mktemp $TMPDIR/poXXXXXX` || exit 1
83c87b03e5Sespie	TEMP=`mktemp $TMPDIR/pXXXXXX` || exit 1
84c87b03e5Sespie	BAD=`mktemp $TMPDIR/pbadXXXXXX` || exit 1
85c87b03e5Sespie	REF=`mktemp $TMPDIR/pfXXXXXX` || exit 1
86c87b03e5Sespie	REMOVE_TEMP="rm -f $TEMP0 $TEMP $BAD $REF"
87c87b03e5Sespieelse
88c87b03e5Sespie	TEMPD=$TMPDIR/pd$$
89c87b03e5Sespie	TEMP0=$TEMPD/po$$
90c87b03e5Sespie	TEMP=$TEMPD/p$$
91c87b03e5Sespie	BAD=$TEMPD/pbad$$
92c87b03e5Sespie	REF=$TEMPD/pf$$
93c87b03e5Sespie	mkdir $TEMPD || exit 1
94c87b03e5Sespie	REMOVE_TEMP="rm -rf $TEMPD"
95c87b03e5Sespiefi
96c87b03e5Sespie
97c87b03e5Sespie# find a user name
98c87b03e5Sespieif [ "$LOGNAME" = "" ]; then
99c87b03e5Sespie	if [ "$USER" != "" ]; then
100c87b03e5Sespie		LOGNAME="$USER"
101c87b03e5Sespie	else
102c87b03e5Sespie		LOGNAME="UNKNOWN"
103c87b03e5Sespie	fi
104c87b03e5Sespiefi
105c87b03e5Sespie
106c87b03e5SespieFROM="$LOGNAME"
107c87b03e5SespieREPLY_TO="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
108c87b03e5Sespie
109c87b03e5Sespie# Find out the name of the originator of this PR.
110c87b03e5Sespieif [ -n "$NAME" ]; then
111c87b03e5Sespie  ORIGINATOR="$NAME"
112c87b03e5Sespieelif [ -f $HOME/.fullname ]; then
113c87b03e5Sespie  ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
114c87b03e5Sespieelse
115c87b03e5Sespie  # Must use temp file due to incompatibilities in quoting behavior
116c87b03e5Sespie  # and to protect shell metacharacters in the expansion of $LOGNAME
117c87b03e5Sespie  $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP0
118c87b03e5Sespie  ORIGINATOR="`cat $TEMP0`"
119c87b03e5Sespie  rm -f $TEMP0
120c87b03e5Sespiefi
121c87b03e5Sespie
122c87b03e5Sespieif [ -n "$ORGANIZATION" ]; then
123c87b03e5Sespie  if [ -f "$ORGANIZATION" ]; then
124c87b03e5Sespie    ORGANIZATION="`cat $ORGANIZATION`"
125c87b03e5Sespie  fi
126c87b03e5Sespieelse
127c87b03e5Sespie  if [ -n "$DEFAULT_ORGANIZATION" ]; then
128c87b03e5Sespie    ORGANIZATION="$DEFAULT_ORGANIZATION"
129c87b03e5Sespie  elif [ -f $HOME/.organization ]; then
130c87b03e5Sespie    ORGANIZATION="`cat $HOME/.organization`"
131c87b03e5Sespie  fi
132c87b03e5Sespiefi
133c87b03e5Sespie
134c87b03e5Sespie# If they don't have a preferred editor set, then use
135c87b03e5Sespieif [ -z "$VISUAL" ]; then
136c87b03e5Sespie  if [ -z "$EDITOR" ]; then
137c87b03e5Sespie    EDIT=vi
138c87b03e5Sespie  else
139c87b03e5Sespie    EDIT="$EDITOR"
140c87b03e5Sespie  fi
141c87b03e5Sespieelse
142c87b03e5Sespie  EDIT="$VISUAL"
143c87b03e5Sespiefi
144c87b03e5Sespie
145c87b03e5Sespie# Find out some information.
146c87b03e5SespieSYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
147c87b03e5Sespie        ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
148c87b03e5SespieARCH=`[ -f /bin/arch ] && /bin/arch`
149c87b03e5SespieMACHINE=`[ -f /bin/machine ] && /bin/machine`
150c87b03e5Sespie
151c87b03e5SespieCOMMAND=`echo $0 | sed -e 's,.*/,,'`
152c87b03e5SespieUSAGE="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity]
153c87b03e5Sespie       [-c address] [--request-id] [--version]"
154c87b03e5SespieREMOVE=
155c87b03e5SespieBATCH=
156c87b03e5SespieCC=
157c87b03e5SespieSEVERITY_C=
158c87b03e5Sespie
159c87b03e5Sespiewhile [ $# -gt 0 ]; do
160c87b03e5Sespie  case "$1" in
161c87b03e5Sespie    -r) ;; 		# Ignore for backward compat.
162c87b03e5Sespie    -t | --to) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
163c87b03e5Sespie	shift ; GNATS_ADDR="$1"
164c87b03e5Sespie	EXPLICIT_GNATS_ADDR=true
165c87b03e5Sespie        ;;
166c87b03e5Sespie    -f | --file) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
167c87b03e5Sespie	shift ; IN_FILE="$1"
168c87b03e5Sespie	if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
169c87b03e5Sespie	  echo "$COMMAND: cannot read $IN_FILE"
170c87b03e5Sespie	  $REMOVE_TEMP
171c87b03e5Sespie	  exit 1
172c87b03e5Sespie	fi
173c87b03e5Sespie	;;
174c87b03e5Sespie    -b | --batch) BATCH=true ;;
175c87b03e5Sespie    -c | --cc) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
176c87b03e5Sespie	shift ; CC="$1"
177c87b03e5Sespie	;;
178c87b03e5Sespie    -s | --severity) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
179c87b03e5Sespie	shift ; SEVERITY_C="$1"
180c87b03e5Sespie	;;
181c87b03e5Sespie    -p | -P | --print) PRINT=true ;;
182c87b03e5Sespie    -L | --list) FORMAT=norm ;;
183c87b03e5Sespie    -l | -CL | --lisp) FORMAT=lisp ;;
184c87b03e5Sespie    --request-id) REQUEST_ID=true ;;
185c87b03e5Sespie    -h | --help) echo "$USAGE"; $REMOVE_TEMP; exit 0 ;;
186c87b03e5Sespie    -V | --version) cat <<EOF
187c87b03e5Sespiegccbug (GCC) $DEFAULT_RELEASE
188c87b03e5SespieCopyright (C) 2002 Free Software Foundation, Inc.
189c87b03e5SespieThis is free software; see the source for copying conditions.  There is NO
190c87b03e5Sespiewarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
191c87b03e5Sespie
192c87b03e5SespieEOF
193c87b03e5Sespie	$REMOVE_TEMP; exit 0 ;;
194c87b03e5Sespie    -*) echo "$USAGE" ; $REMOVE_TEMP; exit 1 ;;
195c87b03e5Sespie    *) echo "$USAGE" ; $REMOVE_TEMP; exit 1
196c87b03e5Sespie esac
197c87b03e5Sespie shift
198c87b03e5Sespiedone
199c87b03e5Sespie
200c87b03e5Sespie# spam does not need to be listed here
201*a67f0032SmiodCATEGORIES="ada bootstrap c++ c debug driver fortran inline-asm java libf2c libgcj libobjc libstdc++ middle-end objc other preprocessor rtl-optimization target tree-optimization web"
202c87b03e5Sespie
203c87b03e5Sespiecase "$FORMAT" in
204c87b03e5Sespie  lisp) echo "$CATEGORIES" | \
205c87b03e5Sespie        awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
206c87b03e5Sespie	$REMOVE_TEMP
207c87b03e5Sespie        exit 0
208c87b03e5Sespie        ;;
209c87b03e5Sespie  norm) l=`echo "$CATEGORIES" | \
210c87b03e5Sespie	awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
211c87b03e5Sespie	     END {print max + 1;}'`
212c87b03e5Sespie	c=`expr 70 / $l`
213c87b03e5Sespie	if [ $c -eq 0 ]; then c=1; fi
214c87b03e5Sespie	echo "$CATEGORIES" | \
215c87b03e5Sespie        awk 'BEGIN {print "Known categories:"; i = 0 }
216c87b03e5Sespie          { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
217c87b03e5Sespie            END { print ""; }'
218c87b03e5Sespie	$REMOVE_TEMP
219c87b03e5Sespie        exit 0
220c87b03e5Sespie        ;;
221c87b03e5Sespieesac
222c87b03e5Sespie
223c87b03e5SespieORIGINATOR_C='<name of the PR author (one line)>'
224c87b03e5SespieORGANIZATION_C='<organization of PR author (multiple lines)>'
225c87b03e5SespieSYNOPSIS_C='<synopsis of the problem (one line)>'
226c87b03e5Sespieif [ -z "$SEVERITY_C" ]; then
227c87b03e5Sespie  SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
228c87b03e5Sespiefi
229c87b03e5SespiePRIORITY_C='<[ low | medium ] (one line)>'
230c87b03e5SespieCATEGORY_C='<choose from the top of this file (one line)>'
231c87b03e5SespieRELEASE_C='<release number or tag (one line)>'
232c87b03e5SespieENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
233c87b03e5SespieDESCRIPTION_C='<precise description of the problem (multiple lines)>'
234c87b03e5SespieHOW_TO_REPEAT_C='<When reporting a compiler error, preprocessor output must be included>'
235c87b03e5SespieFIX_C='<how to correct or work around the problem, if known (multiple lines)>'
236c87b03e5Sespie
237c87b03e5Sespie# Catch some signals. ($xs kludge needed by Sun /bin/sh)
238c87b03e5Sespiexs=0
239c87b03e5Sespietrap '$REMOVE_TEMP; exit $xs' 0
240c87b03e5Sespietrap 'echo "$COMMAND: Aborting ..."; $REMOVE_TEMP; xs=1; exit' 1 3 13 15
241c87b03e5Sespie
242c87b03e5Sespie# If they told us to use a specific file, then do so.
243c87b03e5Sespieif [ -n "$IN_FILE" ]; then
244c87b03e5Sespie  if [ "$IN_FILE" = "-" ]; then
245c87b03e5Sespie    # The PR is coming from the standard input.
246c87b03e5Sespie    if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
247c87b03e5Sespie      sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
248c87b03e5Sespie    else
249c87b03e5Sespie      cat > $TEMP
250c87b03e5Sespie    fi
251c87b03e5Sespie  else
252c87b03e5Sespie    # Use the file they named.
253c87b03e5Sespie    if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
254c87b03e5Sespie      sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
255c87b03e5Sespie    else
256c87b03e5Sespie      cat $IN_FILE > $TEMP
257c87b03e5Sespie    fi
258c87b03e5Sespie  fi
259c87b03e5Sespieelse
260c87b03e5Sespie
261c87b03e5Sespie  if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
262c87b03e5Sespie    # If their PR_FORM points to a bogus entry, then bail.
263c87b03e5Sespie    if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
264c87b03e5Sespie      echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
265c87b03e5Sespie      sleep 1
266c87b03e5Sespie      PRINT_INTERN=bad_prform
267c87b03e5Sespie    fi
268c87b03e5Sespie  fi
269c87b03e5Sespie
270c87b03e5Sespie  if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
271c87b03e5Sespie    cp $PR_FORM $TEMP ||
272c87b03e5Sespie      ( echo "$COMMAND: could not copy $PR_FORM" ; xs=1; exit )
273c87b03e5Sespie  else
274c87b03e5Sespie    for file in $TEMP $REF ; do
275c87b03e5Sespie      cat  > $file << '__EOF__'
276c87b03e5SespieSEND-PR: -*- send-pr -*-
277c87b03e5SespieSEND-PR: Lines starting with `SEND-PR' will be removed automatically, as
278c87b03e5SespieSEND-PR: will all comments (text enclosed in `<' and `>').
279c87b03e5SespieSEND-PR:
280c87b03e5SespieSEND-PR: Please consult the GCC manual if you are not sure how to
281c87b03e5SespieSEND-PR: fill out a problem report.
282c87b03e5SespieSEND-PR: Note that the Synopsis field is mandatory.  The Subject (for
283c87b03e5SespieSEND-PR: the mail) will be made the same as Synopsis unless explicitly
284c87b03e5SespieSEND-PR: changed.
285c87b03e5SespieSEND-PR:
286c87b03e5SespieSEND-PR: Choose from the following categories:
287c87b03e5SespieSEND-PR:
288c87b03e5Sespie__EOF__
289c87b03e5Sespie
290c87b03e5Sespie      # Format the categories so they fit onto lines.
291c87b03e5Sespie	l=`echo "$CATEGORIES" | \
292c87b03e5Sespie	awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
293c87b03e5Sespie	     END {print max + 1;}'`
294c87b03e5Sespie	c=`expr 61 / $l`
295c87b03e5Sespie	if [ $c -eq 0 ]; then c=1; fi
296c87b03e5Sespie	echo "$CATEGORIES" | \
297c87b03e5Sespie        awk 'BEGIN {printf "SEND-PR: "; i = 0 }
298c87b03e5Sespie          { printf ("%-'$l'.'$l's", $0);
299c87b03e5Sespie	    if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
300c87b03e5Sespie            END { printf "\nSEND-PR:\n"; }' >> $file
301c87b03e5Sespie
302c87b03e5Sespie      cat >> $file << __EOF__
303c87b03e5SespieTo: $GNATS_ADDR
304c87b03e5SespieSubject:
305c87b03e5SespieFrom: $FROM
306c87b03e5SespieReply-To: $REPLYTO
307c87b03e5SespieCc: $CC
308c87b03e5SespieX-send-pr-version: $VERSION
309c87b03e5SespieX-GNATS-Notify:
310c87b03e5Sespie
311c87b03e5Sespie
312c87b03e5Sespie>Submitter-Id:	$SUBMITTER
313c87b03e5Sespie>Originator:	$ORIGINATOR
314c87b03e5Sespie>Organization:	${ORGANIZATION-$ORGANIZATION_C}
315c87b03e5Sespie>Confidential:	no
316c87b03e5SespieSEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
317c87b03e5Sespie>Synopsis:	$SYNOPSIS_C
318c87b03e5Sespie>Severity:	$SEVERITY_C
319c87b03e5SespieSEND-PR: critical     GCC is completely not operational; no work-around known.
320c87b03e5SespieSEND-PR: serious      GCC is not working properly; a work-around is possible.
321c87b03e5SespieSEND-PR: non-critical Report indicates minor problem.
322c87b03e5Sespie>Priority:	$PRIORITY_C
323c87b03e5SespieSEND-PR: medium       The problem should be solved in the next release.
324c87b03e5SespieSEND-PR: low          The problem should be solve in a future release.
325c87b03e5Sespie>Category:	$CATEGORY_C
326c87b03e5Sespie>Class:		<[ doc-bug | accepts-illegal | rejects-legal | wrong-code | ice-on-legal-code| ice-on-illegal-code | pessimizes-code | sw-bug | change-request | support ] (one line)>
327c87b03e5SespieSEND-PR: doc-bug          The documentation is incorrect.
328c87b03e5SespieSEND-PR: accepts-illegal  GCC fails to reject erroneous code.
329c87b03e5SespieSEND-PR: rejects-legal    GCC gives an error message for correct code.
330c87b03e5SespieSEND-PR: wrong-code       The machine code generated by gcc is incorrect.
331c87b03e5SespieSEND-PR: ice-on-legal-code   GCC gives an Internal Compiler Error (ICE)
332c87b03e5SespieSEND-PR:                     for correct code
333c87b03e5SespieSEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
334c87b03e5SespieSEND-PR: pessimizes-code     GCC misses an important optimization opportunity
335c87b03e5SespieSEND-PR: sw-bug              Software bug of some other class than above
336c87b03e5SespieSEND-PR: change-request      A feature in GCC is missing.
337c87b03e5SespieSEND-PR: support             I need help with gcc.
338c87b03e5Sespie>Release:	${DEFAULT_RELEASE-$RELEASE_C}
339c87b03e5Sespie>Environment:
340c87b03e5Sespie`[ -n "$SYSTEM" ] && echo System: $SYSTEM`
341c87b03e5Sespie`[ -n "$ARCH" ] && echo Architecture: $ARCH`
342c87b03e5Sespie`[ -n "$MACHINE" ] && echo Machine: $MACHINE`
343c87b03e5Sespie	$ENVIRONMENT_C
344c87b03e5Sespiehost: @host@
345c87b03e5Sespiebuild: @build@
346c87b03e5Sespietarget: @target@
347c87b03e5Sespieconfigured with: @gcc_config_arguments@
348c87b03e5Sespie>Description:
349c87b03e5Sespie	$DESCRIPTION_C
350c87b03e5Sespie>How-To-Repeat:
351c87b03e5Sespie	$HOW_TO_REPEAT_C
352c87b03e5Sespie>Fix:
353c87b03e5Sespie	$FIX_C
354c87b03e5Sespie__EOF__
355c87b03e5Sespie    done
356c87b03e5Sespie  fi
357c87b03e5Sespie
358c87b03e5Sespie  if [ "$PRINT" = true -o "$PRINT_INTERN" = true ]; then
359c87b03e5Sespie    cat $TEMP
360c87b03e5Sespie    xs=0; exit
361c87b03e5Sespie  fi
362c87b03e5Sespie
363c87b03e5Sespie  chmod u+w $TEMP
364c87b03e5Sespie  if [ -z "$REQUEST_ID" ]; then
365c87b03e5Sespie    eval $EDIT $TEMP
366c87b03e5Sespie  else
367c87b03e5Sespie    ed -s $TEMP << '__EOF__'
368c87b03e5Sespie/^Subject/s/^Subject:.*/Subject: request for a customer id/
369c87b03e5Sespie/^>Category/s/^>Category:.*/>Category: send-pr/
370c87b03e5Sespiew
371c87b03e5Sespieq
372c87b03e5Sespie__EOF__
373c87b03e5Sespie  fi
374c87b03e5Sespie
375c87b03e5Sespie  if cmp -s $REF $TEMP ; then
376c87b03e5Sespie    echo "$COMMAND: problem report not filled out, therefore not sent"
377c87b03e5Sespie    xs=1; exit
378c87b03e5Sespie  fi
379c87b03e5Sespiefi
380c87b03e5Sespie
381c87b03e5Sespie#
382c87b03e5Sespie#	Check the enumeration fields
383c87b03e5Sespie
384c87b03e5Sespie# This is a "sed-subroutine" with one keyword parameter
385c87b03e5Sespie# (with workaround for Sun sed bug)
386c87b03e5Sespie#
387c87b03e5SespieSED_CMD='
388c87b03e5Sespie/$PATTERN/{
389c87b03e5Sespies|||
390c87b03e5Sespies|<.*>||
391c87b03e5Sespies|^[ 	]*||
392c87b03e5Sespies|[ 	]*$||
393c87b03e5Sespiep
394c87b03e5Sespieq
395c87b03e5Sespie}'
396c87b03e5Sespie
397c87b03e5Sespie
398c87b03e5Sespiewhile [ -z "$REQUEST_ID" ]; do
399c87b03e5Sespie  CNT=0
400c87b03e5Sespie
401c87b03e5Sespie  # 1) Confidential
402c87b03e5Sespie  #
403c87b03e5Sespie  PATTERN=">Confidential:"
404c87b03e5Sespie  CONFIDENTIAL=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
405c87b03e5Sespie  case "$CONFIDENTIAL" in
406c87b03e5Sespie    no) CNT=`expr $CNT + 1` ;;
407c87b03e5Sespie    *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
408c87b03e5Sespie  esac
409c87b03e5Sespie  #
410c87b03e5Sespie  # 2) Severity
411c87b03e5Sespie  #
412c87b03e5Sespie  PATTERN=">Severity:"
413c87b03e5Sespie  SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
414c87b03e5Sespie  case "$SEVERITY" in
415c87b03e5Sespie    ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
416c87b03e5Sespie    *)  echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
417c87b03e5Sespie  esac
418c87b03e5Sespie  #
419c87b03e5Sespie  # 3) Priority
420c87b03e5Sespie  #
421c87b03e5Sespie  PATTERN=">Priority:"
422c87b03e5Sespie  PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
423c87b03e5Sespie  case "$PRIORITY" in
424c87b03e5Sespie    ""|low|medium) CNT=`expr $CNT + 1` ;;
425c87b03e5Sespie    high) echo "$COMMAND: \`Priority: high' is reserved for GCC maintainers." ;;
426c87b03e5Sespie    *)  echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
427c87b03e5Sespie  esac
428c87b03e5Sespie  #
429c87b03e5Sespie  # 4) Category
430c87b03e5Sespie  #
431c87b03e5Sespie  PATTERN=">Category:"
432c87b03e5Sespie  CATEGORY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
433c87b03e5Sespie  FOUND=
434c87b03e5Sespie  for C in $CATEGORIES
435c87b03e5Sespie  do
436c87b03e5Sespie    if [ "$C" = "$CATEGORY" ]; then FOUND=true ; break ; fi
437c87b03e5Sespie  done
438c87b03e5Sespie  if [ -n "$FOUND" ]; then
439c87b03e5Sespie    CNT=`expr $CNT + 1`
440c87b03e5Sespie  else
441c87b03e5Sespie    if [ -z "$CATEGORY" ]; then
442c87b03e5Sespie      echo "$COMMAND: you must include a Category: field in your report."
443c87b03e5Sespie    else
444c87b03e5Sespie      echo "$COMMAND: \`$CATEGORY' is not a known category."
445c87b03e5Sespie    fi
446c87b03e5Sespie  fi
447c87b03e5Sespie  #
448c87b03e5Sespie  # 5) Class
449c87b03e5Sespie  #
450c87b03e5Sespie  PATTERN=">Class:"
451c87b03e5Sespie  CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
452c87b03e5Sespie  case "$CLASS" in
453c87b03e5Sespie    ""|doc-bug|accepts-illegal|rejects-legal|wrong-code|ice-on-legal-code|ice-on-illegal-code|pessimizes-code|sw-bug|change-request|support) CNT=`expr $CNT + 1` ;;
454c87b03e5Sespie    *)  echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
455c87b03e5Sespie  esac
456c87b03e5Sespie  #
457c87b03e5Sespie  # 6) Check that synopsis is not empty
458c87b03e5Sespie  #
459c87b03e5Sespie  if grep "^>Synopsis:[ 	]*${SYNOPSIS_C}\$" $TEMP > /dev/null
460c87b03e5Sespie  then
461c87b03e5Sespie    echo "$COMMAND: Synopsis must not be empty."
462c87b03e5Sespie  else
463c87b03e5Sespie    CNT=`expr $CNT + 1`
464c87b03e5Sespie  fi
465c87b03e5Sespie
466c87b03e5Sespie  [ $CNT -lt 6 -a -z "$BATCH" ] &&
467c87b03e5Sespie    echo "Errors were found with the problem report."
468c87b03e5Sespie
469c87b03e5Sespie  while true; do
470c87b03e5Sespie    if [ -z "$BATCH" ]; then
471c87b03e5Sespie      $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
472c87b03e5Sespie      read input
473c87b03e5Sespie    else
474c87b03e5Sespie      if [ $CNT -eq 6 ]; then
475c87b03e5Sespie        input=s
476c87b03e5Sespie      else
477c87b03e5Sespie        input=a
478c87b03e5Sespie      fi
479c87b03e5Sespie    fi
480c87b03e5Sespie    case "$input" in
481c87b03e5Sespie      a*)
482c87b03e5Sespie	if [ -z "$BATCH" ]; then
483c87b03e5Sespie	  echo "$COMMAND: the problem report remains in $BAD and is not sent."
484c87b03e5Sespie	  REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF"
485c87b03e5Sespie	  mv $TEMP $BAD
486c87b03e5Sespie        else
487c87b03e5Sespie	  echo "$COMMAND: the problem report is not sent."
488c87b03e5Sespie	fi
489c87b03e5Sespie	xs=1; exit
490c87b03e5Sespie	;;
491c87b03e5Sespie      e*)
492c87b03e5Sespie        eval $EDIT $TEMP
493c87b03e5Sespie	continue 2
494c87b03e5Sespie	;;
495c87b03e5Sespie      s*)
496c87b03e5Sespie	break 2
497c87b03e5Sespie	;;
498c87b03e5Sespie    esac
499c87b03e5Sespie  done
500c87b03e5Sespiedone
501c87b03e5Sespie
502c87b03e5Sespie#
503c87b03e5Sespie# Make sure the mail has got a Subject.  If not, use the same as
504c87b03e5Sespie# in Synopsis.
505c87b03e5Sespie#
506c87b03e5Sespie
507c87b03e5Sespieif grep '^Subject:[ 	]*$' $TEMP > /dev/null
508c87b03e5Sespiethen
509c87b03e5Sespie  SYNOPSIS=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[ 	]*//'`
510c87b03e5Sespie  ed -s $TEMP << __EOF__
511c87b03e5Sespie/^Subject:/s/:.*\$/: $SYNOPSIS/
512c87b03e5Sespiew
513c87b03e5Sespieq
514c87b03e5Sespie__EOF__
515c87b03e5Sespiefi
516c87b03e5Sespie
517c87b03e5Sespie#
518c87b03e5Sespie#	Remove comments and send the problem report
519c87b03e5Sespie#	(we have to use patterns, where the comment contains regex chars)
520c87b03e5Sespie#
521c87b03e5Sespie# /^>Originator:/s;$ORIGINATOR;;
522c87b03e5Sespiesed  -e "
523c87b03e5Sespie/^SEND-PR:/d
524c87b03e5Sespie/^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
525c87b03e5Sespie/^>Confidential:/s;<.*>;;
526c87b03e5Sespie/^>Synopsis:/s;$SYNOPSIS_C;;
527c87b03e5Sespie/^>Severity:/s;<.*>;;
528c87b03e5Sespie/^>Priority:/s;<.*>;;
529c87b03e5Sespie/^>Category:/s;$CATEGORY_C;;
530c87b03e5Sespie/^>Class:/s;<.*>;;
531c87b03e5Sespie/^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
532c87b03e5Sespie/^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
533c87b03e5Sespie/^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
534c87b03e5Sespie/^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
535c87b03e5Sespie/^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
536c87b03e5Sespie" $TEMP > $REF
537c87b03e5Sespie
538c87b03e5Sespieif $MAIL_AGENT < $REF; then
539c87b03e5Sespie  echo "$COMMAND: problem report sent"
540c87b03e5Sespie  xs=0; exit
541c87b03e5Sespieelse
542c87b03e5Sespie  echo "$COMMAND: mysterious mail failure."
543c87b03e5Sespie  if [ -z "$BATCH" ]; then
544c87b03e5Sespie    echo "$COMMAND: the problem report remains in $BAD and is not sent."
545c87b03e5Sespie    REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF"
546c87b03e5Sespie    mv $REF $BAD
547c87b03e5Sespie  else
548c87b03e5Sespie    echo "$COMMAND: the problem report is not sent."
549c87b03e5Sespie  fi
550c87b03e5Sespie  xs=1; exit
551c87b03e5Sespiefi
552