LEX rule, anyone???

T. William Wells bill at twwells.com
Thu Dec 7 01:49:05 AEST 1989


In article <21108 at mimsy.umd.edu> cml at tove.umd.edu (Christopher Lott) writes:
:    /* this is a regular expression to match a c comment       */
:    /* written by cml 890922   (probably not minimal)  */
: %%
: "/*"([^*]|[*]*[^*/])*[*]+"/"  {printf("saw a c comment.\n");}
: .                             {putchar(*yytext);}

This breaks if the comment is longer than lex's internal buffer.
Moreoever, at least some lex's do *not* check for buffer overflow.

Boom.

---
Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
bill at twwells.com



More information about the Comp.lang.c mailing list