This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] fix a pascal parsing bug
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [RFA] fix a pascal parsing bug
- From: Pierre Muller <muller at cerbere dot u-strasbg dot fr>
- Date: Fri, 27 Oct 2000 12:57:28 +0200
- Cc: taylor at cygnus dot com
Pascal patch n°7:
The following patch fixes a bug in the pascal parsing.
The problem is due to the fact that some special operators have
ascii names in pascal. For instance && is and in pascal
(in fact it is both the logical and the arithmetical and).
Thus trying to print a var with name starting with and fais with current
CVS tree.
(gdb) p andstate
A parse error in expressiion, near `'.
The error message is not very explicit either.
The patch also allows to recognize 'AND' and 'and' as being
the same operator (pascal is case insensitive).
PS: if the patch is accepted, should I also commit the resulting
p-exp.tab.c file ?
ChangeLog entry:
2000-10-27 Pierre Muller <muller@ics.u-strasbg.fr>
* p-exp.y (yylex): avoid problem with symbol name starting as a
operator name.
Index: p-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/p-exp.y,v
retrieving revision 1.1
diff -b -c -r1.1 p-exp.y
*** p-exp.y 2000/06/14 12:27:59 1.1
--- p-exp.y 2000/10/27 11:02:11
***************
*** 942,957 ****
char *uptokstart;
char *tokptr;
char *p;
! int tempbufindex;
static char *tempbuf;
static int tempbufsize;
retry:
tokstart = lexptr;
/* See if it is a special token of length 3. */
for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
! if (STREQN (tokstart, tokentab3[i].operator, 3))
{
lexptr += 3;
yylval.opcode = tokentab3[i].opcode;
--- 942,962 ----
char *uptokstart;
char *tokptr;
char *p;
! int explen,tempbufindex;
static char *tempbuf;
static int tempbufsize;
retry:
tokstart = lexptr;
+ explen = strlen(lexptr);
/* See if it is a special token of length 3. */
+ if (explen > 2)
for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
! if ((strnicmp (tokstart, tokentab3[i].operator, 3) == 0) &&
! (!isalpha (tokentab3[i].operator[0]) || (explen == 3) ||
! (!isalpha (tokstart[3]) && !isdigit (tokstart[3]) &&
(tokstart[3] != '_'))
! ))
{
lexptr += 3;
yylval.opcode = tokentab3[i].opcode;
***************
*** 959,966 ****
}
/* See if it is a special token of length 2. */
for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
! if (STREQN (tokstart, tokentab2[i].operator, 2))
{
lexptr += 2;
yylval.opcode = tokentab2[i].opcode;
--- 964,975 ----
}
/* See if it is a special token of length 2. */
+ if (explen > 1)
for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
! if ((strnicmp (tokstart, tokentab2[i].operator, 2) == 0)
! && (!isalpha (tokentab2[i].operator[0]) || (explen == 2) ||
! (!isalpha (tokstart[2]) && !isdigit (tokstart[2]) &&
(tokstart[2] != '_'))
! ))
{
lexptr += 2;
yylval.opcode = tokentab2[i].opcode;
Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller@ics.u-strasbg.fr
Phone : (33)-3-88-41-40-07 Fax : (33)-3-88-41-40-99