Article View: comp.bugs.4bsd
Article #1253Re: lex dumps core on empty input
From: Dave Cohrs
Date: Sun, 20 Nov 1988 18:37
Date: Sun, 20 Nov 1988 18:37
77 lines
2947 bytes
2947 bytes
In article <7995@megaron.arizona.edu> wendt@arizona.edu (Alan Lee Wendt) writes:
>lex < /dev/null dumps core.
Here's simple fix for the 4.3bsd lex; your line numbers may
vary:
*** /tmp/,RCSt1a06426 Sun Nov 20 12:30:34 1988
--- lmain.c Sun Nov 20 12:18:51 1988
***************
*** 69,74 ****
--- 69,77 ----
sp += slength("INITIAL") + 1;
sname[1] = 0;
if(yyparse(0)) exit(1); /* error return code */
+ #ifdef UW
+ if(fout == NULL) exit(1); /* never opened output; so just quit */
+ #endif UW
/* may be disposed of: def, subs, dchar */
free1core();
/* may be gotten: tmpstat, foll, positions, gotof, nexts, nchar, state, atable, sfall, cpackflg */
*** /tmp/,RCSt1a06437 Sun Nov 20 12:31:17 1988
--- parser.y Sun Nov 20 12:30:23 1988
***************
*** 241,256 ****
--- 241,272 ----
sectbegin = TRUE;
i = treesize*(sizeof(*name)+sizeof(*left)+
sizeof(*right)+sizeof(*nullstr)+sizeof(*parent))+ALITTLEEXTRA;
+ #ifdef UW
+ /* bad typing; morons! */
+ xp = myalloc(i,1);
+ if(xp == 0)
+ error("Too little core for parse tree");
+ p = xp;
+ #else
c = myalloc(i,1);
if(c == 0)
error("Too little core for parse tree");
p = c;
+ #endif UW
cfree(p,i,1);
+ #ifdef UW
+ name = (int*) myalloc(treesize,sizeof(*name));
+ left = (int*) myalloc(treesize,sizeof(*left));
+ right = (int*) myalloc(treesize,sizeof(*right));
+ nullstr = myalloc(treesize,sizeof(*nullstr));
+ parent = (int*) myalloc(treesize,sizeof(*parent));
+ #else
name = myalloc(treesize,sizeof(*name));
left = myalloc(treesize,sizeof(*left));
right = myalloc(treesize,sizeof(*right));
nullstr = myalloc(treesize,sizeof(*nullstr));
parent = myalloc(treesize,sizeof(*parent));
+ #endif UW
if(name == 0 || left == 0 || right == 0 || parent == 0 || nullstr == 0)
error("Too little core for parse tree");
return(freturn(DELIM));
***************
*** 678,683 ****
--- 694,705 ----
}
}
/* section three */
+ #ifdef UW
+ /* EOF before we did any real processing! */
+ if (!lgatflg) {
+ return(freturn(0));
+ }
+ #endif UW
ptail();
# ifdef DEBUG
if(debug)
--
Dave Cohrs
+1 608 262-6617 UW-Madison Computer Sciences Department
dave@cs.wisc.edu ...!{harvard,rutgers,ucbvax}!uwvax!dave
Technical Details
Message-ID:
<6700@spool.cs.wisc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!nrl-cmf!ukma!rutgers!uwvax!dave@cs.wisc.eduReferences:
<7995@megaron.arizona.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!nrl-cmf!ukma!rutgers!uwvax!dave@cs.wisc.edu From: dave@cs.wisc.edu (Dave Cohrs) Newsgroups: comp.bugs.4bsd Subject: Re: lex dumps core on empty input Message-ID: <6700@spool.cs.wisc.edu> Date: 20 Nov 88 18:37:50 GMT References: <7995@megaron.arizona.edu> Sender: news@spool.cs.wisc.edu Reply-To: dave@cs.wisc.edu (Dave Cohrs) Organization: U of Wisconsin CS Dept Lines: 77