Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
delete comments in .c file
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Stephen Samuel, post: 1685246"] Here's a perl script which will handle *MOST* sane C code... Some things that it will miss (scan manually for it first: a double quote inside of single quotes (e.g.) char confusion = '"'; C-99 // comments like this I'm sure that some people can come up with other convoluted counter-examples. It reads and plays with the entire file, so it will need to hold at least two or three copies of it in RAM. (for today's computers, that would be some number of megabytes). If you want any of the above fixed, feel free to send me a cheque. ____________________________________________________ #!/usr/bin/perl $s=join("",<>); # printf "[[%s]]\n\n",$s; $s=~ s/("(\\\\|\\"|[^"])*")|(\/\*([^*]|\*(?=[^\/]))*\*\/)|(\/\/.*)/[[$1 ]]/g; printf "[[%s]]\n\n",$s; ____________________________________________________ Yep, That's it... 5 lines including the shell header. One bug: Quoted strings have a space inserted after them. Again: fixable, but not worth the trouble for free. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
delete comments in .c file
Top