neovim/neovim — pull request #337 by lslah (2014-03-09 00:13:21+00:00)
Title: [RFC] Remove dead code.

By accident I've found that the last few declarations of `os_unix.h` don't even have a corresponding function definition and thus are not used in the code at all. I tried to find all of theses declarations with the following bash script:
```bash
#!/bin/sh

header_files=`find src/ -name "*.h"`
for file in $header_files
do
declarations=`perl -ne 'print "$1\n" if /^(?:\w+? )*(\w+?)\(/' $file`

for declaration in $declarations
do
usage_count=`git grep $declaration | wc -l`
if [ $usage_count -eq 1 ]
then
echo $file:$declaration
fi
done
done
```
In my first commit, I deleted all declarations found with this script. Then I recognized that a function name which occurs exactly twice is also dead, since we have a declaration and a definition, but no function call.
Thus I've rerun the script with `$usage_count -le 2`.
Deleting the so found unused functions revealed a couple of more otherwise unused functions, when rerunning the script.

The script is far from being perfect though. It doesn't distinguish between occurrences in comments and actual code (with `$usage_count -le 2` I also found some declarations which don't have a definition but are mentioned in some comment). Also it's very easy to write a function declaration which doesn't match the used regex.

It would be nice if someone with more command-line-skills could improve the script to fix these things.

Especially the third commit showed that there might be more dead code between gui related preprocessor `if`s. Maybe some other script can find these.