📄 inclhack.sh
字号:
;; # case end for file name test esac # # Fix 66: Sun_Catmacro # case "${file}" in ./pixrect/memvar.h ) if ( test -n "`egrep '^#define[ ]+CAT\\(a,b\\)' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} sun_catmacro" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^#define[ ]CAT(a,b)/ i\#ifdef __STDC__ \#define CAT(a,b) a##b\#else' \ -e '/^#define[ ]CAT(a,b)/ 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 67: Sun_Malloc # case "${file}" in ./malloc.h ) fixlist="${fixlist} sun_malloc" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/typedef[ ]char \* malloc_t/typedef void \* malloc_t/g' \ -e 's/int[ ][ ]*free/void free/g' \ -e 's/char\([ ]*\*[ ]*malloc\)/void\1/g' \ -e 's/char\([ ]*\*[ ]*realloc\)/void\1/g' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 68: Sun_Memcpy # case "${file}" in ./memory.h ) if ( test -n "`egrep '/\\* @\\(#\\)(head/memory.h 50.1 |memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2 )\\*/' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} sun_memcpy" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '1i\/* This file was generated by fixincludes */\#ifndef __memory_h__\#define __memory_h__\\#ifdef __STDC__\extern void *memccpy();\extern void *memchr();\extern void *memcpy();\extern void *memset();\#else\extern char *memccpy();\extern char *memchr();\extern char *memcpy();\extern char *memset();\#endif /* __STDC__ */\\extern int memcmp();\\#endif /* __memory_h__ */' \ -e '1,$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 69: Sun_Rusers_Semi # case "${file}" in ./rpcsvc/rusers.h ) if ( test -n "`egrep '_cnt$' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} sun_rusers_semi" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' \ < $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 70: Sun_Signal # case "${file}" in ./sys/signal.h | \ ./signal.h ) if ( test -n "`egrep '^void \\(\\*signal\\(\\)\\)\\(\\);' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} sun_signal" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^void (\*signal())();$/i\#ifdef __cplusplus\void (*signal(...))(...);\#else' \ -e '/^void (\*signal())();$/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 71: Sun_Auth_Proto # case "${file}" in ./rpc/auth.h | \ ./rpc/clnt.h | \ ./rpc/svc.h | \ ./rpc/xdr.h ) if ( test -n "`egrep '\\(\\*[a-z][a-z_]*\\)\\(\\)' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} sun_auth_proto" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/^\(.*(\*[a-z][a-z_]*)(\)\();.*\)/\#ifdef __cplusplus\\1...\2\#else\\1\2\#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 72: Sunos_Matherr_Decl # case "${file}" in ./math.h ) fixlist="${fixlist} sunos_matherr_decl" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^struct exception/,$b' \ -e '/matherr/i\struct exception;' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 73: Sunos_Strlen # case "${file}" in ./strings.h ) fixlist="${fixlist} sunos_strlen" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/int[ ]*strlen();/__SIZE_TYPE__ strlen();/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 74: Systypes # case "${file}" in ./sys/types.h | \ ./stdlib.h | \ ./sys/stdtypes.h | \ ./stddef.h | \ ./memory.h | \ ./unistd.h ) if ( test -n "`egrep 'typedef[ ]+[a-z_][ a-z_]*[ ](size|ptrdiff|wchar)_t' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} systypes" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^[ ]*\*[ ]*typedef unsigned int size_t;/N' \ -e 's/^\([ ]*\*[ ]*typedef unsigned int size_t;\n[ ]*\*\/\)/\1\#ifndef __SIZE_TYPE__\#define __SIZE_TYPE__ long unsigned int\#endif\typedef __SIZE_TYPE__ size_t;\/' \ -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\#ifndef __SIZE_TYPE__\#define __SIZE_TYPE__ long unsigned int\#endif' \ -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \ -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\#ifndef __PTRDIFF_TYPE__\#define __PTRDIFF_TYPE__ long int\#endif' \ -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \ -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\#ifndef __WCHAR_TYPE__\#define __WCHAR_TYPE__ int\#endif\#ifndef __cplusplus' \ -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/a\#endif' \ -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ 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 75: Systypes_For_Aix # case "${file}" in ./sys/types.h ) if ( test -n "`egrep 'typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t' ${file}`" -a \ -z "`egrep '_GCC_SIZE_T' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} systypes_for_aix" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/i\#ifndef _GCC_SIZE_T\#define _GCC_SIZE_T' \ -e '/typedef[ ][ ]*[A-Za-z_][ A-Za-z_]*[ ]size_t/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 76: Sysv68_String # case "${file}" in ./string.h ) fixlist="${fixlist} sysv68_string" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/extern[ ]*int[ ]*strlen();/extern unsigned int strlen();/' \ -e 's/extern[ ]*int[ ]*ffs[ ]*(long);/extern int ffs(int);/' \ -e 's/strdup(char \*s1);/strdup(const char *s1);/' \ -e '/^extern char$/N' \ -e 's/^extern char\(\n \*memccpy(),\)$/extern void\1/' \ -e '/^ strncmp(),$/N' \ -e 's/^\( strncmp()\),\n\( strlen(),\)$/\1;\extern unsigned int\\2/' \ -e '/^extern int$/N' \ -e 's/^extern int\(\n strlen(),\)/extern size_t\1/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 77: Sysz_Stdlib_For_Sun # case "${file}" in ./stdlib.h ) fixlist="${fixlist} sysz_stdlib_for_sun" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/int abort/void abort/g' \ -e 's/int free/void free/g' \ -e 's/char[ ]*\*[ ]*calloc/void \* calloc/g' \ -e 's/char[ ]*\*[ ]*malloc/void \* malloc/g' \ -e 's/char[ ]*\*[ ]*realloc/void \* realloc/g' \ -e 's/char[ ]*\*[ ]*bsearch/void \* bsearch/g' \ -e 's/int[ ][ ]*exit/void exit/g' \ -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/i\#ifndef _GCC_SIZE_T\#define _GCC_SIZE_T' \ -e '/typedef[ a-zA-Z_]*[ ]size_t[ ]*;/a\#endif' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 78: Sysz_Stdtypes_For_Sun # case "${file}" in ./sys/stdtypes.h ) fixlist="${fixlist} sysz_stdtypes_for_sun" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/[ ]size_t.*;/i\#ifndef _GCC_SIZE_T\#define _GCC_SIZE_T' \ -e '/[ ]size_t.*;/a\#endif' \ -e '/[ ]ptrdiff_t.*;/i\#ifndef _GCC_PTRDIFF_T\#define _GCC_PTRDIFF_T' \ -e '/[ ]ptrdiff_t.*;/a\#endif' \ -e '/[ ]wchar_t.*;/i\#ifndef _GCC_WCHAR_T\#define _GCC_WCHAR_T' \ -e '/[ ]wchar_t.*;/a\#endif' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 79: Tinfo_Cplusplus # case "${file}" in ./tinfo.h ) fixlist="${fixlist} tinfo_cplusplus" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's/[ ]_cplusplus/ __cplusplus/' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 80: Ultrix_Ansi_Compat # case "${file}" in ./ansi_compat.h ) if ( test -n "`egrep 'ULTRIX' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} ultrix_ansi_compat" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '1i\/* This file intentionally left blank. */' \ -e '1,$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 81: Ultrix_Fix_Fixproto # case "${file}" in ./sys/utsname.h ) if ( test -n "`egrep 'ULTRIX' ${file}`" ) > /dev/null 2>&1 ; then fixlist="${fixlist} ultrix_fix_fixproto" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e '/^[ ]*extern[ ]*int[ ]*uname();$/i\struct utsname;' \ < $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 82: Ultrix_Atof_Param # case "${file}" in ./math.h ) fixlist="${fixlist} ultrix_atof_param" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's@atof(\([ ]*char[ ]*\*[^)]*\))@atof(const \1)@' \ -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \ -e 's@inline double abs(double [a-z][a-z]*) {.*}@@' \ -e 's@inline int sqr(int [a-z][a-z]*) {.*}@@' \ -e 's@inline double sqr(double [a-z][a-z]*) {.*}@@' \ < $infile > ${DESTDIR}/fixinc.tmp rm -f ${DESTFILE} mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE} ;; # case end for file name test esac # # Fix 83: Ultrix_Const # case "${file}" in ./stdio.h ) fixlist="${fixlist} ultrix_const" if [ ! -r ${DESTFILE} ] then infile=${file} else infile=${DESTFILE} ; fi sed -e 's@perror( char \*__s );@perror( const char *__s );@' \ -e 's@fputs( char \*__s,@fputs( const char *__s,@' \ -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \ -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \ -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \ -e 's@scanf( char \*__format,@scanf( const char *__format,@' \ -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \ -e 's@popen(char \*, char \*);@popen(const char *,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -