📄 inclhack.sh
字号:
s/ u370 / __u370__ /g s/ u3b\([0-9]*\) / __u3b\1__ /g s/ unix / __unix__ /g s/ vax / __vax__ /g s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g }' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if' # # Fix 46: Math_Exception # case "${file}" in ./math.h ) if ( test -n "`egrep 'struct exception' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} math_exception" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/struct exception/i\#ifdef __cplusplus\#define exception __math_exception\#endif' \ -e '/struct exception/a\#ifdef __cplusplus\#undef exception\#endif' \ -e '/matherr/i\#ifdef __cplusplus\#define exception __math_exception\#endif' \ -e '/matherr/a\#ifdef __cplusplus\#undef exception\#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 47: Math_Gcc_Ifndefs # case "${file}" in ./math.h ) fixlist="${fixlist} math_gcc_ifndefs" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi ( dbl_max_def=`egrep 'define[ ]+DBL_MAX[ ]+.*' float.h 2>/dev/null` if ( test -n "${dbl_max_def}" \ -a -n "`egrep '#define[ ]*HUGE_VAL[ ]+DBL_MAX' $file`" \ -a -z "`egrep '#define[ ]+DBL_MAX[ ]+' $file`" ) > /dev/null 2>&1 then sed -e '/define[ ]HUGE_VAL[ ]DBL_MAX/s/DBL_MAX/$dbl_max_def/' else cat ; fi | sed -e '/define[ ]HUGE_VAL[ ]/i\#ifndef HUGE_VAL' -e '/define[ ]HUGE_VAL[ ]/a\#endif' ) < $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} ;; # case end for file name test esac # # Fix 48: Nested_Comment # case "${file}" in ./rpc/rpc.h ) fixlist="${fixlist} nested_comment" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's@^\(/\*.*rpc/auth_des.h>.*\)/\*@\1*/ /*@' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 49: News_Os_Recursion # case "${file}" in ./stdlib.h ) if ( test -n "`egrep '#include <stdlib.h>' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} news_os_recursion" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^#include <stdlib.h>/i\#ifdef BOGUS_RECURSION' \ -e '/^#include <stdlib.h>/a\#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 50: Next_Math_Prefix # case "${file}" in ./ansi/math.h ) if ( test -n "`egrep '^extern.*double.*__const__.*' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} next_math_prefix" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^extern.*double.*__const__.*sqrt(/s/__const__//' \ -e '/^extern.*double.*__const__.*fabs(/s/__const__//' \ -e '/^extern.*double.*__const__.*cos(/s/__const__//' \ -e '/^extern.*double.*__const__.*hypot(/s/__const__//' \ -e '/^extern.*double.*__const__.*sin(/s/__const__//' \ < $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 51: Next_Template # case "${file}" in ./bsd/libc.h ) if ( test -n "`egrep 'template' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} next_template" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/\(.*template\)/s/template//' \ -e '/extern.*volatile.*void.*abort/s/volatile//' \ < $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 52: Next_Volitile # case "${file}" in ./ansi/stdlib.h ) if ( test -n "`egrep 'volatile' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} next_volitile" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/extern.*volatile.*void.*exit/s/volatile//' \ -e '/extern.*volatile.*void.*abort/s/volatile//' \ < $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 53: Next_Wait_Union # case "${file}" in ./sys/wait.h ) if ( test -n "`egrep 'wait\\(union wait' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} next_wait_union" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's@wait(union wait@wait(void@' \ < $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 54: Nodeent_Syntax # case "${file}" in ./netdnet/dnetdb.h ) fixlist="${fixlist} nodeent_syntax" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/char.*na_addr *$/char *na_addr;/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 55: Osf_Namespace_A # case "${file}" in ./reg_types.h | \ ./sys/lc_core.h ) if ( test '(' -r reg_types.h ')' -a \ '(' -r sys/lc_core.h ')' -a \ '(' -n "`grep '} regex_t;' reg_types.h`" ')' -a \ '(' -z "`grep __regex_t regex.h`" ')' ) > /dev/null 2>&1 ; then fixlist="${fixlist} osf_namespace_a" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/regex_t/__regex_t/g' \ -e 's/regoff_t/__regoff_t/g' \ -e 's/regmatch_t/__regmatch_t/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 56: Osf_Namespace_B # case "${file}" in ./regex.h ) if ( test '(' -r reg_types.h ')' -a \ '(' -r sys/lc_core.h ')' -a \ '(' -n "`grep '} regex_t;' reg_types.h`" ')' -a \ '(' -z "`grep __regex_t regex.h`" ')' ) > /dev/null 2>&1 ; then fixlist="${fixlist} osf_namespace_b" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/#include <reg_types.h>/a\typedef __regex_t regex_t;\typedef __regoff_t regoff_t;\typedef __regmatch_t regmatch_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 57: Pthread_Page_Size # case "${file}" in ./pthread.h ) if ( test -n "`egrep '^int __page_size' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} pthread_page_size" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/^int __page_size/extern int __page_size/' \ < $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 58: Rs6000_Double # case "${file}" in ./math.h ) if ( test -n "`egrep '[^a-zA-Z_]class\\(' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} rs6000_double" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/class[(]/i\#ifndef __cplusplus' \ -e '/class[(]/a\#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 59: Rs6000_Fchmod # case "${file}" in ./sys/stat.h ) if ( test -n "`egrep 'fchmod\\(char' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} rs6000_fchmod" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/fchmod(char \*/fchmod(int/' \ < $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 60: Rs6000_Param # case "${file}" in ./stdio.h | \ ./unistd.h ) fixlist="${fixlist} rs6000_param" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's@rename(const char \*old, const char \*new)@rename(const char *_old, const char *_new)@' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 61: Sony_Include # case "${file}" in ./machine/machparam.h ) if ( test -n "`egrep '\"\\.\\./machine/endian.h\"' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} sony_include" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's@"../machine/endian.h"@<machine/endian.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 62: Statsswtch # case "${file}" in ./rpcsvc/rstat.h ) if ( test -n "`egrep 'boottime$' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} statsswtch" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/boottime$/boottime;/' \ < $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 63: Stdio_Va_List # case "${file}" in ./stdio.h ) fixlist="${fixlist} stdio_va_list" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi ( if ( egrep "__need___va_list" $file ) > /dev/null 2>&1 ; then : else echo "#define __need___va_list" echo "#include <stdarg.h>" fi sed -e 's@ va_list @ __gnuc_va_list @' \ -e 's@ va_list)@ __gnuc_va_list)@' \ -e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \ -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \ -e 's@ va_list@ __va_list__@' \ -e 's@\*va_list@*__va_list__@' \ -e 's@ __va_list)@ __gnuc_va_list)@' \ -e 's@GNUC_VA_LIST@GNUC_Va_LIST@' \ -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \ -e 's@VA_LIST@DUMMY_VA_LIST@' \ -e 's@_Va_LIST@_VA_LIST@' ) < $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} ;; # case end for file name test esac # # Fix 64: Sun_Bogus_Ifdef # case "${file}" in ./hsfs/hsfs_spec.h | \ ./hsfs/iso_spec.h ) if ( test -n "`egrep '#ifdef __i386__ || __vax__' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} sun_bogus_ifdef" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/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 65: Sun_Bogus_Ifdef_Sun4c # case "${file}" in ./hsfs/hsnode.h ) if ( test -n "`egrep '#ifdef __i386__ || __sun4c__' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} sun_bogus_ifdef_sun4c" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} fi # end of selection 'if'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -