in reply to Re: removing C style comments from text files
in thread removing C style comments from text files

No, you don't want the preprocessor output. Consider the following classical program:
# include <stdlib.h> # include <stdio.h> int main (int argc, char * argv []) { printf ("Hello, world\n"); /* Print 'Hello, world' */ exit (0); }

Assume this is in the file hello.c.

$ gcc -E hello.c | wc -l 1566 $ gcc -E hello.c | grep -v '^$' | wc -l 853
Even with blank lines removed, the 7 line hello.c expands to 853 lines of pre processor output.

Abigail

Replies are listed 'Best First'.
Re: Re: removing C style comments from text files
by BUU (Prior) on Jan 07, 2004 at 04:11 UTC
    Well yes, but it expands because you #include files. From his description (text files) I assumed that they weren't actual C programs and wouldn't be using the rest of the pre-processor commands. So there wouldn't be any #includes to expand the file size so dramatically. Beyond that I also suggested that it might be easier to match anything the pre-processor would consider a #define/#include, since the rules for that are fairly strict as I recall.