From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12178 invoked by alias); 15 Dec 2010 18:52:06 -0000 Received: (qmail 12121 invoked by uid 22791); 15 Dec 2010 18:52:05 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,TW_YY X-Spam-Check-By: sourceware.org Received: from omr3.networksolutionsemail.com (HELO omr3.networksolutionsemail.com) (205.178.146.53) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 15 Dec 2010 18:51:59 +0000 Received: from cm-omr4 (mail.networksolutionsemail.com [205.178.146.50]) by omr3.networksolutionsemail.com (8.13.6/8.13.6) with ESMTP id oBFIputg005689 for ; Wed, 15 Dec 2010 13:51:56 -0500 Authentication-Results: cm-omr4 smtp.user=greg@watson.id.au; auth=pass (LOGIN) X-Authenticated-UID: greg@watson.id.au Received: from [108.21.104.164] ([108.21.104.164:46621] helo=[10.0.1.3]) by cm-omr4 (envelope-from ) (ecelerity 2.2.2.41 r(31179/31189)) with ESMTPA id BC/87-14014-C4E090D4; Wed, 15 Dec 2010 13:51:56 -0500 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1082) Subject: Re: Improve handling of Fortran keywords From: Greg Watson In-Reply-To: Date: Wed, 15 Dec 2010 18:52:00 -0000 Content-Transfer-Encoding: quoted-printable Message-Id: <9574F1C6-076E-44C8-A487-D97CA5088D54@computer.org> References: <5503A4B2-EB18-40A9-9182-27E05D73D0EF@computer.org> To: gdb-patches@sourceware.org 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-12/txt/msg00315.txt.bz2 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 chang= e. 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. */ =20=20=20=20 for (i =3D 0; f77_keywords[i].operator !=3D NULL; i++) ! if (strncmp (tokstart, f77_keywords[i].operator, ! strlen(f77_keywords[i].operator)) =3D=3D 0) { /* lexptr +=3D strlen(f77_keywords[i].operator); */=20 yylval.opcode =3D f77_keywords[i].opcode; --- 1150,1157 ---- /* Catch specific keywords. */ =20=20=20=20 for (i =3D 0; f77_keywords[i].operator !=3D NULL; i++) ! if (strlen(f77_keywords[i].operator) =3D=3D namelen && ! strncmp (tokstart, f77_keywords[i].operator, namelen) =3D=3D = 0) { /* lexptr +=3D strlen(f77_keywords[i].operator); */=20 yylval.opcode =3D f77_keywords[i].opcode; On Dec 14, 2010, at 12:41 PM, Tom Tromey wrote: >>>>>> "Greg" =3D=3D Greg Watson writes: >=20 > 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). >=20 > Could you try this patch instead? >=20 > I think it should have the same effect, but it is simpler. >=20 > Tom >=20 > 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. */ >=20 > for (i =3D 0; f77_keywords[i].operator !=3D NULL; i++) > - if (strncmp (tokstart, f77_keywords[i].operator, > - strlen(f77_keywords[i].operator)) =3D=3D 0) > + if (strncmp (tokstart, f77_keywords[i].operator, namelen)) =3D=3D 0) > { > /* lexptr +=3D strlen(f77_keywords[i].operator); */=20 > yylval.opcode =3D f77_keywords[i].opcode;