Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Greg Watson <g.watson@computer.org>
To: gdb-patches@sourceware.org
Subject: Re: Improve handling of Fortran keywords
Date: Wed, 15 Dec 2010 18:52:00 -0000	[thread overview]
Message-ID: <9574F1C6-076E-44C8-A487-D97CA5088D54@computer.org> (raw)
In-Reply-To: <m3vd2wqmkl.fsf@fleche.redhat.com>

Nope, this is not going to work. If the identifier being printed is shorter than the keyword, they will match. You really have to check the length as well.

If you want to use namelen, then I think this is the minimum required change.

Greg

*** f-exp.y.orig	2010-12-14 10:28:34.542834692 -0500
--- f-exp.y	2010-12-15 13:49:51.189819361 -0500
***************
*** 1150,1157 ****
    /* Catch specific keywords.  */
    
    for (i = 0; f77_keywords[i].operator != NULL; i++)
!     if (strncmp (tokstart, f77_keywords[i].operator,
! 		 strlen(f77_keywords[i].operator)) == 0)
        {
  	/* 	lexptr += strlen(f77_keywords[i].operator); */ 
  	yylval.opcode = f77_keywords[i].opcode;
--- 1150,1157 ----
    /* Catch specific keywords.  */
    
    for (i = 0; f77_keywords[i].operator != NULL; i++)
!     if (strlen(f77_keywords[i].operator) == namelen &&
!             strncmp (tokstart, f77_keywords[i].operator, namelen) == 0)
        {
  	/* 	lexptr += strlen(f77_keywords[i].operator); */ 
  	yylval.opcode = f77_keywords[i].opcode;


On Dec 14, 2010, at 12:41 PM, Tom Tromey wrote:

>>>>>> "Greg" == Greg Watson <g.watson@computer.org> writes:
> 
> Greg> Currently, gdb 7.2 will not allow me to use identifier names such
> Greg> as "integer_var" as it treats the first "integer" part as a
> Greg> keyword without checking that the identifier is actually longer
> Greg> than the keyword. Here's a simple patch to fix this (and make
> Greg> Fortran debugging more useful).
> 
> Could you try this patch instead?
> 
> I think it should have the same effect, but it is simpler.
> 
> Tom
> 
> diff --git a/gdb/f-exp.y b/gdb/f-exp.y
> index 415819a..487b00d 100644
> --- a/gdb/f-exp.y
> +++ b/gdb/f-exp.y
> @@ -1150,8 +1150,7 @@ yylex ()
>   /* Catch specific keywords.  */
> 
>   for (i = 0; f77_keywords[i].operator != NULL; i++)
> -    if (strncmp (tokstart, f77_keywords[i].operator,
> -		 strlen(f77_keywords[i].operator)) == 0)
> +    if (strncmp (tokstart, f77_keywords[i].operator, namelen)) == 0)
>       {
> 	/* 	lexptr += strlen(f77_keywords[i].operator); */ 
> 	yylval.opcode = f77_keywords[i].opcode;


  reply	other threads:[~2010-12-15 18:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-14 16:18 Greg Watson
2010-12-14 17:41 ` Tom Tromey
2010-12-15 18:52   ` Greg Watson [this message]
2010-12-15 19:28     ` Tom Tromey

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=9574F1C6-076E-44C8-A487-D97CA5088D54@computer.org \
    --to=g.watson@computer.org \
    --cc=gdb-patches@sourceware.org \
    /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