Scrunch blank lines
John Rupley
rupley at arizona.edu
Sat Apr 1 07:13:38 AEST 1989
>From rupley!local Fri Mar 31 13:43:14 1989
In article <620 at gonzo.UUCP> daveb at gonzo.UUCP (Dave Brower) writes:
>So, I offer this week's challenge: Smallest program that will take
>"blank line" style cpp output on stdin and send to stdout a scrunched
>version with appropriate #line directives.
The following Lex source is somewhat shorter than a previous Lex version.
Specifications assumed: single blank lines, as well as runs of blank
lines +- <#> line directives, are to be replaced by <# lineno
"filename">; only truly blank lines (no space or tab) are to be
considered blank.
------------------------------------------------------------------------
char f[80];
%S P
%%
#.+\n {sscanf(yytext,"#%d%s",&yylineno,f);BEGIN P;}
<P>.+\n {printf("# %d %s\n",yylineno-1,f);ECHO;BEGIN 0;}
\n BEGIN P;
.+\n ECHO;
------------------------------------------------------------------------
John Rupley
rupley!local at megaron.arizona.edu
More information about the Comp.lang.c
mailing list