Article View: net.bugs
Article #209correction to lex bug fix
From: stewart
Date: Thu, 24 May 1984 17:32
Date: Thu, 24 May 1984 17:32
69 lines
3022 bytes
3022 bytes
This is a correction to the lex bug fix reported 23 May 84.
Yesterday's "fix" caused lex to break in a different way.
Sorry.
Lex versions: version 7, Berkeley 2.8 and 4.1 (probably
won't be visible on 32-bit machines, however).
This bug is not in lex itself, but in the boilerplate
lex pulls out of its library to make lex.yy.c.
The original cast two pointers to type int before
comparing them. Needless to say, on our 16-bit int pdp11
this causes errors when the addresses creep past 0x8000.
Yesterday I didn't know why the casts were inserted.
Here is the reason:
yycrank is a constant. yyt takes on values of yycrank+<int>,
where <int> may be negative (if YYOPTIM is defined). yyt
may, in fact, be a negative address! The cast is supposed to
turn this "negative address" into a negative number.
This construction is still terribly unportable, I'm sure.
It depends on ints and pointers being the same length.
John Stewart
*** /usr/lib/lex/ncform Thu May 24 13:08:49 1984
--- /usr/lib/lex/ncform.4.1 Thu Aug 11 23:51:26 1983
***************
*** 54,68
}
# endif
yyr = yyt;
! /* Fix from John Stewart, Teledyne Geotech, 24 May 1984:
! * yyt may be so far below yycrank that it wraps around,
! * appearing as large positive address, in which case
! * (yyt - yycrank) will be positive.
! * The original expression, ((int)yyt > (int)yycrank),
! * breaks on 16-bit machines if the yycrank array
! * straddles the address 0x8000.
! */
! if (((int)yyt - (int)yycrank) > 0){
yyt = yyr + yych;
if (yyt <= yytop && yyt->verify+yysvec == yystate){
if(yyt->advance+yysvec == YYLERR) /* error transitions */
--- 54,60 -----
}
# endif
yyr = yyt;
! if ( (int)yyt > (int)yycrank){
yyt = yyr + yych;
if (yyt <= yytop && yyt->verify+yysvec == yystate){
if(yyt->advance+yysvec == YYLERR) /* error transitions */
***************
*** 72,78
}
}
# ifdef YYOPTIM
! else if(((int)yyt - (int)yycrank) < 0) { /* r < yycrank */
yyt = yyr = yycrank+(yycrank-yyt);
# ifdef LEXDEBUG
if(debug)fprintf(yyout,"compressed state\n");
--- 64,70 -----
}
}
# ifdef YYOPTIM
! else if((int)yyt < (int)yycrank) { /* r < yycrank */
yyt = yyr = yycrank+(yycrank-yyt);
# ifdef LEXDEBUG
if(debug)fprintf(yyout,"compressed state\n");
Technical Details
Message-ID:
<1391@seismo.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!hogpc!houti!ariel!vax135!floyd!cmcl2!seismo!stewartShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 beta 4/10/84; site seismo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!hogpc!houti!ariel!vax135!floyd!cmcl2!seismo!stewart From: stewart@seismo.UUCP Newsgroups: net.bugs,net.unix-wizards Subject: correction to lex bug fix Message-ID: <1391@seismo.UUCP> Date: Thu, 24-May-84 13:32:13 EDT Article-I.D.: seismo.1391 Posted: Thu May 24 13:32:13 1984 Date-Received: Wed, 30-May-84 09:10:36 EDT Distribution: net Organization: Center for Seismic Studies, Arlington, VA Lines: 69