Wine Spelling Police

So, you'd like to correct some missspellings in comments in the Wine source tree, eh? You've come to the right place. Here's how to do it, in five easy steps.

Five Easy Steps to joining the Wine Spelling Police

First, read the cautionary notes in Spellchecking Comments in the Linux Kernel to find out what not to do when fixing typos in comments.

Second, grab my custom dictionary of words peculiar to Wine's source tree, so your spell checker can skip those words and not flag them as errors.

Third, using that custom dictionary, spell-check the wine source file you're working on. For instance:

$ ispell -p stop.txt -l < ~/wine-git/dlls/shell32/autocomplete.c
This will output a list of the misspelt words in that file.

Optionally, you can use my lspell.pl script to run ispell on just the comments in that source file. For instance:

$ perl lspell.pl stop.txt ~/wine-git/dlls/shell32/*.c
This will output a list of misspelled words for each source file you pass it.

Fourth, go carefully fix the typos in the comments, being sure to only fix the glaringly annoying ones, and make sure the source still compiles and passes tests after your changes.

Finally, post a patch with your typo fixes (and nothing else) to wine-patches. Only do a small number of files per week; nobody likes sweeping changes.

Preparing a new custom dictionary

I use the scripts lspell.pl and lspell2.pl to spellcheck the entire source tree in two steps.

First, I spellcheck the noncomment portion of the source, saving the list of apparant typos (really, variable names and the like) to the file stop1.txt, like this:

find wine-git -name '*.[ch]' | xargs perl lspell2.pl /dev/null | grep -v ':' | tr ' ' '\012' | sort -f | uniq > stop1.txt
Second, I spellcheck the comment part of wine's source, telling the spellchecker to ignore any of the variable names found in the previous step:
find wine-git -name '*.[ch]' | xargs perl lspell.pl stop1.txt | grep -v ':' | tr ' ' '\012' | sort -f | uniq > stop2.txt
Third, I manually edit 'stop2.txt' and remove lines that are glaringly obvious spelling errors from everybody's point of view. This is a bit tedious, and requires some finesse. (Don't remove lines that are jokes or britishisms, for instance.)

Finally, I generate the custom dictionary by combining stop1.txt and stop2.txt:

sort -u stop[12].txt > stop.txt
and manually removing obvious crap like blank lines etc. from stop.txt.

There! stop.txt is now a list of words that are probably not typos, and should be filtered out when spellchecking.

Now you're set to use a mass spellchecker on the wine source tree, e.g.

perl lspell.pl stop.txt `find wine-git -name '*.[ch]'`

Other spell checkers

Francois Gouget has another source code spell checking script that seems quite polished, see fgouget.free.fr/index-en.shtml#typos.