196263Sobrien#!/bin/sh
296263Sobrien# Submit a problem report to a GNATS site.
3132718Skan# Copyright (C) 1993, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
496263Sobrien# Contributed by Brendan Kehoe (brendan@cygnus.com), based on a
596263Sobrien# version written by Heinz G. Seidl (hgs@cygnus.com).
696263Sobrien#
796263Sobrien# This file is part of GNU GNATS.
896263Sobrien#
996263Sobrien# GNU GNATS is free software; you can redistribute it and/or modify
1096263Sobrien# it under the terms of the GNU General Public License as published by
1196263Sobrien# the Free Software Foundation; either version 2, or (at your option)
1296263Sobrien# any later version.
1396263Sobrien#
1496263Sobrien# GNU GNATS is distributed in the hope that it will be useful,
1596263Sobrien# but WITHOUT ANY WARRANTY; without even the implied warranty of
1696263Sobrien# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1796263Sobrien# GNU General Public License for more details.
1896263Sobrien#
1996263Sobrien# You should have received a copy of the GNU General Public License
2096263Sobrien# along with GNU GNATS; see the file COPYING.  If not, write to
21169689Skan# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22169689Skan# Boston, MA 02110-1301, USA.
2396263Sobrien
2496263Sobrien# The version of this send-pr.
2596263SobrienVERSION=3.113
2696263Sobrien
2796263Sobrien# The submitter-id for your site.
2896263SobrienSUBMITTER=net
2996263Sobrien
3096263Sobrien# The default mail address for PR submissions. 
3196263SobrienGNATS_ADDR=gcc-gnats@gcc.gnu.org
3296263Sobrien
3396263Sobrien# The default release for this host.
34169689Skan# We have to guess at what program_transform_name might have done.
35169689Skan# "sed 1q" because neither "head -1" nor "head -n 1" is universal, argh.
3696263Sobrien
37169689SkanDEFAULT_GCC="`echo $0 | sed -e 's/bug//'`"
38169689SkanDEFAULT_RELEASE="`$DEFAULT_GCC --version | sed 1q`"
39169689Skan
4096263Sobrien# The default organization.
4196263SobrienDEFAULT_ORGANIZATION=
4296263Sobrien
4396263Sobrien# What mailer to use.  This must come after the config file, since it is
4496263Sobrien# host-dependent.
4596263Sobrien# Copied from cvsbug
4696263Sobrienif [ -f /usr/sbin/sendmail ]; then  
4796263Sobrien    MAIL_AGENT="/usr/sbin/sendmail -oi -t"
4896263Sobrienelse  
4996263Sobrien    MAIL_AGENT="/usr/lib/sendmail -oi -t"
5096263Sobrienfi
5196263SobrienMAILER=`echo $MAIL_AGENT | sed -e 's, .*,,'`
5296263Sobrienif [ ! -f "$MAILER" ] ; then
5396263Sobrien    echo "$COMMAND: Cannot file mail program \"$MAILER\"."
5496263Sobrien    echo "$COMMAND: Please fix the MAIL_AGENT entry in the $COMMAND file."
5596263Sobrien    exit 1
5696263Sobrienfi
5796263Sobrien
5896263Sobrien
5996263Sobrien# How to read the passwd database.
6096263SobrienPASSWD="cat /etc/passwd"
6196263Sobrien
6296263SobrienECHON=bsd
6396263Sobrien
6496263Sobrienif [ $ECHON = bsd ] ; then
6596263Sobrien  ECHON1="echo -n"
6696263Sobrien  ECHON2=
6796263Sobrienelif [ $ECHON = sysv ] ; then
6896263Sobrien  ECHON1=echo
6996263Sobrien  ECHON2='\c'
7096263Sobrienelse
7196263Sobrien  ECHON1=echo
7296263Sobrien  ECHON2=
7396263Sobrienfi
7496263Sobrien
7596263Sobrien#
7696263Sobrien
7796263Sobrienif [ -z "$TMPDIR" ]; then
7896263Sobrien  TMPDIR=/tmp
7996263Sobrienelse
8096263Sobrien  if [ "`echo $TMPDIR | grep '/$'`" != "" ]; then
8196263Sobrien    TMPDIR="`echo $TMPDIR | sed -e 's,/$,,'`"
8296263Sobrien  fi
8396263Sobrienfi
8496263Sobrien
8596263Sobrienif [ @have_mktemp_command@ = yes ]; then
8696263Sobrien	TEMP0=`mktemp $TMPDIR/poXXXXXX` || exit 1
8796263Sobrien	TEMP=`mktemp $TMPDIR/pXXXXXX` || exit 1
8896263Sobrien	BAD=`mktemp $TMPDIR/pbadXXXXXX` || exit 1
8996263Sobrien	REF=`mktemp $TMPDIR/pfXXXXXX` || exit 1
9096263Sobrien	REMOVE_TEMP="rm -f $TEMP0 $TEMP $BAD $REF"
9196263Sobrienelse
9296263Sobrien	TEMPD=$TMPDIR/pd$$
9396263Sobrien	TEMP0=$TEMPD/po$$
9496263Sobrien	TEMP=$TEMPD/p$$
9596263Sobrien	BAD=$TEMPD/pbad$$
9696263Sobrien	REF=$TEMPD/pf$$
9796263Sobrien	mkdir $TEMPD || exit 1
9896263Sobrien	REMOVE_TEMP="rm -rf $TEMPD"
9996263Sobrienfi
10096263Sobrien
10196263Sobrien# find a user name
10296263Sobrienif [ "$LOGNAME" = "" ]; then
10396263Sobrien	if [ "$USER" != "" ]; then
10496263Sobrien		LOGNAME="$USER"
10596263Sobrien	else
10696263Sobrien		LOGNAME="UNKNOWN"
10796263Sobrien	fi
10896263Sobrienfi
10996263Sobrien
11096263SobrienFROM="$LOGNAME"
11196263SobrienREPLY_TO="${REPLY_TO:-${REPLYTO:-$LOGNAME}}"
11296263Sobrien
11396263Sobrien# Find out the name of the originator of this PR.
11496263Sobrienif [ -n "$NAME" ]; then
11596263Sobrien  ORIGINATOR="$NAME"
11696263Sobrienelif [ -f $HOME/.fullname ]; then
11796263Sobrien  ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
11896263Sobrienelse
11996263Sobrien  # Must use temp file due to incompatibilities in quoting behavior
12096263Sobrien  # and to protect shell metacharacters in the expansion of $LOGNAME
12196263Sobrien  $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP0
12296263Sobrien  ORIGINATOR="`cat $TEMP0`"
12396263Sobrien  rm -f $TEMP0
12496263Sobrienfi
12596263Sobrien
12696263Sobrienif [ -n "$ORGANIZATION" ]; then
12796263Sobrien  if [ -f "$ORGANIZATION" ]; then
12896263Sobrien    ORGANIZATION="`cat $ORGANIZATION`"
12996263Sobrien  fi
13096263Sobrienelse
13196263Sobrien  if [ -n "$DEFAULT_ORGANIZATION" ]; then
13296263Sobrien    ORGANIZATION="$DEFAULT_ORGANIZATION"
13396263Sobrien  elif [ -f $HOME/.organization ]; then
13496263Sobrien    ORGANIZATION="`cat $HOME/.organization`"
13596263Sobrien  fi
13696263Sobrienfi
13796263Sobrien
13896263Sobrien# If they don't have a preferred editor set, then use
13996263Sobrienif [ -z "$VISUAL" ]; then
14096263Sobrien  if [ -z "$EDITOR" ]; then
14196263Sobrien    EDIT=vi
14296263Sobrien  else
14396263Sobrien    EDIT="$EDITOR"
14496263Sobrien  fi
14596263Sobrienelse
14696263Sobrien  EDIT="$VISUAL"
14796263Sobrienfi
14896263Sobrien
14996263Sobrien# Find out some information.
15096263SobrienSYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
15196263Sobrien        ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
15296263SobrienARCH=`[ -f /bin/arch ] && /bin/arch`
15396263SobrienMACHINE=`[ -f /bin/machine ] && /bin/machine`
15496263Sobrien
15596263SobrienCOMMAND=`echo $0 | sed -e 's,.*/,,'`
15696263SobrienUSAGE="Usage: $COMMAND [-PVL] [-t address] [-f filename] [-s severity]
15796263Sobrien       [-c address] [--request-id] [--version]"
15896263SobrienREMOVE=
15996263SobrienBATCH=
16096263SobrienCC=
16196263SobrienSEVERITY_C=
16296263Sobrien
16396263Sobrienwhile [ $# -gt 0 ]; do
16496263Sobrien  case "$1" in
16596263Sobrien    -r) ;; 		# Ignore for backward compat.
16696263Sobrien    -t | --to) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
16796263Sobrien	shift ; GNATS_ADDR="$1"
16896263Sobrien	EXPLICIT_GNATS_ADDR=true
16996263Sobrien        ;;
17096263Sobrien    -f | --file) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
17196263Sobrien	shift ; IN_FILE="$1"
17296263Sobrien	if [ "$IN_FILE" != "-" -a ! -r "$IN_FILE" ]; then
17396263Sobrien	  echo "$COMMAND: cannot read $IN_FILE"
17496263Sobrien	  $REMOVE_TEMP
17596263Sobrien	  exit 1
17696263Sobrien	fi
17796263Sobrien	;;
17896263Sobrien    -b | --batch) BATCH=true ;;
17996263Sobrien    -c | --cc) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
18096263Sobrien	shift ; CC="$1"
18196263Sobrien	;;
18296263Sobrien    -s | --severity) if [ $# -eq 1 ]; then echo "$USAGE"; $REMOVE_TEMP; exit 1; fi
18396263Sobrien	shift ; SEVERITY_C="$1"
18496263Sobrien	;;
18596263Sobrien    -p | -P | --print) PRINT=true ;;
18696263Sobrien    -L | --list) FORMAT=norm ;;
18796263Sobrien    -l | -CL | --lisp) FORMAT=lisp ;;
18896263Sobrien    --request-id) REQUEST_ID=true ;;
18996263Sobrien    -h | --help) echo "$USAGE"; $REMOVE_TEMP; exit 0 ;;
19096263Sobrien    -V | --version) cat <<EOF
19196263Sobriengccbug (GCC) $DEFAULT_RELEASE
19296263SobrienCopyright (C) 2002 Free Software Foundation, Inc.
19396263SobrienThis is free software; see the source for copying conditions.  There is NO
19496263Sobrienwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19596263Sobrien
19696263SobrienEOF
19796263Sobrien	$REMOVE_TEMP; exit 0 ;;
19896263Sobrien    -*) echo "$USAGE" ; $REMOVE_TEMP; exit 1 ;;
19996263Sobrien    *) echo "$USAGE" ; $REMOVE_TEMP; exit 1
20096263Sobrien esac
20196263Sobrien shift
20296263Sobriendone
20396263Sobrien
20496263Sobrien# spam does not need to be listed here
205169689SkanCATEGORIES="ada bootstrap c++ c debug driver fortran inline-asm java libgcj libobjc libstdc++ middle-end objc other pch preprocessor rtl-optimization target tree-optimization web"
20696263Sobrien
20796263Sobriencase "$FORMAT" in
20896263Sobrien  lisp) echo "$CATEGORIES" | \
20996263Sobrien        awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
21096263Sobrien	$REMOVE_TEMP
21196263Sobrien        exit 0
21296263Sobrien        ;;
21396263Sobrien  norm) l=`echo "$CATEGORIES" | \
21496263Sobrien	awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
21596263Sobrien	     END {print max + 1;}'`
21696263Sobrien	c=`expr 70 / $l`
21796263Sobrien	if [ $c -eq 0 ]; then c=1; fi
21896263Sobrien	echo "$CATEGORIES" | \
21996263Sobrien        awk 'BEGIN {print "Known categories:"; i = 0 }
22096263Sobrien          { printf ("%-'$l'.'$l's", $0); if ((++i % '$c') == 0) { print "" } }
22196263Sobrien            END { print ""; }'
22296263Sobrien	$REMOVE_TEMP
22396263Sobrien        exit 0
22496263Sobrien        ;;
22596263Sobrienesac
22696263Sobrien
22796263SobrienORIGINATOR_C='<name of the PR author (one line)>'
22896263SobrienORGANIZATION_C='<organization of PR author (multiple lines)>'
22996263SobrienSYNOPSIS_C='<synopsis of the problem (one line)>'
23096263Sobrienif [ -z "$SEVERITY_C" ]; then
23196263Sobrien  SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
23296263Sobrienfi
23396263SobrienPRIORITY_C='<[ low | medium ] (one line)>'
23496263SobrienCATEGORY_C='<choose from the top of this file (one line)>'
23596263SobrienRELEASE_C='<release number or tag (one line)>'
23696263SobrienENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
23796263SobrienDESCRIPTION_C='<precise description of the problem (multiple lines)>'
23896263SobrienHOW_TO_REPEAT_C='<When reporting a compiler error, preprocessor output must be included>'
23996263SobrienFIX_C='<how to correct or work around the problem, if known (multiple lines)>'
24096263Sobrien
24196263Sobrien# Catch some signals. ($xs kludge needed by Sun /bin/sh)
24296263Sobrienxs=0
24396263Sobrientrap '$REMOVE_TEMP; exit $xs' 0
24496263Sobrientrap 'echo "$COMMAND: Aborting ..."; $REMOVE_TEMP; xs=1; exit' 1 3 13 15
24596263Sobrien
24696263Sobrien# If they told us to use a specific file, then do so.
24796263Sobrienif [ -n "$IN_FILE" ]; then
24896263Sobrien  if [ "$IN_FILE" = "-" ]; then
24996263Sobrien    # The PR is coming from the standard input.
25096263Sobrien    if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
25196263Sobrien      sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" > $TEMP
25296263Sobrien    else
25396263Sobrien      cat > $TEMP
25496263Sobrien    fi
25596263Sobrien  else
25696263Sobrien    # Use the file they named.
25796263Sobrien    if [ -n "$EXPLICIT_GNATS_ADDR" ]; then
25896263Sobrien      sed -e "s;^[Tt][Oo]:.*;To: $GNATS_ADDR;" $IN_FILE > $TEMP
25996263Sobrien    else
26096263Sobrien      cat $IN_FILE > $TEMP
26196263Sobrien    fi
26296263Sobrien  fi
26396263Sobrienelse
26496263Sobrien
26596263Sobrien  if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
26696263Sobrien    # If their PR_FORM points to a bogus entry, then bail.
26796263Sobrien    if [ ! -f "$PR_FORM" -o ! -r "$PR_FORM" -o ! -s "$PR_FORM" ]; then
26896263Sobrien      echo "$COMMAND: can't seem to read your template file (\`$PR_FORM'), ignoring PR_FORM"
26996263Sobrien      sleep 1
27096263Sobrien      PRINT_INTERN=bad_prform
27196263Sobrien    fi
27296263Sobrien  fi
27396263Sobrien
27496263Sobrien  if [ -n "$PR_FORM" -a -z "$PRINT_INTERN" ]; then
27596263Sobrien    cp $PR_FORM $TEMP || 
27696263Sobrien      ( echo "$COMMAND: could not copy $PR_FORM" ; xs=1; exit )
27796263Sobrien  else
27896263Sobrien    for file in $TEMP $REF ; do
27996263Sobrien      cat  > $file << '__EOF__'
28096263SobrienSEND-PR: -*- send-pr -*-
28196263SobrienSEND-PR: Lines starting with `SEND-PR' will be removed automatically, as
28296263SobrienSEND-PR: will all comments (text enclosed in `<' and `>').
28396263SobrienSEND-PR: 
28496263SobrienSEND-PR: Please consult the GCC manual if you are not sure how to
28596263SobrienSEND-PR: fill out a problem report.
28696263SobrienSEND-PR: Note that the Synopsis field is mandatory.  The Subject (for
28796263SobrienSEND-PR: the mail) will be made the same as Synopsis unless explicitly
28896263SobrienSEND-PR: changed.
28996263SobrienSEND-PR:
29096263SobrienSEND-PR: Choose from the following categories:
29196263SobrienSEND-PR:
29296263Sobrien__EOF__
29396263Sobrien
29496263Sobrien      # Format the categories so they fit onto lines.
29596263Sobrien	l=`echo "$CATEGORIES" | \
29696263Sobrien	awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
29796263Sobrien	     END {print max + 1;}'`
29896263Sobrien	c=`expr 61 / $l`
29996263Sobrien	if [ $c -eq 0 ]; then c=1; fi
30096263Sobrien	echo "$CATEGORIES" | \
30196263Sobrien        awk 'BEGIN {printf "SEND-PR: "; i = 0 }
30296263Sobrien          { printf ("%-'$l'.'$l's", $0);
30396263Sobrien	    if ((++i % '$c') == 0) { printf "\nSEND-PR: " } }
30496263Sobrien            END { printf "\nSEND-PR:\n"; }' >> $file
30596263Sobrien
30696263Sobrien      cat >> $file << __EOF__
30796263SobrienTo: $GNATS_ADDR
30896263SobrienSubject: 
30996263SobrienFrom: $FROM
31096263SobrienReply-To: $REPLYTO
31196263SobrienCc: $CC
31296263SobrienX-send-pr-version: $VERSION
31396263SobrienX-GNATS-Notify: 
31496263Sobrien
31596263Sobrien
31696263Sobrien>Submitter-Id:	$SUBMITTER
31796263Sobrien>Originator:	$ORIGINATOR
31896263Sobrien>Organization:	${ORGANIZATION-$ORGANIZATION_C}
31996263Sobrien>Confidential:	no
32096263SobrienSEND-PR: Leave "Confidential" as "no"; all GCC PRs are public.
32196263Sobrien>Synopsis:	$SYNOPSIS_C
32296263Sobrien>Severity:	$SEVERITY_C
32396263SobrienSEND-PR: critical     GCC is completely not operational; no work-around known.
32496263SobrienSEND-PR: serious      GCC is not working properly; a work-around is possible.
32596263SobrienSEND-PR: non-critical Report indicates minor problem.
32696263Sobrien>Priority:	$PRIORITY_C
32796263SobrienSEND-PR: medium       The problem should be solved in the next release.
32896263SobrienSEND-PR: low          The problem should be solve in a future release.
32996263Sobrien>Category:	$CATEGORY_C
33096263Sobrien>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)>
33196263SobrienSEND-PR: doc-bug          The documentation is incorrect.
33296263SobrienSEND-PR: accepts-illegal  GCC fails to reject erroneous code.
33396263SobrienSEND-PR: rejects-legal    GCC gives an error message for correct code.
33496263SobrienSEND-PR: wrong-code       The machine code generated by gcc is incorrect.
33596263SobrienSEND-PR: ice-on-legal-code   GCC gives an Internal Compiler Error (ICE)
33696263SobrienSEND-PR:                     for correct code
33796263SobrienSEND-PR: ice-on-illegal-code GCC gives an ICE instead of reporting an error
33896263SobrienSEND-PR: pessimizes-code     GCC misses an important optimization opportunity
33996263SobrienSEND-PR: sw-bug              Software bug of some other class than above
34096263SobrienSEND-PR: change-request      A feature in GCC is missing.
34196263SobrienSEND-PR: support             I need help with gcc.
34296263Sobrien>Release:	${DEFAULT_RELEASE-$RELEASE_C}
34396263Sobrien>Environment:
34496263Sobrien`[ -n "$SYSTEM" ] && echo System: $SYSTEM`
34596263Sobrien`[ -n "$ARCH" ] && echo Architecture: $ARCH`
34696263Sobrien`[ -n "$MACHINE" ] && echo Machine: $MACHINE`
34796263Sobrien	$ENVIRONMENT_C
34896263Sobrienhost: @host@
34996263Sobrienbuild: @build@
35096263Sobrientarget: @target@
351132718Skan__EOF__
352132718Skan      cat >> $file << \__EOF__
35396263Sobrienconfigured with: @gcc_config_arguments@
354132718Skan__EOF__
355132718Skan      cat >> $file << __EOF__
35696263Sobrien>Description:
35796263Sobrien	$DESCRIPTION_C
35896263Sobrien>How-To-Repeat:
35996263Sobrien	$HOW_TO_REPEAT_C
36096263Sobrien>Fix:
36196263Sobrien	$FIX_C
36296263Sobrien__EOF__
36396263Sobrien    done
36496263Sobrien  fi
36596263Sobrien
36696263Sobrien  if [ "$PRINT" = true -o "$PRINT_INTERN" = true ]; then
36796263Sobrien    cat $TEMP
36896263Sobrien    xs=0; exit
36996263Sobrien  fi
37096263Sobrien
37196263Sobrien  chmod u+w $TEMP
37296263Sobrien  if [ -z "$REQUEST_ID" ]; then
37396263Sobrien    eval $EDIT $TEMP
37496263Sobrien  else
37596263Sobrien    ed -s $TEMP << '__EOF__'
37696263Sobrien/^Subject/s/^Subject:.*/Subject: request for a customer id/
37796263Sobrien/^>Category/s/^>Category:.*/>Category: send-pr/
37896263Sobrienw
37996263Sobrienq
38096263Sobrien__EOF__
38196263Sobrien  fi
38296263Sobrien
38396263Sobrien  if cmp -s $REF $TEMP ; then
38496263Sobrien    echo "$COMMAND: problem report not filled out, therefore not sent"
38596263Sobrien    xs=1; exit
38696263Sobrien  fi
38796263Sobrienfi
38896263Sobrien
38996263Sobrien#
39096263Sobrien#	Check the enumeration fields
39196263Sobrien
39296263Sobrien# This is a "sed-subroutine" with one keyword parameter 
39396263Sobrien# (with workaround for Sun sed bug)
39496263Sobrien#
39596263SobrienSED_CMD='
39696263Sobrien/$PATTERN/{
39796263Sobriens|||
39896263Sobriens|<.*>||
39996263Sobriens|^[ 	]*||
40096263Sobriens|[ 	]*$||
40196263Sobrienp
40296263Sobrienq
40396263Sobrien}'
40496263Sobrien
40596263Sobrien
40696263Sobrienwhile [ -z "$REQUEST_ID" ]; do
40796263Sobrien  CNT=0
40896263Sobrien
40996263Sobrien  # 1) Confidential
41096263Sobrien  #
41196263Sobrien  PATTERN=">Confidential:"
41296263Sobrien  CONFIDENTIAL=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
41396263Sobrien  case "$CONFIDENTIAL" in
41496263Sobrien    no) CNT=`expr $CNT + 1` ;;
41596263Sobrien    *) echo "$COMMAND: \`$CONFIDENTIAL' is not a valid value for \`Confidential'." ;;
41696263Sobrien  esac
41796263Sobrien  #
41896263Sobrien  # 2) Severity
41996263Sobrien  #
42096263Sobrien  PATTERN=">Severity:"
42196263Sobrien  SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
42296263Sobrien  case "$SEVERITY" in
42396263Sobrien    ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
42496263Sobrien    *)  echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
42596263Sobrien  esac
42696263Sobrien  #
42796263Sobrien  # 3) Priority
42896263Sobrien  #
42996263Sobrien  PATTERN=">Priority:"
43096263Sobrien  PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
43196263Sobrien  case "$PRIORITY" in
43296263Sobrien    ""|low|medium) CNT=`expr $CNT + 1` ;;
43396263Sobrien    high) echo "$COMMAND: \`Priority: high' is reserved for GCC maintainers." ;;
43496263Sobrien    *)  echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
43596263Sobrien  esac
43696263Sobrien  #
43796263Sobrien  # 4) Category
43896263Sobrien  #
43996263Sobrien  PATTERN=">Category:"
44096263Sobrien  CATEGORY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
44196263Sobrien  FOUND=
44296263Sobrien  for C in $CATEGORIES
44396263Sobrien  do
44496263Sobrien    if [ "$C" = "$CATEGORY" ]; then FOUND=true ; break ; fi
44596263Sobrien  done
44696263Sobrien  if [ -n "$FOUND" ]; then
44796263Sobrien    CNT=`expr $CNT + 1`	
44896263Sobrien  else
44996263Sobrien    if [ -z "$CATEGORY" ]; then
45096263Sobrien      echo "$COMMAND: you must include a Category: field in your report."
45196263Sobrien    else
45296263Sobrien      echo "$COMMAND: \`$CATEGORY' is not a known category."
45396263Sobrien    fi
45496263Sobrien  fi
45596263Sobrien  #
45696263Sobrien  # 5) Class
45796263Sobrien  #
45896263Sobrien  PATTERN=">Class:"
45996263Sobrien  CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
46096263Sobrien  case "$CLASS" in
46196263Sobrien    ""|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` ;;
46296263Sobrien    *)  echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
46396263Sobrien  esac
46496263Sobrien  #
46596263Sobrien  # 6) Check that synopsis is not empty
46696263Sobrien  #
46796263Sobrien  if grep "^>Synopsis:[ 	]*${SYNOPSIS_C}\$" $TEMP > /dev/null
46896263Sobrien  then
46996263Sobrien    echo "$COMMAND: Synopsis must not be empty."
47096263Sobrien  else
47196263Sobrien    CNT=`expr $CNT + 1`
47296263Sobrien  fi
47396263Sobrien
47496263Sobrien  [ $CNT -lt 6 -a -z "$BATCH" ] && 
47596263Sobrien    echo "Errors were found with the problem report."
47696263Sobrien
47796263Sobrien  while true; do
47896263Sobrien    if [ -z "$BATCH" ]; then
47996263Sobrien      $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
48096263Sobrien      read input
48196263Sobrien    else
48296263Sobrien      if [ $CNT -eq 6 ]; then
48396263Sobrien        input=s
48496263Sobrien      else
48596263Sobrien        input=a
48696263Sobrien      fi
48796263Sobrien    fi
48896263Sobrien    case "$input" in
48996263Sobrien      a*)
49096263Sobrien	if [ -z "$BATCH" ]; then
49196263Sobrien	  echo "$COMMAND: the problem report remains in $BAD and is not sent."
49296263Sobrien	  REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF"
49396263Sobrien	  mv $TEMP $BAD
49496263Sobrien        else
49596263Sobrien	  echo "$COMMAND: the problem report is not sent."
49696263Sobrien	fi
49796263Sobrien	xs=1; exit
49896263Sobrien	;;
49996263Sobrien      e*)
50096263Sobrien        eval $EDIT $TEMP
50196263Sobrien	continue 2
50296263Sobrien	;;
50396263Sobrien      s*)
50496263Sobrien	break 2
50596263Sobrien	;;
50696263Sobrien    esac
50796263Sobrien  done
50896263Sobriendone
50996263Sobrien
51096263Sobrien#
51196263Sobrien# Make sure the mail has got a Subject.  If not, use the same as
51296263Sobrien# in Synopsis.
51396263Sobrien#
51496263Sobrien
51596263Sobrienif grep '^Subject:[ 	]*$' $TEMP > /dev/null
51696263Sobrienthen
51796263Sobrien  SYNOPSIS=`grep '^>Synopsis:' $TEMP | sed -e 's/^>Synopsis:[ 	]*//'`
51896263Sobrien  ed -s $TEMP << __EOF__
51996263Sobrien/^Subject:/s/:.*\$/: $SYNOPSIS/
52096263Sobrienw
52196263Sobrienq
52296263Sobrien__EOF__
52396263Sobrienfi
52496263Sobrien
52596263Sobrien#
52696263Sobrien#	Remove comments and send the problem report
52796263Sobrien#	(we have to use patterns, where the comment contains regex chars)
52896263Sobrien#
52996263Sobrien# /^>Originator:/s;$ORIGINATOR;;
53096263Sobriensed  -e "
53196263Sobrien/^SEND-PR:/d
53296263Sobrien/^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
53396263Sobrien/^>Confidential:/s;<.*>;;
53496263Sobrien/^>Synopsis:/s;$SYNOPSIS_C;;
53596263Sobrien/^>Severity:/s;<.*>;;
53696263Sobrien/^>Priority:/s;<.*>;;
53796263Sobrien/^>Category:/s;$CATEGORY_C;;
53896263Sobrien/^>Class:/s;<.*>;;
53996263Sobrien/^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
54096263Sobrien/^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
54196263Sobrien/^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
54296263Sobrien/^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
54396263Sobrien/^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
54496263Sobrien" $TEMP > $REF
54596263Sobrien
54696263Sobrienif $MAIL_AGENT < $REF; then
54796263Sobrien  echo "$COMMAND: problem report sent"
54896263Sobrien  xs=0; exit
54996263Sobrienelse
55096263Sobrien  echo "$COMMAND: mysterious mail failure."
55196263Sobrien  if [ -z "$BATCH" ]; then
55296263Sobrien    echo "$COMMAND: the problem report remains in $BAD and is not sent."
55396263Sobrien    REMOVE_TEMP="rm -f $TEMP0 $TEMP $REF"
55496263Sobrien    mv $REF $BAD
55596263Sobrien  else
55696263Sobrien    echo "$COMMAND: the problem report is not sent."
55796263Sobrien  fi
55896263Sobrien  xs=1; exit
55996263Sobrienfi
560