Command used for the job:
egrep -rl ' $' --include *.c --include *.h --include *.s --include *.inc --include *.txt * | xargs sed -i 's/\s\+$//g'
Credits to Grant Murphy from Stack Overflow.
* adds some constants for standard script names and messagebox types
* replaces some callstd calls with msgbox calls where equivalent
* replaces msgbox and callstd calls using raw digits with versions that use the constants