A little while back (in April), we had a contest on #noise that started with David's post regarding a script to comment out words in a C file. The general applicability of this script is questionable, but it was still a fun contest. Here are the instructions:
- Write a command-line filter which will comment out all matches of a pattern given on the command-line, reading a C program from stdin and filtering to stdout. Whether the pattern is a literal, glob, regular expression is up to the contestant.
- The filter should ignore matches that are already contained within a comment (including C++ style comments) or double-quoted string.
The existing gawk implementation on David's blog is an interesting starting point, though it doesn't fulfill all the requirements above.
The final results are in now! In order of longest to shortest:
- http://n01se.net/paste/9Cc (owen, awk, 169 chars)
- http://n01se.net/paste/MX (chouser, perl, 91 chars)
http://n01se.net/paste/Lf (bob, perl, 91 chars)
- http://n01se.net/paste/OI (agriffis, perl, 85 chars)
- http://n01se.net/paste/Kf (aaron+kanaka, sed+cpp, 52 chars)