Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!ig!arizona!rupley From: rupley@arizona.edu (John Rupley) Newsgroups: comp.lang.c Subject: Re: Want a way to strip comments from a Summary: comments do not overflow yytext[] Message-ID: <9919@megaron.arizona.edu> Date: 28 Mar 89 10:04:16 GMT References: <7150@siemens.UUCP> <9900010@bradley> <4896@cbnews.ATT.COM> <795@twwells.uucp> Organization: U of Arizona CS Dept, Tucson Lines: 26 In article <795@twwells.uucp>, bill@twwells.uucp (T. William Wells) writes: > In article <9797@megaron.arizona.edu> rupley@arizona.edu (John Rupley) writes: > : A Lex source for uncommenting is attached (which I hope does not belie > : the remark above about hard to get the logic wrong :-). > > Try it on a very long comment. You might discover an overflowed lex > buffer. On the other hand, this shouldn't be too hard to fix. Just do > for the comment what you did for the noncommented text. Nope.... no problem.... comments are thrown away line-by-line, by design, so that very long comments indeed do not blow the buffer. A very long string, however, will overflow the buffer, but clearly this is understood, and it can be viewed as a feature, although idiosyncratic, as noted in <9888@megaron.arizona.edu>. If you want to handle strings differently, add another start condition (state) begun by '"' and make explicit start condition 0 = , or change the size of the match buffer (yytext[]) by including in the definitions: %{ #define YYLMAX 5000 /* or whatever */ %} John Rupley rupley!local@megaron.arizona.edu