summaryrefslogtreecommitdiff
path: root/gdb/cli/cli-script.c
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2009-11-18 20:42:34 +0000
committerVladimir Prus <vladimir@codesourcery.com>2009-11-18 20:42:34 +0000
commita0b3f377c27c23f882f45e632541ea9cd5a2ac4c (patch)
tree0f64728b1f26fb059938af1a269efac08279150b /gdb/cli/cli-script.c
parent35a34cb48b58adb0b1bf81f92d8f243ba90b09bb (diff)
downloadgdb-a0b3f377c27c23f882f45e632541ea9cd5a2ac4c.tar.gz
* cli/cli-script.c (process_next_line): Recognize 'end'
even when the line has leading space and we're not parsing commands.
Diffstat (limited to 'gdb/cli/cli-script.c')
-rw-r--r--gdb/cli/cli-script.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 6e90bf222bf..0f8f393e729 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -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))
- return end_command;
+ 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. */