From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 876 invoked from network); 9 Feb 2003 07:48:53 -0000 Received: from unknown (HELO monty-python.gnu.org) (199.232.76.173) by 172.16.49.205 with SMTP; 9 Feb 2003 07:48:53 -0000 Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18hmCC-000106-00 for listarch-gnats-devel@sources.redhat.com; Sun, 09 Feb 2003 02:48:12 -0500 Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18hmBz-000100-00 for help-gnats@gnu.org; Sun, 09 Feb 2003 02:47:59 -0500 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18hmBw-0000up-00 for help-gnats@gnu.org; Sun, 09 Feb 2003 02:47:58 -0500 Received: from ppp133.adsl88.pacific.net.au ([202.7.88.133] helo=localhost.localdomain) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18hmBt-0000lq-00 for help-gnats@gnu.org; Sun, 09 Feb 2003 02:47:54 -0500 Received: (from andrewg@localhost) by localhost.localdomain (8.11.2/8.11.2) id h196nS607794; Sun, 9 Feb 2003 17:49:28 +1100 Date: Sun, 09 Feb 2003 07:48:00 -0000 Message-Id: <200302090649.h196nS607794@localhost.localdomain> From: "Andrew J. Gray" To: hatzis@juniper.net In-reply-to: <3E3ED43B.4020305@juniper.net> (message from Mel Hatzis on Mon, 03 Feb 2003 12:42:35 -0800) References: <200212021037.gB2Ab8D04083@localhost.localdomain> <3DEBE798.4030702@juniper.net> <200212080625.gB86Pvh07876@localhost.localdomain> <3DF3A833.3060508@juniper.net> <200302020832.h128Wef03254@localhost.localdomain> <3E3ED43B.4020305@juniper.net> cc: help-gnats@gnu.org Subject: Re: patch to display new PR number for new submissions X-BeenThere: help-gnats@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: General discussion about GNU GNATS List-Help: List-Post: List-Subscribe: , List-Archive: Sender: help-gnats-bounces+listarch-gnats-devel=sources.redhat.com@gnu.org Errors-To: help-gnats-bounces+listarch-gnats-devel=sources.redhat.com@gnu.org X-SW-Source: 2003-q1/txt/msg00065.txt.bz2 Thanks for your comments on my modifications. > One small concern with the patch though...in get_reply you've made > a change allowing for outfp to be NULL... Actually, outfp was already allowed to be NULL in some cases, get_reply is called passing NULL for outfp in a number of places in client.c. It appears that the client code avoids referencing outfp when it is NULL by relying on the server code to send the expected responses. > However, immediately above this code, there's another reference to > 'outfp' which is unprotected.... > > else > { > read_server (outfp); > } > > I suggest that you put some checks for NULL around this too. Thanks, that is a good idea. > > -the database. A zero exit code is returned if the submission was > > -successful. Otherwise, the reason(s) for the PR being rejected are > > -printed to stdout, and a non-zero exit code is returned. > > +the database. If the submission a zero exit code is returned. > ^^^^^^ > I think you're missing 'is successful' in the above sentence. Yes, thanks for picking up that error. A new patch with changes to fix these issues is at the end of this message. > > Since this change is an enhancement and modifies the gnatsd command > > protocol I am thinking it should not be included in GNATS 4.0 final, > > but put on a 4.1 branch. What do people think? > > I'm in favour of rolling out 4.0 pretty soon....if you think putting > this patch on a 4.1 branch would help this endevour, I'd suggest > you do just that. OK, I will hold this patch for when we create a 4.1 branch. -- Andrew J. Gray Index: doc/gnats.texi =================================================================== RCS file: /cvsroot/gnats/gnats/doc/gnats.texi,v retrieving revision 1.40 diff -u -p -r1.40 gnats.texi --- doc/gnats.texi 25 Nov 2002 08:48:44 -0000 1.40 +++ doc/gnats.texi 9 Feb 2003 02:42:51 -0000 @@ -1386,8 +1386,9 @@ lock is cleared. @code{211 (CODE_SEND_PR)} @*The client should now transmit the new PR text using the normal quoting mechanism. After the PR has been sent, the server will respond -with either a @code{200 (CODE_OK)} response indicating that the new PR -has been created (and mail sent to the appropriate persons), or one or +with either @code{351 (CODE_INFORMATION_FILLER)} and +@code{350 (CODE_INFORMATION)} responses indicating that the new PR +has been created and supplying the number assigned to it, or one or more error codes listing problems with the new PR text. @item CHDB @var{database} Index: doc/p-admin.texi =================================================================== RCS file: /cvsroot/gnats/gnats/doc/p-admin.texi,v retrieving revision 1.34 diff -u -p -r1.34 p-admin.texi --- doc/p-admin.texi 27 Nov 2002 22:04:38 -0000 1.34 +++ doc/p-admin.texi 9 Feb 2003 02:43:06 -0000 @@ -2083,7 +2083,7 @@ The usage for @code{pr-edit} is: @smallexample pr-edit [ -l @var{username} | --lock=@var{username} ] [ -u | --unlockdb ] [ -L | --lockdb ] [ -U | --unlockdb ] [ -c | --check ] - [ -C | --check-initial ] [ -s | --submit ] + [ -C | --check-initial ] [ -s | --submit [ --show-prnum ] ] [ -a @var{field} | --append field=@var{field} ] [ -r @var{field} | --replace=@var{field} ] [ --delete-pr ] [ -R @var{reason} | --reason=@var{reason} ] @@ -2147,9 +2147,13 @@ rather than proposed edits of existing P @itemx --submit Used to submit a new PR to the database. The PR is read in and verified for content; if the PR is valid as an initial PR, it is then added to -the database. A zero exit code is returned if the submission was -successful. Otherwise, the reason(s) for the PR being rejected are -printed to stdout, and a non-zero exit code is returned. +the database. If the submission is successful a zero exit code is +returned. Otherwise, the reason(s) for the PR being rejected are +printed, and a non-zero exit code is returned. + +@item --show-prnum +This option is used with the @code{--submit} option to display the PR +number associated with the submitted PR. @end table @noindent The following options require a PR number to be given. Index: gnats/client.c =================================================================== RCS file: /cvsroot/gnats/gnats/gnats/client.c,v retrieving revision 1.46 diff -u -p -r1.46 client.c --- gnats/client.c 25 Nov 2002 13:58:33 -0000 1.46 +++ gnats/client.c 9 Feb 2003 02:43:11 -0000 @@ -329,12 +329,20 @@ get_reply (FILE *outfp) } else { - read_server (outfp); + if (outfp != NULL) + read_server (outfp); + else + { + fprintf (stderr, "%s: unexpected %d received\n", + program_name, r->state); + safe_exit(); + } } break; case CODE_INFORMATION: - fprintf (outfp, "%s\n", r->text); + if (outfp != NULL) + fprintf (outfp, "%s\n", r->text); break; case CODE_NONEXISTENT_PR: @@ -1216,7 +1224,7 @@ netSetEditEmailAddr (const char *addr) } static void -netSendPRCmd (const char *cmd, FILE *file) +netSendPRCmd (const char *cmd, FILE *file, int show_information) { char *line; if (debug) @@ -1233,13 +1241,13 @@ netSendPRCmd (const char *cmd, FILE *fil } fprintf (serv_write, ".\r\n"); /* if get_reply finds errors it writes messages and doesn't return */ - get_reply (stdout); + get_reply (show_information ? stdout : NULL); } void netCheckPR (FILE *file, int initial) { - netSendPRCmd (initial ? "CHEK INIT" : "CHEK", file); + netSendPRCmd (initial ? "CHEK INIT" : "CHEK", file, 1); } void @@ -1298,9 +1306,9 @@ netEditField (FILE *fp, const char *prnu } void -netSubmitNewPR (FILE *file) +netSubmitNewPR (FILE *file, int show_prnum) { - netSendPRCmd ("SUBM", file); + netSendPRCmd ("SUBM", file, show_prnum); } void @@ -1310,7 +1318,7 @@ netModifyPR (FILE *file, const char *prN netSetEditEmailAddr (editEmailAddr); asprintf (&buf, "EDIT %s", prNum); - netSendPRCmd (buf, file); + netSendPRCmd (buf, file, 1); free (buf); } Index: gnats/cmds.c =================================================================== RCS file: /cvsroot/gnats/gnats/gnats/cmds.c,v retrieving revision 1.70 diff -u -p -r1.70 cmds.c --- gnats/cmds.c 14 Oct 2002 11:42:25 -0000 1.70 +++ gnats/cmds.c 9 Feb 2003 02:43:17 -0000 @@ -478,6 +478,7 @@ GNATS_subm (int ac, char **av ATTRIBUTE_ char *tempfile; FILE *fp; ErrorDesc err; + int new_pr_num; if (ac != 0) { @@ -507,9 +508,11 @@ GNATS_subm (int ac, char **av ATTRIBUTE_ { if (daemon_lock_gnats (FALSE) == 0) { - if (submit_pr (currentDatabase, fp, &err) != 0) + if ((new_pr_num = submit_pr (currentDatabase, fp, &err)) != 0) { - printf ("%d PR added.\r\n", CODE_OK); + printf ("%d-The added PR number is:\r\n", + CODE_INFORMATION_FILLER); + printf ("%d %d\r\n", CODE_INFORMATION, new_pr_num); fflush (stdout); } else Index: gnats/file-pr.c =================================================================== RCS file: /cvsroot/gnats/gnats/gnats/file-pr.c,v retrieving revision 1.51 diff -u -p -r1.51 file-pr.c --- gnats/file-pr.c 1 Nov 2002 11:37:51 -0000 1.51 +++ gnats/file-pr.c 9 Feb 2003 02:43:21 -0000 @@ -930,11 +930,13 @@ getBugNumber (const DatabaseInfo databas return bug_number; } -/* Submit the PR whose contents are referred to by FP. */ +/* Submit the PR whose contents are referred to by FP. + * Return the new PR number if it's a new PR, or return the PR number of + * the PR which was appended to if it's an existing PR. */ int submit_pr (const DatabaseInfo database, FILE *fp, ErrorDesc *err) { - int result; + int result, retval; PR *pr = allocPR (database); result = (read_header (pr, fp) >= 0); @@ -956,10 +958,8 @@ submit_pr (const DatabaseInfo database, } else { - if (append_report (fp, pr, prID, err) != 0) - { - result = 0; - } + retval = append_report (fp, pr, prID, err); + result = (retval == 0) ? atoi (prID) : 0; free_pr (pr); } free (prID); @@ -967,10 +967,8 @@ submit_pr (const DatabaseInfo database, else { read_pr (pr, fp, 0); - if (createNewPRFile (pr, createCategoryDirs (database), err) < 0) - { - result = 0; - } + retval = createNewPRFile (pr, createCategoryDirs (database), err); + result = (retval < 0) ? 0 : retval; } } else Index: gnats/gnats.h =================================================================== RCS file: /cvsroot/gnats/gnats/gnats/gnats.h,v retrieving revision 1.52 diff -u -p -r1.52 gnats.h --- gnats/gnats.h 31 Oct 2002 23:43:28 -0000 1.52 +++ gnats/gnats.h 9 Feb 2003 02:43:22 -0000 @@ -292,7 +292,7 @@ extern void netEditField (FILE *fieldDat const char *editUserEmailAddr, int appendToField, char *reason); -extern void netSubmitNewPR (FILE *file); +extern void netSubmitNewPR (FILE *file, int show_prnum); extern void netModifyPR (FILE *file, const char *prNum, const char *editUserEmailAddr); extern void netLockDB (void); Index: gnats/pr-edit.c =================================================================== RCS file: /cvsroot/gnats/gnats/gnats/pr-edit.c,v retrieving revision 1.37 diff -u -p -r1.37 pr-edit.c --- gnats/pr-edit.c 1 Nov 2002 09:02:23 -0000 1.37 +++ gnats/pr-edit.c 9 Feb 2003 02:43:25 -0000 @@ -43,6 +43,7 @@ enum { } edit_options; #define DELETE_PR_OPT 256 +#define SHOW_PRNUM_OPT 257 struct option long_options[] = { @@ -61,6 +62,7 @@ struct option long_options[] = {"filename", 1, NULL, 'f'}, {"version", 0, NULL, 'V'}, {"delete-pr", 0, NULL, DELETE_PR_OPT}, + {"show-prnum", 0, NULL, SHOW_PRNUM_OPT}, {"help", 0, NULL, 'h'}, {"user", 1, NULL, 'v'}, {"passwd", 1, NULL, 'w'}, @@ -83,9 +85,10 @@ Modify database.\n\ -L --lockdb lock the whole database\n\ -U --unlockdb unlock the database\n\ -c --check check input for editting, don't change PR\n\ - -C --check-initial check input for submition, don't submit new PR\n\ + -C --check-initial check input for submission, don't submit new PR\n\ -s --submit submit new PR\n", "\ + --show-prnum display the newly created PR number (for --submit)\n\ -a --append=FIELDNAME append input to FIELDNAME\n\ -r --replace=FIELDNAME replace FIELDNAME with input\n\ --delete-pr delete PR from the database completely\n\ @@ -145,7 +148,7 @@ read_file (FILE *inp) static void handleNetworkEdit (int edit_options, FILE *fpin, char *prnum, char *username, char *editEmailAddr, char *processid, char *fieldname, - char *reason) + char *reason, int show_prnum) { int exitcode = 0; @@ -165,7 +168,7 @@ handleNetworkEdit (int edit_options, FIL break; case SUBMIT: { - netSubmitNewPR (fpin); + netSubmitNewPR (fpin, show_prnum); break; } case CHECK: @@ -216,6 +219,7 @@ main (int argc, char **argv) int networkmode = 0; char *editUserEmailAddr = NULL; char *reason = NULL; + int show_prnum = 0; program_name = basename (argv[0]); edit_options = MODIFY; @@ -233,6 +237,10 @@ main (int argc, char **argv) debug = 1; break; + case SHOW_PRNUM_OPT: + show_prnum = 1; + break; + case 'f': fp = fopen (optarg, "r"); /* If they gave a bogus argument, then exit right away; we don't @@ -398,7 +406,7 @@ main (int argc, char **argv) exit (3); } handleNetworkEdit (edit_options, fp, prnum, username, editUserEmailAddr, - processid, fieldname, reason); + processid, fieldname, reason, show_prnum); } database = init_gnats (program_name, nameOfDatabase, &err); @@ -467,6 +475,10 @@ main (int argc, char **argv) case SUBMIT: { result = submit_pr (database, fp, &err); + if (show_prnum && result) + { + fprintf (stdout, "%d\n", result); + } break; } case APPEND: Index: send-pr/send-pr.sh =================================================================== RCS file: /cvsroot/gnats/gnats/send-pr/send-pr.sh,v retrieving revision 1.23 diff -u -p -r1.23 send-pr.sh --- send-pr/send-pr.sh 29 Oct 2002 09:58:15 -0000 1.23 +++ send-pr/send-pr.sh 9 Feb 2003 02:43:28 -0000 @@ -536,8 +536,8 @@ do echo "$COMMAND: problem report mailed" xs=0; exit else - if $LIBEXECDIR/pr-edit --submit < $REF; then - echo "$COMMAND: problem report filed" + if pr_num=`$LIBEXECDIR/pr-edit --submit --show-prnum < $REF` ; then + echo "$COMMAND: problem report $pr_num filed" xs=0; exit else echo "$COMMAND: the problem report is not sent." _______________________________________________ Help-gnats mailing list Help-gnats@gnu.org http://mail.gnu.org/mailman/listinfo/help-gnats