Searching for Signal

the n01se blog

Commentify contest

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:

  1. 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.
  2. 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.

Sample I/O:

  1. simple:input /output ("add")
  2. wacky:input /output ("wacky")
  3. deranged:input /output ("int")

The final results are in now! In order of longest to shortest:

  1. http://n01se.net/paste/9Cc (owen, awk, 169 chars)
  2. http://n01se.net/paste/MX (chouser, perl, 91 chars)
    http://n01se.net/paste/Lf (bob, perl, 91 chars)
  3. http://n01se.net/paste/OI (agriffis, perl, 85 chars)
  4. http://n01se.net/paste/Kf (aaron+kanaka, sed+cpp, 52 chars)