Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <vladimir@codesourcery.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb@sources.redhat.com
Subject: Re: gdb v7.0 - user defined command's document section - space prefixed end
Date: Thu, 19 Nov 2009 07:17:00 -0000	[thread overview]
Message-ID: <200911182341.56401.vladimir@codesourcery.com> (raw)
In-Reply-To: <20091113143605.GA18096@caradoc.them.org>

[-- Attachment #1: Type: Text/Plain, Size: 886 bytes --]

On Friday 13 November 2009 17:36:05 Daniel Jacobowitz wrote:

> On Fri, Nov 06, 2009 at 08:56:40PM +0300, Vladimir Prus wrote:
> > Note that comment has disappeared, but it's not me -- process_next_line is given
> > an empty string, presumably because readline is trying to act smart.
> 
> It's command_line_input, from top.c.  It also does history expansion.
> Oh, well... for another day.
> 
> This patch is OK.  Please include changelogs...
> 
> > +  if (parse_commands)
> > +    {
> > +      /* If commands are parsed, we skip initial spaces. Otherwise,
> > +        which is the case for Python commands and documentation
> > +        (see the 'document' command), spaces are preserved.  */
> > +      p = p2;
> > +    }
> > 
> >    if (parse_commands)
> >      {
> > 
> 
> Want to combine the two if statements?

Yes, thanks. Here's the final version I've checked in.

- Volodya


[-- Attachment #2: final.diff --]
[-- Type: text/x-patch, Size: 2248 bytes --]

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.11088
diff -u -p -r1.11088 ChangeLog
--- gdb/ChangeLog	18 Nov 2009 16:28:42 -0000	1.11088
+++ gdb/ChangeLog	18 Nov 2009 20:40:56 -0000
@@ -1,3 +1,9 @@
+2009-11-18  Vladimir Prus  <vladimir@codesourcery.com>
+
+	* cli/cli-script.c (process_next_line): Recognize 'end'
+	even when the line has leading space and we're not parsing
+	commands.
+
 2009-11-18  Tom Tromey  <tromey@redhat.com>
 
 	* symtab.c (symbol_set_names): Correctly set 'name' on symbol when
Index: gdb/cli/cli-script.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-script.c,v
retrieving revision 1.53
diff -u -p -r1.53 cli-script.c
--- gdb/cli/cli-script.c	3 Aug 2009 12:26:37 -0000	1.53
+++ gdb/cli/cli-script.c	18 Nov 2009 20:40:56 -0000
@@ -879,30 +879,35 @@ static enum misc_command_type
 process_next_line (char *p, struct command_line **command, int parse_commands)
 {
   char *p1;
+  char *p2;
   int not_handled = 0;
 
   /* Not sure what to do here.  */
   if (p == NULL)
     return end_command;
 
-  if (parse_commands)
-    {
-      /* Strip leading whitespace.  */
-      while (*p == ' ' || *p == '\t')
-	p++;
-    }
-
   /* Strip trailing whitespace.  */
   p1 = p + strlen (p);
   while (p1 != p && (p1[-1] == ' ' || p1[-1] == '\t'))
     p1--;
 
-  /* Is this the end of a simple, while, or if control structure?  */
-  if (p1 - p == 3 && !strncmp (p, "end", 3))
+  p2 = p;
+  /* Strip leading whitespace.  */
+  while (*p2 == ' ' || *p2 == '\t')
+    p2++;
+
+  /* 'end' is always recognized, regardless of parse_commands value. 
+     We also permit whitespace before end and after.  */
+  if (p1 - p2 == 3 && !strncmp (p2, "end", 3))
     return end_command;
-
+  
   if (parse_commands)
     {
+      /* If commands are parsed, we skip initial spaces. Otherwise,
+	 which is the case for Python commands and documentation
+	 (see the 'document' command), spaces are preserved.  */
+      p = p2;
+
       /* Blanks and comments don't really do anything, but we need to
 	 distinguish them from else, end and other commands which can be
 	 executed.  */

  reply	other threads:[~2009-11-18 20:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-28  6:12 James Pandavan
2009-11-03 14:33 ` Joel Brobecker
2009-11-03 18:58   ` James Pandavan
2009-11-03 19:43     ` Joel Brobecker
2009-11-03 19:51       ` Daniel Jacobowitz
2009-11-03 22:03         ` Jim Ingham
2009-11-06 21:42         ` Vladimir Prus
2009-11-06 21:49           ` Daniel Jacobowitz
2009-11-07  1:14             ` Vladimir Prus
2009-11-13 23:41               ` Daniel Jacobowitz
2009-11-19  7:17                 ` Vladimir Prus [this message]
2009-11-04 20:47       ` Tom Tromey
2009-11-04 21:07         ` Paul Koning
2009-11-04 21:18           ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200911182341.56401.vladimir@codesourcery.com \
    --to=vladimir@codesourcery.com \
    --cc=drow@false.org \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox