📄 inclhack.sh
字号:
if ( test -n "`egrep '#[ ]*define[ ]*__wchar_t' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} arm_wchar" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/\(#[ ]*ifndef[ ]*\)__wchar_t/\1_GCC_WCHAR_T/' \ -e 's/\(#[ ]*define[ ]*\)__wchar_t/\1_GCC_WCHAR_T/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for file name test esac # # Fix 8: Aux_Asm # case "${file}" in ./sys/param.h ) if ( test -n "`egrep '#ifndef NOINLINE' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} aux_asm" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's|#ifndef NOINLINE|#if !defined(NOINLINE) \&\& !defined(__GNUC__)|' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for file name test esac # # Fix 9: Avoid_Bool # case "${file}" in ./curses.h | \ ./curses_colr/curses.h | \ ./term.h | \ ./tinfo.h ) fixlist="${fixlist} avoid_bool" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/i\#ifndef __cplusplus' \ -e '/^#[ ]*define[ ][ ]*bool[ ][ ]*char[ ]*$/a\#endif' \ -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/i\#ifndef __cplusplus' \ -e '/^typedef[ ][ ]*char[ ][ ]*bool[ ]*;/a\#endif' \ -e '/^[ ]*typedef[ ][ ]*unsigned char[ ][ ]*bool[ ]*;/i\#ifndef __cplusplus' \ -e '/^[ ]*typedef[ ][ ]*unsigned char[ ][ ]*bool[ ]*;/a\#endif' \ -e '/^typedef[ ][ ]*int[ ][ ]*bool[ ]*;/i\#ifndef __cplusplus' \ -e '/^typedef[ ][ ]*int[ ][ ]*bool[ ]*;/a\#endif' \ -e '/^[ ]*typedef[ ][ ]*unsigned int[ ][ ]*bool[ ]*;/i\#ifndef __cplusplus' \ -e '/^[ ]*typedef[ ][ ]*unsigned int[ ][ ]*bool[ ]*;/a\#endif' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 10: Bad_Struct_Term # case "${file}" in ./curses.h ) if ( test -n "`egrep '^[ ]*typedef[ ]+struct[ ]+term[ ]*;' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} bad_struct_term" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/^[ ]*typedef[ ][ ]*\(struct[ ][ ]*term[ ]*;[ ]*\)$/\1/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for file name test esac # # Fix 11: Badquote # case "${file}" in ./sundev/vuid_event.h ) fixlist="${fixlist} badquote" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/doesn'\''t/does not/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 12: Bad_Lval # case "${file}" in ./libgen.h | \ ./dirent.h | \ ./ftw.h | \ ./grp.h | \ ./ndbm.h | \ ./pthread.h | \ ./pwd.h | \ ./signal.h | \ ./standards.h | \ ./stdlib.h | \ ./string.h | \ ./stropts.h | \ ./time.h | \ ./unistd.h ) fixlist="${fixlist} bad_lval" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/^[ ]*#[ ]*define[ ]*\([^(]*\)\(([^)]*)\)[ ]*\(_.\)\1\2[ ]*$/#define \1 \3\1/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 13: Broken_Assert_Stdio # case "${file}" in ./assert.h ) if ( test -n "`egrep 'stderr' ${file}`" -a \ -z "`egrep 'include.*stdio.h' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} broken_assert_stdio" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '1i\#include <stdio.h>' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for file name test esac # # Fix 14: Broken_Assert_Stdlib # case "${file}" in ./assert.h ) if ( test -n "`egrep 'exit *\\(|abort *\\(' ${file}`" -a \ -z "`egrep 'include.*stdlib.h' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} broken_assert_stdlib" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '1i\#ifdef __cplusplus\#include <stdlib.h>\#endif' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for file name test esac # # Fix 15: Bsd43_Io_Macros # if ( test -n "`egrep 'BSD43__IO' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} bsd43_io_macros" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/[ ]BSD43__IO[A-Z]*[ ]*(/s/(\(.\),/('\''\1'\'',/' \ -e '/#[ ]*define[ ]*[ ]BSD43__IO/s/'\''\([cgx]\)'\''/\1/g' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' # # Fix 16: Dec_Intern_Asm # case "${file}" in ./c_asm.h ) fixlist="${fixlist} dec_intern_asm" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^[ ]*float[ ]*fasm/i\#ifdef __DECC' \ -e '/^[ ]*#[ ]*pragma[ ]*intrinsic([ ]*dasm/a\#endif' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 17: No_Double_Slash # if ( test -n "`egrep '(^|[^:])//[^\"*]' ${file}`" -a \ '(' -z "`echo ${file} | egrep '(CC|cxx|\+\+)/'`" ')' ) > /dev/null 2>&1 ; then fixlist="${fixlist} no_double_slash" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's,^//.*$,,' \ -e 's,[^:]//[^"].*$,,' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' # # Fix 18: Ecd_Cursor # case "${file}" in ./sunwindow/win_lock.h | \ ./sunwindow/win_cursor.h ) fixlist="${fixlist} ecd_cursor" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/ecd.cursor/ecd_cursor/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 19: Sco5_Stat_Wrappers # case "${file}" in ./sys/stat.h ) case "$target_canonical" in i*86-*-sco3.2v5* ) fixlist="${fixlist} sco5_stat_wrappers" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^static int[ ]*[a-z]*stat(/i\#ifdef __cplusplus\extern "C"\{\#endif\' \ -e '/^}$/a\#ifdef __cplusplus\}\#endif /* __cplusplus */\' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for machine type test esac ;; # case end for file name test esac # # Fix 20: End_Else_Label # if ( test -n "`egrep '^[ ]*#[ ]*(else|endif)[ ]+([!-.0-z\\{\\|\\}\\~]|/[^\\*])' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} end_else_label" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e ':loop/\\$/Ns/\\$/\\+++fixinc_eol+++//\\$/b loops/\\+++fixinc_eol+++/\\/gs%^\([ ]*#[ ]*else\)[ ][ ]*/[^*].*%\1%s%^\([ ]*#[ ]*else\)[ ][ ]*[^/ ].*%\1%s%^\([ ]*#[ ]*endif\)[ ][ ]*/[^*].*%\1%s%^\([ ]*#[ ]*endif\)[ ][ ]**[^/].*%\1%s%^\([ ]*#[ ]*endif\)[ ][ ]*[^/* ].*%\1%' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' # # Fix 21: Hp_Inline # case "${file}" in ./sys/spinlock.h ) if ( test -n "`egrep 'include.*\"\\.\\./machine/' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} hp_inline" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's,"../machine/inline.h",<machine/inline.h>,' \ -e 's,"../machine/psl.h",<machine/psl.h>,' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for file name test esac # # Fix 22: Hp_Sysfile # case "${file}" in ./sys/file.h ) if ( test -n "`egrep 'HPUX_SOURCE' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} hp_sysfile" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/(\.\.\.)/(struct file * ...)/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for file name test esac # # Fix 23: Cxx_Unready # case "${file}" in ./sys/mman.h | \ ./rpc/types.h ) if ( test -z "`egrep '\"C\"|__BEGIN_DECLS' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} cxx_unready" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '1i\#ifdef __cplusplus\extern "C" {\#endif\' \ -e '$a\#ifdef __cplusplus\}\#endif' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for file name test esac # # Fix 24: Hpux_Maxint # case "${file}" in ./sys/param.h ) fixlist="${fixlist} hpux_maxint" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^#[ ]*define[ ]*MAXINT[ ]/i\#ifndef MAXINT' \ -e '/^#[ ]*define[ ]*MAXINT[ ]/a\#endif' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 25: Hpux_Systime # case "${file}" in ./sys/time.h ) if ( test -n "`egrep '^extern struct sigevent;' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} hpux_systime" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/^extern struct sigevent;/struct sigevent;/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for file name test esac # # Fix 26: Interactv_Add1 # case "${file}" in ./stdio.h | \ ./math.h | \ ./ctype.h | \ ./sys/limits.h | \ ./sys/fcntl.h | \ ./sys/dirent.h ) if ( test '(' -d /etc/conf/kconfig.d ')' -a \ '(' -n "`grep _POSIX_VERSION /usr/include/sys/unistd.h`" ')' ) > /dev/null 2>&1 ; then fixlist="${fixlist} interactv_add1" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/!defined(__STDC__) && !defined(_POSIX_SOURCE)/!defined(_POSIX_SOURCE)/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for file name test esac # # Fix 27: Interactv_Add2 # case "${file}" in ./math.h ) if ( test '(' -d /etc/conf/kconfig.d ')' -a \ '(' -n "`grep _POSIX_VERSION /usr/include/sys/unistd.h`" ')'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -