#!/bin/sh fixup_file() { local path=$1 grep -q '//' $path || return echo "found C++ style comments in $path" # remove blank comments sed -i 's@/\*\s*\*/@@' $path # C style with extra leading / sed -i 's@//\*\(.*\)\*/@/*\1*/@' $path # nested C style within C++ style sed -i 's@//\(.*\)/\*\(.*\)\*/@/*\1 \2*/@' $path # C style bracketing with many C++ delimeters sed -i 's@////*\([^/]*\)////*@/* \1 */@' $path # nested C++ style within C++ style sed -i 's@///*\(.*\)///*\(.*\)@//\1 \2@' $path # C++ comment at beginning of line sed -i 's@^//\(.*\)@/* \1 */@' $path # C++ comment elsewhere in line, avoid url's sed -i 's@\([^:]\)//\(.*\)@\1/* \2 */@' $path } # specific instance of schizophrenia in the AtomBios sources if [ -f AtomBios/includes/ObjectID.h ] ; then sed -i 's@// Graphics@/* Graphics@' AtomBios/includes/ObjectID.h fi for f in $(find . -name '*.h') $(find . -name '*.c') ; do fixup_file $f done