public inbox for gnats-devel@sourceware.org
 help / color / mirror / Atom feed
* Extra empty line in Unformatted
@ 2003-01-08 19:26 Lars Henriksen
  2003-01-08 20:46 ` Lars Henriksen
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Henriksen @ 2003-01-08 19:26 UTC (permalink / raw)
  To: help-gnats

Have you ever pondered over this comment in parsepr() in gnatsweb 4?

  # 3/30/99 kenstir: For some reason Unformatted always ends up with an
  # extra newline here.
  $fields{$UNFORMATTED_FIELD} ||= ''; # Default to empty value
  $fields{$UNFORMATTED_FIELD} =~ s/\n$//;

I have, and now I've found the reason for the extra newline. The bug is in
GNATS: a query with format 'full' returns an extra, empty line after each PR.
Try "query-pr --format=full <PR>" and compare with the PR file in the
database. The command "pr-edit --lock <user> <PR>" also returns the full PR,
but without the extra newline.

This is of no consequence when viewing PRs, but it is when editing. Gnatsweb
retrieves a PR for editing with the equivalent of the query-pr command above
and fills in the form. When the user submits the form, gnatsweb retrieves and
locks the PR with the equivalent of the pr-edit command above. Gnatsweb then
overwrites the old PR fields with the values from the form. Without the hack
above the last PR field (which happens to be Unformatted) will get an extra
line appended.

Fix follows.

Lars Henriksen

Index: cmds.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/cmds.c,v
retrieving revision 1.70
diff -u -p -r1.70 cmds.c
--- cmds.c	14 Oct 2002 11:42:25 -0000	1.70
+++ cmds.c	8 Jan 2003 19:01:00 -0000
@@ -281,7 +281,7 @@ server_print_query (int which, PR *pr, Q
 	}
       else
 	{
-	  printf ("\r\n.\r\n");
+	  printf (".\r\n");
 	}
     }
 }


_______________________________________________
Help-gnats mailing list
Help-gnats@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnats

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Extra empty line in Unformatted
  2003-01-08 19:26 Extra empty line in Unformatted Lars Henriksen
@ 2003-01-08 20:46 ` Lars Henriksen
  2003-01-10  7:23   ` gnatsd end-of-line termination Lars Henriksen
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Henriksen @ 2003-01-08 20:46 UTC (permalink / raw)
  To: help-gnats

On Wed, Jan 08, 2003 at 08:14:59PM +0100, Lars Henriksen wrote:
> Have you ever pondered over this comment in parsepr() in gnatsweb 4?
> 
>   # 3/30/99 kenstir: For some reason Unformatted always ends up with an
>   # extra newline here.
>   $fields{$UNFORMATTED_FIELD} ||= ''; # Default to empty value
>   $fields{$UNFORMATTED_FIELD} =~ s/\n$//;
> 
> I have, and now I've found the reason for the extra newline. The bug is in
> GNATS: a query with format 'full' returns an extra, empty line after each PR.
> Try "query-pr --format=full <PR>" and compare with the PR file in the
> database. The command "pr-edit --lock <user> <PR>" also returns the full PR,
> but without the extra newline.
> 
[snip]
> Index: cmds.c
> ===================================================================
> RCS file: /cvsroot/gnats/gnats/gnats/cmds.c,v
> retrieving revision 1.70
> diff -u -p -r1.70 cmds.c
> --- cmds.c	14 Oct 2002 11:42:25 -0000	1.70
> +++ cmds.c	8 Jan 2003 19:01:00 -0000
> @@ -281,7 +281,7 @@ server_print_query (int which, PR *pr, Q
>  	}
>        else
>  	{
> -	  printf ("\r\n.\r\n");
> +	  printf (".\r\n");
>  	}
>      }
>  }

My "fix" breaks things hopelessly. A closer look at server_print_query()
reveals that it prints the "\r\n" sequence after every single query result.
If individual query results have no terminating newline, the results are
nicely broken into lines; if they have, they are separated by empty lines.

So maybe the problem is that gnatsweb doesn't take the separator line into
account?

Lars Henriksen


_______________________________________________
Help-gnats mailing list
Help-gnats@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnats

^ permalink raw reply	[flat|nested] 3+ messages in thread

* gnatsd end-of-line termination
  2003-01-08 20:46 ` Lars Henriksen
@ 2003-01-10  7:23   ` Lars Henriksen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Henriksen @ 2003-01-10  7:23 UTC (permalink / raw)
  To: help-gnats

On Wed, Jan 08, 2003 at 09:18:39PM +0100, Lars Henriksen wrote:
> On Wed, Jan 08, 2003 at 08:14:59PM +0100, Lars Henriksen wrote:
> My "fix" breaks things hopelessly. A closer look at server_print_query()
> reveals that it prints the "\r\n" sequence after every single query result.
> If individual query results have no terminating newline, the results are
> nicely broken into lines; if they have, they are separated by empty lines.

While trying to understand how replies are returned by gnatsd I discovered
that three list commands (list FieldNames, list InitialInputFields and list
InitialRequiredFields) terminate lines with "\n" and not with "\r\n". This is
contrary to the documentation. All other lines are terminated by "\r\n".

Lars Henriksen

Index: lists.c
===================================================================
RCS file: /cvsroot/gnats/gnats/gnats/lists.c,v
retrieving revision 1.20
diff -u -p -r1.20 lists.c
--- lists.c	28 Oct 2002 22:57:50 -0000	1.20
+++ lists.c	10 Jan 2003 07:19:48 -0000
@@ -131,7 +131,7 @@ getGnatsFile (const DatabaseInfo databas
 
 	for (x = 0; (f = getNthField (database, x)) != NULL; x++)
 	  {
-	    fprintf (fpout, "%s\n", fieldDefForIndex (f)->name);
+	    fprintf (fpout, "%s%s", fieldDefForIndex (f)->name, eolTerminator);
 	  }
 	break;
       }
@@ -142,7 +142,7 @@ getGnatsFile (const DatabaseInfo databas
 	for (t = getInputTemplate (database); t != NULL; t = t->next)
 	  {
 	    FieldDef field = fieldDefForIndex (t->index);
-	    fprintf (fpout, "%s\n", field->name);
+	    fprintf (fpout, "%s%s", field->name, eolTerminator);
 	  }
 	break;
       }
@@ -151,7 +151,9 @@ getGnatsFile (const DatabaseInfo databas
 	FieldList fields = getRequiredInputFields(database);
 	while (fields != NULL)
 	  {
-	    fprintf (fpout, "%s\n", complexFieldIndexToString (fields->ent));
+	    fprintf (fpout, "%s%s",
+		            complexFieldIndexToString (fields->ent),
+			    eolTerminator);
 	    fields = fields->next;
 	  }
 	break;


_______________________________________________
Help-gnats mailing list
Help-gnats@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnats

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-01-10  7:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-08 19:26 Extra empty line in Unformatted Lars Henriksen
2003-01-08 20:46 ` Lars Henriksen
2003-01-10  7:23   ` gnatsd end-of-line termination Lars Henriksen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).