Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Improve handling of Fortran keywords
@ 2010-12-14 16:18 Greg Watson
  2010-12-14 17:41 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Watson @ 2010-12-14 16:18 UTC (permalink / raw)
  To: gdb-patches

Hi,

Currently, gdb 7.2 will not allow me to use identifier names such as "integer_var" as it treats the first "integer" part as a keyword without checking that the identifier is actually longer than the keyword. Here's a simple patch to fix this (and make Fortran debugging more useful).

Regards,
Greg

*** f-exp.y.orig	2010-12-14 10:28:34.542834692 -0500
--- f-exp.y	2010-12-14 11:06:04.798853514 -0500
***************
*** 955,960 ****
--- 955,961 ----
  {
    int c;
    int namelen;
+   int keylen;
    unsigned int i,token;
    char *tokstart;
    
***************
*** 1149,1162 ****
    
    /* 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;
  	return f77_keywords[i].token;
        }
    
    yylval.sval.ptr = tokstart;
    yylval.sval.length = namelen;
--- 1150,1165 ----
    
    /* Catch specific keywords.  */
    
!   for (i = 0; f77_keywords[i].operator != NULL; i++) {
!     keylen = strlen(f77_keywords[i].operator);
!     if (strlen(tokstart) == keylen &&
!             strncmp (tokstart, f77_keywords[i].operator, keylen) == 0)
        {
  	/* 	lexptr += strlen(f77_keywords[i].operator); */ 
  	yylval.opcode = f77_keywords[i].opcode;
  	return f77_keywords[i].token;
        }
+   }
    
    yylval.sval.ptr = tokstart;
    yylval.sval.length = namelen;


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-15 19:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-14 16:18 Improve handling of Fortran keywords Greg Watson
2010-12-14 17:41 ` Tom Tromey
2010-12-15 18:52   ` Greg Watson
2010-12-15 19:28     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox