From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27789 invoked by alias); 1 Jan 2010 11:02:27 -0000 Received: (qmail 27541 invoked by uid 22791); 1 Jan 2010 11:02:26 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,FH_DATE_PAST_20XX,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Jan 2010 11:02:19 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o01B1uT6028208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 1 Jan 2010 06:01:56 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o01B1r09010281 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 1 Jan 2010 06:01:56 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o01B1rdK003124; Fri, 1 Jan 2010 12:01:53 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o01B1rON003123; Fri, 1 Jan 2010 12:01:53 +0100 Date: Fri, 01 Jan 2010 11:02:00 -0000 From: Jan Kratochvil To: Joel Brobecker Cc: gdb-patches@sourceware.org Subject: Re: [patch] Rename process_next_line variables Message-ID: <20100101110153.GA3117@host0.dyn.jankratochvil.net> References: <20100101084332.GA30042@host0.dyn.jankratochvil.net> <20100101103630.GS2788@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100101103630.GS2788@adacore.com> User-Agent: Mutt/1.5.20 (2009-08-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00017.txt.bz2 On Fri, 01 Jan 2010 11:36:30 +0100, Joel Brobecker wrote: > > 2010-01-01 Jan Kratochvil > > > > * cli/cli-script.c (process_next_line): Rename p1 as p_end and p2 as > > p_start. > > Sure, I agree it is clearer. Checked-in. Thanks, Jan http://sourceware.org/ml/gdb-cvs/2010-01/msg00015.html --- src/gdb/ChangeLog 2010/01/01 10:57:42 1.11191 +++ src/gdb/ChangeLog 2010/01/01 10:58:56 1.11192 @@ -1,5 +1,10 @@ 2010-01-01 Jan Kratochvil + * cli/cli-script.c (process_next_line): Rename p1 as p_end and p2 as + p_start. Change != comparisons to > and < comparisons. + +2010-01-01 Jan Kratochvil + * cli/cli-script.c (process_next_line): Check P2 overrun. 2009-01-01 Joel Brobecker --- src/gdb/cli/cli-script.c 2010/01/01 10:57:43 1.56 +++ src/gdb/cli/cli-script.c 2010/01/01 10:58:56 1.57 @@ -878,8 +878,8 @@ static enum misc_command_type process_next_line (char *p, struct command_line **command, int parse_commands) { - char *p1; - char *p2; + char *p_end; + char *p_start; int not_handled = 0; /* Not sure what to do here. */ @@ -887,18 +887,18 @@ return end_command; /* Strip trailing whitespace. */ - p1 = p + strlen (p); - while (p1 != p && (p1[-1] == ' ' || p1[-1] == '\t')) - p1--; + p_end = p + strlen (p); + while (p_end > p && (p_end[-1] == ' ' || p_end[-1] == '\t')) + p_end--; - p2 = p; + p_start = p; /* Strip leading whitespace. */ - while (p2 != p1 && (*p2 == ' ' || *p2 == '\t')) - p2++; + while (p_start < p_end && (*p_start == ' ' || *p_start == '\t')) + p_start++; /* '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)) + if (p_end - p_start == 3 && !strncmp (p_start, "end", 3)) return end_command; if (parse_commands) @@ -906,51 +906,51 @@ /* 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; + p = p_start; /* Blanks and comments don't really do anything, but we need to distinguish them from else, end and other commands which can be executed. */ - if (p1 == p || p[0] == '#') + if (p_end == p || p[0] == '#') return nop_command; /* Is the else clause of an if control structure? */ - if (p1 - p == 4 && !strncmp (p, "else", 4)) + if (p_end - p == 4 && !strncmp (p, "else", 4)) return else_command; /* Check for while, if, break, continue, etc and build a new command line structure for them. */ - if (p1 - p > 5 && !strncmp (p, "while", 5)) + if (p_end - p > 5 && !strncmp (p, "while", 5)) { char *first_arg; first_arg = p + 5; - while (first_arg < p1 && isspace (*first_arg)) + while (first_arg < p_end && isspace (*first_arg)) first_arg++; *command = build_command_line (while_control, first_arg); } - else if (p1 - p > 2 && !strncmp (p, "if", 2)) + else if (p_end - p > 2 && !strncmp (p, "if", 2)) { char *first_arg; first_arg = p + 2; - while (first_arg < p1 && isspace (*first_arg)) + while (first_arg < p_end && isspace (*first_arg)) first_arg++; *command = build_command_line (if_control, first_arg); } - else if (p1 - p >= 8 && !strncmp (p, "commands", 8)) + else if (p_end - p >= 8 && !strncmp (p, "commands", 8)) { char *first_arg; first_arg = p + 8; - while (first_arg < p1 && isspace (*first_arg)) + while (first_arg < p_end && isspace (*first_arg)) first_arg++; *command = build_command_line (commands_control, first_arg); } - else if (p1 - p == 6 && !strncmp (p, "python", 6)) + else if (p_end - p == 6 && !strncmp (p, "python", 6)) { /* Note that we ignore the inline "python command" form here. */ *command = build_command_line (python_control, ""); } - else if (p1 - p == 10 && !strncmp (p, "loop_break", 10)) + else if (p_end - p == 10 && !strncmp (p, "loop_break", 10)) { *command = (struct command_line *) xmalloc (sizeof (struct command_line)); @@ -960,7 +960,7 @@ (*command)->body_count = 0; (*command)->body_list = NULL; } - else if (p1 - p == 13 && !strncmp (p, "loop_continue", 13)) + else if (p_end - p == 13 && !strncmp (p, "loop_continue", 13)) { *command = (struct command_line *) xmalloc (sizeof (struct command_line)); @@ -980,7 +980,7 @@ *command = (struct command_line *) xmalloc (sizeof (struct command_line)); (*command)->next = NULL; - (*command)->line = savestring (p, p1 - p); + (*command)->line = savestring (p, p_end - p); (*command)->control_type = simple_control; (*command)->body_count = 0; (*command)->body_list = NULL;