📄 inclhack.sh
字号:
) > /dev/null 2>&1 ; then fixlist="${fixlist} interactv_add2" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/fmod(double)/fmod(double, double)/' \ < $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 28: Interactv_Add3 # case "${file}" in ./sys/limits.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_add3" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/CHILD_MAX/s,/\* Max, Max,' \ -e '/OPEN_MAX/s,/\* Max, Max,' \ < $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 29: Io_Def_Quotes # if ( test -n "`egrep '[ ]*[ ](_|DES)IO[A-Z]*[ ]*\\( *[^,'\\'']' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} io_def_quotes" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/\([ ]*[ ]_IO[A-Z]*[ ]*(\)\([^,'\'']\),/\1'\''\2'\'',/' \ -e 's/\([ ]*[ ]DESIO[A-Z]*[ ]*(\)\([^,'\'']\),/\1'\''\2'\'',/' \ -e '/#[ ]*define[ ]*[ ]_IO/s/'\''\([cgxtf]\)'\''/\1/g' \ -e '/#[ ]*define[ ]*[ ]DESIOC/s/'\''\([cdgx]\)'\''/\1/g' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' # # Fix 30: Ioctl_Fix_Ctrl # if ( test -n "`egrep 'CTRL[ ]*\\(' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} ioctl_fix_ctrl" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/[^A-Z0-9_]CTRL[ ]*(/s/\([^'\'']\))/'\''\1'\'')/' \ -e '/[^A-Z0-9]_CTRL[ ]*(/s/\([^'\'']\))/'\''\1'\'')/' \ -e '/#[ ]*define[ ]*[ ]CTRL/s/'\''\([cgx]\)'\''/\1/g' \ -e '/#[ ]*define[ ]*[ ]_CTRL/s/'\''\([cgx]\)'\''/\1/g' \ -e '/#[ ]*define[ ]*[ ]BSD43_CTRL/s/'\''\([cgx]\)'\''/\1/g' \ -e '/#[ ]*define[ ]*[ ]_*ISCTRL/s/'\''\([cgx]\)'\''/\1/g' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' # # Fix 31: Ip_Missing_Semi # case "${file}" in ./netinet/ip.h ) fixlist="${fixlist} ip_missing_semi" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^struct/,/^};/s/}$/};/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 32: Irix_Multiline_Cmnt # case "${file}" in ./sys/types.h ) fixlist="${fixlist} irix_multiline_cmnt" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's@type of the result@type of the result */@' \ -e 's@of the sizeof@/* of the sizeof@' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 33: Irix_Sockaddr # case "${file}" in ./rpc/auth.h ) if ( test -n "`egrep 'authdes_create.*struct sockaddr' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} irix_sockaddr" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/authdes_create.*struct sockaddr/i\struct sockaddr;' \ < $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 34: Irix_Struct__File # case "${file}" in ./rpc/xdr.h ) fixlist="${fixlist} irix_struct__file" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/xdrstdio_create.*struct __file_s/i\struct __file_s;' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 35: Isc_Fmod # case "${file}" in ./math.h ) if ( test -n "`egrep 'fmod\\(double\\)' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} isc_fmod" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/fmod(double)/fmod(double, double)/' \ < $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 36: Motorola_Nested # case "${file}" in ./limits.h | \ ./sys/limits.h ) case "$target_canonical" in m68k-motorola-sysv* ) fixlist="${fixlist} motorola_nested" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's@^\(#undef[ ][ ]*PIPE_BUF[ ]*/\* max # bytes atomic in write to a\)$@\1 */@' \ -e 's@\(/\*#define HUGE_VAL 3.40282346638528860e+38 \)\(/\*error value returned by Math lib\*/\)$@\1*/ \2@' \ < $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 37: Isc_Sys_Limits # case "${file}" in ./sys/limits.h ) if ( test -n "`egrep 'CHILD_MAX' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} isc_sys_limits" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/CHILD_MAX/s,/\* Max, Max,' \ -e '/OPEN_MAX/s,/\* Max, Max,' \ < $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 38: Kandr_Concat # case "${file}" in ./sparc/asm_linkage.h | \ ./sun3/asm_linkage.h | \ ./sun3x/asm_linkage.h | \ ./sun4/asm_linkage.h | \ ./sun4c/asm_linkage.h | \ ./sun4m/asm_linkage.h | \ ./sun4c/debug/asm_linkage.h | \ ./sun4m/debug/asm_linkage.h | \ ./arm/as_support.h | \ ./arm/mc_type.h | \ ./arm/xcb.h | \ ./dev/chardefmac.h | \ ./dev/ps_irq.h | \ ./dev/screen.h | \ ./dev/scsi.h | \ ./sys/tty.h | \ ./Xm.acorn/XmP.h | \ ./bsd43/bsd43_.h ) if ( test -n "`egrep '/\\*\\*/' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} kandr_concat" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's|/\*\*/|##|g' \ < $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 39: Limits_Ifndefs # case "${file}" in ./limits.h | \ ./sys/limits.h ) if ( test -z "`egrep 'ifndef[ ]+FLT_MIN' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} limits_ifndefs" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/[ ]FLT_MIN[ ]/i\#ifndef FLT_MIN' \ -e '/[ ]FLT_MIN[ ]/a\#endif' \ -e '/[ ]FLT_MAX[ ]/i\#ifndef FLT_MAX' \ -e '/[ ]FLT_MAX[ ]/a\#endif' \ -e '/[ ]FLT_DIG[ ]/i\#ifndef FLT_DIG' \ -e '/[ ]FLT_DIG[ ]/a\#endif' \ -e '/[ ]DBL_MIN[ ]/i\#ifndef DBL_MIN' \ -e '/[ ]DBL_MIN[ ]/a\#endif' \ -e '/[ ]DBL_MAX[ ]/i\#ifndef DBL_MAX' \ -e '/[ ]DBL_MAX[ ]/a\#endif' \ -e '/[ ]DBL_DIG[ ]/i\#ifndef DBL_DIG' \ -e '/[ ]DBL_DIG[ ]/a\#endif' \ -e '/^\(\/\*#define HUGE_VAL 3\.[0-9e+]* *\)\/\*/s//\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 40: Lynx_Void_Int # case "${file}" in ./curses.h ) if ( test -n "`egrep '#[ ]*define[ ]+void[ ]+int' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} lynx_void_int" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/#[ ]*define[ ][ ]*void[ ]int/d' \ < $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 41: Lynxos_Fcntl_Proto # case "${file}" in ./fcntl.h ) if ( test -n "`egrep 'fcntl.*\\(int, int, int\\)' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} lynxos_fcntl_proto" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/\(fcntl.*(int, int, \)int)/\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 42: M88k_Bad_Hypot_Opt # case "${file}" in ./math.h ) case "$target_canonical" in m88k-motorola-sysv3* ) fixlist="${fixlist} m88k_bad_hypot_opt" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/extern double floor(), ceil(), fmod(), fabs();/extern double floor(), ceil(), fmod(), fabs _PARAMS((double));/' \ -e '/^extern double hypot();$/a\\/* Workaround a stupid Motorola optimization if one\ of x or y is 0.0 and the other is negative! *\/\#ifdef __STDC__\static __inline__ double fake_hypot (double x, double y)\#else\static __inline__ double fake_hypot (x, y)\ double x, y;\#endif\{\ return fabs (hypot (x, y));\}\#define hypot fake_hypot' \ < $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 43: M88k_Bad_S_If # case "${file}" in ./sys/stat.h ) case "$target_canonical" in m88k-*-sysv3* ) if ( test -n "`egrep '#define[ ]+S_IS[A-Z]*(m)[ ]' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} m88k_bad_s_if" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(S_IF[A-Z][A-Z][A-Z][A-Z]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \ -e 's/^\(#define[ ]*S_IS[A-Z]*(m)\)[ ]*(m[ ]*&[ ]*\(0[0-9]*\)[ ]*)/\1 (((m)\&S_IFMT)==\2)/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for machine type test esac ;; # case end for file name test esac # # Fix 44: M88k_Multi_Incl # case "${file}" in ./time.h ) case "$target_canonical" in m88k-tektronix-sysv3* ) if ( test -z "`egrep '#ifndef' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} m88k_multi_incl" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi ( echo Fixing $file, to protect against multiple inclusion. >&2 cpp_wrapper=`echo $file | sed -e 's,\.,_,g' -e 's,/,_,g'` echo "#ifndef __GCC_GOT_${cpp_wrapper}_" echo "#define __GCC_GOT_${cpp_wrapper}_" cat echo "#endif /* ! __GCC_GOT_${cpp_wrapper}_ */" ) < $infile > ${DESTDIR}/fixinc.tmp # Shell scripts have the potential of removing the output # We interpret that to mean the file is not to be altered # if test ! -f ${DESTDIR}/fixinc.tmp then continue ; fi rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' ;; # case end for machine type test esac ;; # case end for file name test esac # # Fix 45: Machine_Name # if ( test -n "`egrep '^#[ ]*(if|elif).*[^a-zA-Z0-9_](_*[MSRrhim]|[Mbimnpstuv])[a-zA-Z0-9_]' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} machine_name" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e ':loop/\\$/Ns/\\$/\\+++fixinc_eol+++//\\$/b loops/\\+++fixinc_eol+++/\\/g/#[ ]*[el]*if/ { s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g s/ M32 / __M32__ /g s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g s/ _*\([Rr][34]\)000 / __\1000__ /g s/ _*host_mips / __host_mips__ /g s/ _*i386 / __i386__ /g s/ _*mips / __mips__ /g s/ bsd4\([0-9]\) / __bsd4\1__ /g s/ is68k / __is68k__ /g s/ m68k / __m68k__ /g s/ m88k / __m88k__ /g s/ mc680\([0-9]\)0 / __mc680\10__ /g s/ news\([0-9]*\) / __news\1__ /g s/ ns32000 / __ns32000__ /g s/ pdp11 / __pdp11__ /g s/ pyr / __pyr__ /g s/ sel / __sel__ /g s/ sony_news / __sony_news__ /g s/ sparc / __sparc__ /g s/ sun\([a-z0-9]*\) / __sun\1__ /g s/ tahoe / __tahoe__ /g s/ tower\([_0-9]*\) / __tower\1__ /g
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -