This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: Can `cpp' strip off comments in C source code?


Things are a little complicated. I've googled a sed script on:
http://sed.sourceforge.net/grabbag/scripts/remccoms2.sh.txt

But the script can't handle this testcase:
    printf("/*  Haha \n"); /* Haha */
	printf("//  Haha \n"); // Haha

I think a simple regular expression filter is not enough. A lexical parsing is required to ensure the results come out right in all cases.
A prefessional utility is more suitable than a script written by me since I am not an expert in ANSI C standard.

>AWK itself can do it, as can sed.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]