Return to BSD News archive
Newsgroups: comp.bugs.2bsd Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!yarrina.connect.com.au!classic.iinet.com.au!news.uoknor.edu!news.ecn.uoknor.edu!paladin.american.edu!gatech!swrinde!sdd.hp.com!hplabs!nsc!voder!wlbr!sms From: sms@wlv.iipo.gtegsc.com (Steven M. Schultz) Subject: yacc generated files cause xstr problems (#241) Sender: news@wlbr.iipo.gtegsc.com (System Administrator) Organization: GTE Government Systems, Westlake Village Message-ID: <D8I32F.88M@wlbr.iipo.gtegsc.com> X-Nntp-Posting-Host: wlv.iipo.gtegsc.com Date: Sat, 13 May 1995 04:56:38 GMT Lines: 429 Subject: yacc generated files cause xstr problems (#241) Index: usr.bin/yacc 2.11BSD Description: Processing a .y file with yacc places the string: #ifndef lint static char yaccpar_sccsid[] = "@(#)yaccpar 4.1 (Berkeley) 2/11/83"; #endif not lint in the resulting y.tab.c file Using xstr(1) and cc on y.tab.c produces the error: foo.c:2: warning: illegal combination of pointer and integer, op = 2: Illegal initialization Repeat-By: Script started on Fri May 12 20:00:24 1995 # cat foo.c #ifndef lint static char yaccpar_sccsid[] = "@(#)yaccpar 4.1 (Berkeley) 2/11/83"; #endif not lint # cc -E foo.c | xstr -c - # cc -c x.c foo.c:2: warning: illegal combination of pointer and integer, op = 2: Illegal initialization # exit # script done on Fri May 12 20:00:51 1995 Fix: Apply the update below and reinstall yacc. Initially only the file 'yaccpar' (which gets installed in /usr/lib) was modified. I could not leave well enough alone however and ifdef'd out the sccsid strings from all of the modules. sccs id strings are not a good idea on a small machine especially in a program that is straining the address space limits. A final bit of tidying up was done by adding additional register declarations - the yacc text segment is approximately 450 bytes smaller now. save the patch below to a file, /tmp/241 patch -p0 < /tmp/241 cd /usr/src/usr.bin/yacc make make install make clean ===================cut here================== *** /usr/src/usr.bin/yacc/y1.c.old Mon Feb 16 16:21:07 1987 --- /usr/src/usr.bin/yacc/y1.c Thu May 11 22:36:17 1995 *************** *** 1,6 **** ! #ifndef lint ! static char sccsid[] = "@(#)y1.c 4.1 (Berkeley) 2/11/83"; ! #endif not lint # include "dextern" --- 1,6 ---- ! #if !defined(lint) && defined(DOSCCS) ! static char sccsid[] = "@(#)y1.c 4.1.1 (2.11BSD) 1995/05/11"; ! #endif # include "dextern" *************** *** 111,117 **** fclose( ftable ); } ! char *chcopy( p, q ) char *p, *q; { /* copies string q into p, returning next free char ptr */ while( *p = *q++ ) ++p; return( p ); --- 111,117 ---- fclose( ftable ); } ! char *chcopy( p, q ) register char *p, *q; { /* copies string q into p, returning next free char ptr */ while( *p = *q++ ) ++p; return( p ); *************** *** 119,127 **** # define ISIZE 400 char *writem(pp) int *pp; { /* creates output string for item pointed to by pp */ ! int i,*p; static char sarr[ISIZE]; ! char *q; for( p=pp; *p>0 ; ++p ) ; p = prdptr[-*p]; --- 119,127 ---- # define ISIZE 400 char *writem(pp) int *pp; { /* creates output string for item pointed to by pp */ ! register int i,*p; static char sarr[ISIZE]; ! register char *q; for( p=pp; *p>0 ; ++p ) ; p = prdptr[-*p]; *************** *** 145,151 **** } char *symnam(i){ /* return a pointer to the name of symbol i */ ! char *cp; cp = (i>=NTBASE) ? nontrst[i-NTBASE].name : tokset[i].name ; if( *cp == ' ' ) ++cp; --- 145,151 ---- } char *symnam(i){ /* return a pointer to the name of symbol i */ ! register char *cp; cp = (i>=NTBASE) ? nontrst[i-NTBASE].name : tokset[i].name ; if( *cp == ' ' ) ++cp; *************** *** 203,209 **** } aryfil( v, n, c ) int *v,n,c; { /* set elements 0 through n-1 to c */ ! int i; for( i=0; i<n; ++i ) v[i] = c; } --- 203,209 ---- } aryfil( v, n, c ) int *v,n,c; { /* set elements 0 through n-1 to c */ ! register int i; for( i=0; i<n; ++i ) v[i] = c; } *************** *** 222,227 **** --- 222,228 ---- prlook( p ) struct looksets *p;{ register j, *pp; + pp = p->lset; if( pp == 0 ) fprintf( foutput, "\tNULL"); else { *************** *** 236,242 **** cpres(){ /* compute an array with the beginnings of productions yielding given nonterminals The array pres points to these lists */ /* the array pyield has the lists: the total size is only NPROD+1 */ ! register **pmem; register c, j, i; static int * pyield[NPROD]; --- 237,243 ---- cpres(){ /* compute an array with the beginnings of productions yielding given nonterminals The array pres points to these lists */ /* the array pyield has the lists: the total size is only NPROD+1 */ ! int **pmem; register c, j, i; static int * pyield[NPROD]; *** /usr/src/usr.bin/yacc/y2.c.old Mon Feb 16 16:21:07 1987 --- /usr/src/usr.bin/yacc/y2.c Thu May 11 22:41:56 1995 *************** *** 1,6 **** ! #ifndef lint ! static char sccsid[] = "@(#)y2.c 4.1 (Berkeley) 2/11/83"; ! #endif not lint # include "dextern" # define IDENTIFIER 257 --- 1,6 ---- ! #if !defined(lint) && defined(DOSCCS) ! static char sccsid[] = "@(#)y2.c 4.1.1 (2.11BSD) 1995/05/11"; ! #endif # include "dextern" # define IDENTIFIER 257 *************** *** 67,73 **** setup(argc,argv) int argc; char *argv[]; ! { int i,j,lev,t, ty; int c; int *p; char actname[8]; --- 67,74 ---- setup(argc,argv) int argc; char *argv[]; ! { int i,lev, ty; ! register int t, j; int c; int *p; char actname[8]; *************** *** 628,633 **** --- 629,635 ---- fdtype( t ){ /* determine the type of a symbol */ register v; + if( t >= NTBASE ) v = nontrst[t-NTBASE].tvalue; else v = TYPE( toklev[t] ); if( v <= 0 ) error( "must specify type for %s", (t>=NTBASE)?nontrst[t-NTBASE].name: *************** *** 691,698 **** } cpycode(){ /* copies code between \{ and \} */ - int c; c = getc(finput); if( c == '\n' ) { c = getc(finput); --- 693,700 ---- } cpycode(){ /* copies code between \{ and \} */ + register int c; c = getc(finput); if( c == '\n' ) { c = getc(finput); *************** *** 714,720 **** } skipcom(){ /* skip over comments */ ! register c, i=0; /* i is the number of lines skipped */ /* skipcom is called after reading a / */ --- 716,722 ---- } skipcom(){ /* skip over comments */ ! register int c, i=0; /* i is the number of lines skipped */ /* skipcom is called after reading a / */ *************** *** 732,738 **** } cpyact(offset){ /* copy C action to the next ; or closing } */ ! int brac, c, match, j, s, tok; fprintf( faction, "\n# line %d \"%s\"\n", lineno, infile ); --- 734,741 ---- } cpyact(offset){ /* copy C action to the next ; or closing } */ ! register int c; ! int brac, match, j, s, tok; fprintf( faction, "\n# line %d \"%s\"\n", lineno, infile ); *** /usr/src/usr.bin/yacc/y3.c.old Mon Feb 16 16:21:07 1987 --- /usr/src/usr.bin/yacc/y3.c Thu May 11 22:50:20 1995 *************** *** 1,6 **** ! #ifndef lint ! static char sccsid[] = "@(#)y3.c 4.1 (Berkeley) 2/11/83"; ! #endif not lint # include "dextern" --- 1,6 ---- ! #if !defined(lint) && defined(DOSCCS) ! static char sccsid[] = "@(#)y3.c 4.1.1 (2.11BSD) 1995/05/11"; ! #endif # include "dextern" *************** *** 10,16 **** output(){ /* print the output for the states */ ! int i, k, c; register struct wset *u, *v; fprintf( ftable, "short yyexca[] ={\n" ); --- 10,17 ---- output(){ /* print the output for the states */ ! int i, k; ! register int c; register struct wset *u, *v; fprintf( ftable, "short yyexca[] ={\n" ); *************** *** 123,129 **** } go2out(){ /* output the gotos for the nontermninals */ ! int i, j, k, best, count, cbest, times; fprintf( ftemp, "$\n" ); /* mark begining of gotos */ --- 124,131 ---- } go2out(){ /* output the gotos for the nontermninals */ ! register int i, j, k; ! int best, count, cbest, times; fprintf( ftemp, "$\n" ); /* mark begining of gotos */ *************** *** 176,182 **** int g2debug = 0; go2gen(c){ /* output the gotos for nonterminal c */ ! int i, work, cc; struct item *p, *q; --- 178,185 ---- int g2debug = 0; go2gen(c){ /* output the gotos for nonterminal c */ ! register int i, cc; ! int work; struct item *p, *q; *************** *** 224,230 **** } } ! precftn(r,t,s){ /* decide a shift/reduce conflict by precedence. /* r is a rule number, t a token number */ /* the conflict is in state s */ /* temp1[t] is changed to reflect the action */ --- 227,234 ---- } } ! precftn(r,t,s) register int t; ! { /* decide a shift/reduce conflict by precedence. /* r is a rule number, t a token number */ /* the conflict is in state s */ /* temp1[t] is changed to reflect the action */ *************** *** 257,266 **** } } ! wract(i){ /* output state i */ /* temp1 has the actions, lastred the default */ int p, p0, p1; ! int ntimes, tred, count, j; int flag; /* find the best choice for lastred */ --- 261,271 ---- } } ! wract(i) register int i; { /* output state i */ /* temp1 has the actions, lastred the default */ int p, p0, p1; ! int ntimes, tred, count; ! register int j; int flag; /* find the best choice for lastred */ *** /usr/src/usr.bin/yacc/y4.c.old Mon Feb 16 16:21:07 1987 --- /usr/src/usr.bin/yacc/y4.c Thu May 11 22:51:45 1995 *************** *** 1,6 **** ! #ifndef lint ! static char sccsid[] = "@(#)y4.c 4.1 (Berkeley) 2/11/83"; ! #endif not lint # include "dextern" --- 1,6 ---- ! #if !defined(lint) && defined(DOSCCS) ! static char sccsid[] = "@(#)y4.c 4.1.1 (2.11BSD) 1995/05/11"; ! #endif # include "dextern" *** /usr/src/usr.bin/yacc/yaccpar.old Mon Feb 16 16:21:08 1987 --- /usr/src/usr.bin/yacc/yaccpar Thu May 11 22:23:08 1995 *************** *** 1,6 **** ! #ifndef lint static char yaccpar_sccsid[] = "@(#)yaccpar 4.1 (Berkeley) 2/11/83"; ! #endif not lint # # define YYFLAG -1000 --- 1,6 ---- ! #if !defined(lint) && defined(DOSCCS) static char yaccpar_sccsid[] = "@(#)yaccpar 4.1 (Berkeley) 2/11/83"; ! #endif # # define YYFLAG -1000 *** /VERSION.old Mon May 8 21:34:07 1995 --- /VERSION Fri May 12 19:49:50 1995 *************** *** 1,4 **** ! Current Patch Level: 240 2.11 BSD ============ --- 1,4 ---- ! Current Patch Level: 241 2.11 BSD ============