ORIG_DIR=`pwd`
-# Make LIB absolute.
-cd $LIB; LIB=`pwd`
-
-# This prevents /bin/ex from failing if the current terminal type is
-# unrecognizable.
-TERM=dumb
-export TERM
-# This prevents /bin/ex from failing if the EXINIT environment variable
-# was set to something invalid.
-EXINIT=""
-export EXINIT
+# Make LIB absolute if it is relative.
+# Don't do this if not necessary, since may screw up automounters.
+case $LIB in
+/*)
+ ;;
+*)
+ cd $LIB; LIB=`${PWDCMD-pwd}`
+ ;;
+esac
echo 'Building fixincludes in ' ${LIB}
if expr $x : "${INPUT}/.*" > /dev/null; then
# Y gets the actual target dir name, relative to ${INPUT}.
y=`echo $x | sed -n "s&${INPUT}/&&p"`
- echo $file '->' $y ': Making link'
+ # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
+ dots=`echo "$file" |
+ sed -e 's@^./@@' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
+ echo $file '->' $dots$y ': Making link'
rm -fr ${LIB}/$file > /dev/null 2>&1
- ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
+ ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
else
# If the link is to outside ${INPUT},
# treat this directory as if it actually contained the files.
files=`find . -name '*.h' -type f -print`
echo 'Checking header files:'
for file in $files; do
- echo Fixing $file
if [ -r $file ]; then
cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
chmod +w $2/$file
+ chmod a+r $2/$file
# The following have been removed from the sed command below
# because it is more useful to leave these things in.
# which isn't much of a reason. -- rms.
# /^[ ]*#[ ]*ident/d
+# This code makes Solaris SCSI fail, because it changes the
+# alignment within some critical structures. See <sys/scsi/impl/commands.h>.
+# s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
+# Disable these also, since they probably aren't safe either.
+# s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
+# s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
+# s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
+# s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
+
# The change of u_char, etc, to u_int
# applies to bit fields.
sed -e '
- s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */%
- s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */%
+ s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
+ s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
+ s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
+ s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
s/#lint(on)/defined(lint)/g
s/#lint(off)/!defined(lint)/g
s/#machine(\([^)]*\))/defined(__\1__)/g
/#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
/#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
/#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
- s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
- s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
- s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
- s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
- s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
- s/__STDC__ == 0/!defined (__STRICT_ANSI__)/g
- s/__STDC__ != 0/defined (__STRICT_ANSI__)/g
+ s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
+ s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
+ s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
' $2/$file > $2/$file.sed
mv $2/$file.sed $2/$file
if cmp $file $2/$file >/dev/null 2>&1; then
- echo Deleting $2/$file\; no fixes were needed.
rm $2/$file
+ else
+ echo Fixed $file
fi
fi
done
echo Checking $file_to_fix
sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base
fi
sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
| sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base
fi
echo Checking $file_to_fix
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
- ex /tmp/$base <<EOF
- /^#define[ ]*NULL[ ]*0$/c
-#ifndef NULL
-#ifdef __cplusplus
-#define __NULL_TYPE
-#else /* !defined(__cplusplus) */
-#define __NULL_TYPE (void *)
-#endif /* !defined(__cplusplus) */
-#define NULL (__NULL_TYPE 0)
-#endif /* !defined(NULL) */
-.
- wq
-EOF
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ chmod a+r /tmp/$base
+ sed -e '/^#define[ ]*NULL[ ]*0$/c\
+#ifndef NULL\
+#ifdef __cplusplus\
+#define __NULL_TYPE\
+#else /* !defined(__cplusplus) */\
+#define __NULL_TYPE (void *)\
+#endif /* !defined(__cplusplus) */\
+#define NULL (__NULL_TYPE 0)\
+#endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
+ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
+ cp /tmp/$base.sed ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
- rm -f /tmp/$base
+ rm -f /tmp/$base /tmp/$base.sed
fi
# Likewise fix the definition of NULL in <stdio.h> so that it is conditional
echo Checking $file_to_fix
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
- ex /tmp/$base <<EOF
- /^#define[ ]*NULL[ ]*0$/c
-#ifdef __cplusplus
-#define __NULL_TYPE
-#else /* !defined(__cplusplus) */
-#define __NULL_TYPE (void *)
-#endif /* !defined(__cplusplus) */
-#define NULL (__NULL_TYPE 0)
-.
- wq
-EOF
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ sed -e '/^#define[ ]*NULL[ ]*0$/c\
+#ifdef __cplusplus\
+#define __NULL_TYPE\
+#else /* !defined(__cplusplus) */\
+#define __NULL_TYPE (void *)\
+#endif /* !defined(__cplusplus) */\
+#define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
+ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
+ cp /tmp/$base.sed ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
- rm -f /tmp/$base
+ rm -f /tmp/$base /tmp/$base.sed
fi
# Likewise fix the definition of NULL in <dbm.h> so that it is conditional
echo Checking $file_to_fix
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
- ex /tmp/$base <<EOF
- /^#define[ ]*NULL[ ]*((char \*) 0)$/c
-#ifndef NULL
-#ifdef __cplusplus
-#define __NULL_TYPE
-#else /* !defined(__cplusplus) */
-#define __NULL_TYPE (void *)
-#endif /* !defined(__cplusplus) */
-#define NULL (__NULL_TYPE 0)
-#endif /* !defined(NULL) */
-.
- wq
-EOF
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
+#ifndef NULL\
+#ifdef __cplusplus\
+#define __NULL_TYPE\
+#else /* !defined(__cplusplus) */\
+#define __NULL_TYPE (void *)\
+#endif /* !defined(__cplusplus) */\
+#define NULL (__NULL_TYPE 0)\
+#endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
+ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
+ cp /tmp/$base.sed ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
- rm -f /tmp/$base
+ rm -f /tmp/$base /tmp/$base.sed
fi
# Add a prototyped declaration of mmap to <sys/mman.h>.
echo Checking $file_to_fix
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
- ex /tmp/$base <<EOF
- /^extern caddr_t mmap();$/c
-#ifdef __STDC__
-extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,
- int fd, off_t off);
-#else /* !defined(__STDC__) */
-extern caddr_t mmap ();
-#endif /* !defined(__STDC__) */
-.
- wq
-EOF
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No changed needed in $file_to_fix
+ sed -e '/^extern caddr_t mmap();$/c\
+#ifdef __STDC__\
+extern caddr_t mmap (caddr_t addr, size_t len, int prot, int flags,\
+ int fd, off_t off);\
+#else /* !defined(__STDC__) */\
+extern caddr_t mmap ();\
+#endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
+ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
+ cp /tmp/$base.sed ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
- rm -f /tmp/$base
+ rm -f /tmp/$base /tmp/$base.sed
fi
# Fix declarations of `ftw' and `nftw' in <ftw.h>.
echo Checking $file_to_fix
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
- ex /tmp/$base <<EOF
- /^extern int ftw(const/c
-#if !defined(_STYPES)
-static
-#else
-extern
-#endif
- int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
-.
- /^extern int nftw/c
-#if defined(_STYPES)
-static
-#else
-extern
-#endif
- int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);
-.
- /^extern int ftw(),/c
-#if !defined(_STYPES)
-static
-#else
-extern
-#endif
- int ftw();
-#if defined(_STYPES)
-static
-#else
-extern
-#endif
- int nftw();
-.
- wq
-EOF
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ sed -e '/^extern int ftw(const/c\
+#if !defined(_STYPES)\
+static\
+#else\
+extern\
+#endif\
+ int ftw(const char *, int (*)(const char *, const struct stat *, int), int);' \
+ -e '/^extern int nftw/c\
+#if defined(_STYPES)\
+static\
+#else\
+extern\
+#endif\
+ int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *),int, int);' \
+ -e '/^extern int ftw(),/c\
+#if !defined(_STYPES)\
+static\
+#else\
+extern\
+#endif\
+ int ftw();\
+#if defined(_STYPES)\
+static\
+#else\
+extern\
+#endif\
+ int nftw();' /tmp/$base > /tmp/$base.sed
+ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
+ cp /tmp/$base.sed ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
- rm -f /tmp/$base
+ rm -f /tmp/$base /tmp/$base.sed
fi
# Add a `static' declaration of `getrnge' into <regexp.h>.
+# Don't do this if there is already a `static void getrnge' declaration
+# present, since this would cause a redeclaration error. Solaris 2.x has
+# such a declaration.
+
file=regexp.h
base=`basename $file`
if [ -r ${LIB}/$file ]; then
fi
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- ex /tmp/$base <<EOF
- /^static int[ ]*size;/c
-static int size ;
-
-static int getrnge ();
-.
- wq
-EOF
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ if grep "static void getrnge" $file_to_fix > /dev/null; then
+ true
else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
+ cp $file_to_fix /tmp/$base
+ chmod +w /tmp/$base
+ sed -e '/^static int[ ]*size;/c\
+static int size ;\
+\
+static int getrnge ();' /tmp/$base > /tmp/$base.sed
+ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
+ true
+ else
+ echo Fixed $file_to_fix
+ rm -f ${LIB}/$file
+ cp /tmp/$base.sed ${LIB}/$file
+ chmod a+r ${LIB}/$file
+ fi
fi
- rm -f /tmp/$base
+ rm -f /tmp/$base /tmp/$base.sed
fi
# Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
# that is visible to any ANSI compiler using this include. Simply
-# delete the lines the #define some string functions to internal forms.
+# delete the lines that #define some string functions to internal forms.
file=string.h
base=`basename $file`
echo Checking $file_to_fix
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
- ex /tmp/$base <<EOF
- g/#define.*__std_hdr_/d
- wq
-EOF
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
+ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
+ cp /tmp/$base.sed ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
- rm -f /tmp/$base
+ rm -f /tmp/$base /tmp/$base.sed
fi
+# Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
+# tend to conflict with the compiler's own definition of this symbol. (We
+# will use the compiler's definition.)
+# Likewise __sparc, for Solaris, and __i860, and a few others
+# (guessing it is necessary for all of them).
+
+file=ieeefp.h
+base=`basename $file`
+if [ -r ${LIB}/$file ]; then
+ file_to_fix=${LIB}/$file
+else
+ if [ -r ${INPUT}/$file ]; then
+ file_to_fix=${INPUT}/$file
+ else
+ file_to_fix=""
+ fi
+fi
+if [ \! -z "$file_to_fix" ]; then
+ echo Checking $file_to_fix
+ cp $file_to_fix /tmp/$base
+ chmod +w /tmp/$base
+ sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
+ -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
+ -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
+ /tmp/$base > /tmp/$base.sed
+ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
+ true
+ else
+ echo Fixed $file_to_fix
+ rm -f ${LIB}/$file
+ cp /tmp/$base.sed ${LIB}/$file
+ chmod a+r ${LIB}/$file
+ fi
+ rm -f /tmp/$base /tmp/$base.sed
+fi
+
# Add a #define of _SIGACTION_ into <sys/signal.h>.
# Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
echo Checking $file_to_fix
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
- ex /tmp/$base <<EOF
- /^struct sigaction {/c
-#define _SIGACTION_
-struct sigaction {
-.
- 1,\$s/(void *(\*)())/(void (*)(int))/
- wq
-EOF
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ sed -e '/^struct sigaction {/c\
+#define _SIGACTION_\
+struct sigaction {' \
+ -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
+ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
+ cp /tmp/$base.sed ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
- rm -f /tmp/$base
+ rm -f /tmp/$base /tmp/$base.sed
fi
# Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
echo Checking $file_to_fix
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
- ex /tmp/$base <<EOF
- /^dev_t makedev(const/c
-static dev_t makedev(const major_t, const minor_t);
-.
- /^dev_t makedev()/c
-static dev_t makedev();
-.
- /^major_t major(const/c
-static major_t major(const dev_t);
-.
- /^major_t major()/c
-static major_t major();
-.
- /^minor_t minor(const/c
-static minor_t minor(const dev_t);
-.
- /^minor_t minor()/c
-static minor_t minor();
-.
- wq
-EOF
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ sed -e '/^dev_t makedev(const/c\
+static dev_t makedev(const major_t, const minor_t);' \
+ -e '/^dev_t makedev()/c\
+static dev_t makedev();' \
+ -e '/^major_t major(const/c\
+static major_t major(const dev_t);' \
+ -e '/^major_t major()/c\
+static major_t major();' \
+ -e '/^minor_t minor(const/c\
+static minor_t minor(const dev_t);' \
+ -e '/^minor_t minor()/c\
+static minor_t minor();' /tmp/$base > /tmp/$base.sed
+ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
+ cp /tmp/$base.sed ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
- rm -f /tmp/$base
+ rm -f /tmp/$base /tmp/$base.sed
fi
# Fix reference to NMSZ in <sys/adv.h>.
echo Checking $file_to_fix
sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base
fi
sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
| sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base
fi
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
if grep _KERNEL $file_to_fix > /dev/null; then
- echo No change needed in $file_to_fix
+ true
else
echo '#ifdef _KERNEL' > /tmp/$base
cat $file_to_fix >> /tmp/$base
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
if grep _KERNEL $file_to_fix > /dev/null; then
- echo No change needed in $file_to_fix
+ true
else
echo '#ifdef _KERNEL' > /tmp/$base
cat $file_to_fix >> /tmp/$base
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
if grep _KERNEL $file_to_fix > /dev/null; then
- echo No change needed in $file_to_fix
+ true
else
echo '#ifdef _KERNEL' > /tmp/$base
cat $file_to_fix >> /tmp/$base
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
if grep _KERNEL $file_to_fix > /dev/null; then
- echo No change needed in $file_to_fix
+ true
else
echo '#ifdef _KERNEL' > /tmp/$base
cat $file_to_fix >> /tmp/$base
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
if grep _KERNEL $file_to_fix > /dev/null; then
- echo No change needed in $file_to_fix
+ true
else
echo '#ifdef _KERNEL' > /tmp/$base
cat $file_to_fix >> /tmp/$base
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
if grep _KERNEL $file_to_fix > /dev/null; then
- echo No change needed in $file_to_fix
+ true
else
echo '#ifdef _KERNEL' > /tmp/$base
cat $file_to_fix >> /tmp/$base
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
if grep _KERNEL $file_to_fix > /dev/null; then
- echo No change needed in $file_to_fix
+ true
else
echo '#ifdef _KERNEL' > /tmp/$base
cat $file_to_fix >> /tmp/$base
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
if grep _KERNEL $file_to_fix > /dev/null; then
- echo No change needed in $file_to_fix
+ true
else
echo '#ifdef _KERNEL' > /tmp/$base
cat $file_to_fix >> /tmp/$base
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
rm -f /tmp/$base
fi
fi
+# Conditionalize some of <netinet/in.h> on _KERNEL being defined.
+
+file=netinet/in.h
+base=`basename $file`
+if [ -r ${LIB}/$file ]; then
+ file_to_fix=${LIB}/$file
+else
+ if [ -r ${INPUT}/$file ]; then
+ file_to_fix=${INPUT}/$file
+ else
+ file_to_fix=""
+ fi
+fi
+if [ \! -z "$file_to_fix" ]; then
+ echo Checking $file_to_fix
+ if grep _KERNEL $file_to_fix > /dev/null; then
+ true
+ else
+ sed -e '/#ifdef INKERNEL/i\
+#ifdef _KERNEL' \
+ -e '/#endif[ ]*\/\* INKERNEL \*\//a\
+#endif /* _KERNEL */' \
+ $file_to_fix > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+ echo Fixed $file_to_fix
+ fi
+fi
+
+# Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
+
+file=sys/endian.h
+base=`basename $file`
+if [ -r ${LIB}/$file ]; then
+ file_to_fix=${LIB}/$file
+else
+ if [ -r ${INPUT}/$file ]; then
+ file_to_fix=${INPUT}/$file
+ else
+ file_to_fix=""
+ fi
+fi
+if [ \! -z "$file_to_fix" ]; then
+ echo Checking $file_to_fix
+ if grep __GNUC__ $file_to_fix > /dev/null; then
+ true
+ else
+ sed -e '/# ifdef __STDC__/i\
+# if !defined (__GNUC__) && !defined (__GNUG__)' \
+ -e '/# include <sys\/byteorder.h>/s/ / /'\
+ -e '/# include <sys\/byteorder.h>/i\
+# endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
+ $file_to_fix > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+ echo Fixed $file_to_fix
+ fi
+fi
+
+# Commented out because tmcconne@sedona.intel.com says we don't clearly need it
+# and the text in types.h is not erroneous.
+## In sys/types.h, don't name the enum for booleans.
+#
+#file=sys/types.h
+#base=`basename $file`
+#if [ -r ${LIB}/$file ]; then
+# file_to_fix=${LIB}/$file
+#else
+# if [ -r ${INPUT}/$file ]; then
+# file_to_fix=${INPUT}/$file
+# else
+# file_to_fix=""
+# fi
+#fi
+#if [ \! -z "$file_to_fix" ]; then
+# echo Checking $file_to_fix
+# if grep "enum boolean" $file_to_fix > /dev/null; then
+# sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
+# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
+# echo Fixed $file_to_fix
+# else
+# true
+# fi
+#fi
+
# Remove useless extern keyword from struct forward declarations in
# <sys/stream.h> and <sys/strsubr.h>
fi
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
- sed -e 's/extern struct \(stdata\|strevent\);/struct \1;/' $file_to_fix > /tmp/$base
+ sed -e '
+ s/extern struct stdata;/struct stdata;/g
+ s/extern struct strevent;/struct strevent;/g
+ ' $file_to_fix > /tmp/$base
if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base
fi
fi
if [ \! -z "$file_to_fix" ]; then
echo Checking $file_to_fix
- sed -e 's/extern struct \(strbuf\|uio\|thread\|proc\);/struct \1;/' $file_to_fix > /tmp/$base
+ sed -e '
+ s/extern struct strbuf;/struct strbuf;/g
+ s/extern struct uio;/struct uio;/g
+ s/extern struct thread;/struct thread;/g
+ s/extern struct proc;/struct proc;/g
+ ' $file_to_fix > /tmp/$base
+ if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
+ true
+ else
+ echo Fixed $file_to_fix
+ rm -f ${LIB}/$file
+ cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
+ fi
+ rm -f /tmp/$base
+fi
+
+# Put storage class at start of decl, to avoid warning.
+file=rpc/types.h
+base=`basename $file`
+if [ -r ${LIB}/$file ]; then
+ file_to_fix=${LIB}/$file
+else
+ if [ -r ${INPUT}/$file ]; then
+ file_to_fix=${INPUT}/$file
+ else
+ file_to_fix=""
+ fi
+fi
+if [ \! -z "$file_to_fix" ]; then
+ echo Checking $file_to_fix
+ sed -e '
+ s/const extern/extern const/g
+ ' $file_to_fix > /tmp/$base
if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- echo No change needed in $file_to_fix
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base
fi
echo Checking $file_to_fix
cp $file_to_fix /tmp/$base
chmod +w /tmp/$base
- ex /tmp/$base <<EOF
-/^stat(path, buf)/j
-j
--
-/^stat(path, buf)/c
-stat (const char *path, struct stat *buf)
-.
-/^lstat(path, buf)/j
-j
--
-/^lstat(path, buf)/c
-lstat (const char *path, struct stat *buf)
-.
-/^fstat(fd, buf)/j
-j
--
-/^fstat(fd, buf)/c
-fstat (int fd, struct stat *buf)
-.
-/^mknod(path, mode, dev)/j
-j
-j
--
-/^mknod(path, mode, dev)/c
-mknod (const char *path, mode_t mode, dev_t dev)
-.
-1,\$s/path/__path/g
-1,\$s/buf/__buf/g
-1,\$s/fd/__fd/g
-1,\$s/ret\\([^u]\\)/__ret\1/g
-1,\$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g
-1,\$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g
-wq
-EOF
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- rm -f /tmp/$base
+ sed -e '/^stat(/{
+N
+N
+s/(.*)\n/( /
+s/;\n/, /
+s/;$/)/
+}' \
+ -e '/^lstat(/{
+N
+N
+s/(.*)\n/( /
+s/;\n/, /
+s/;$/)/
+}' \
+ -e '/^fstat(/{
+N
+N
+s/(.*)\n/( /
+s/;\n/, /
+s/;$/)/
+}' \
+ -e '/^mknod(/{
+N
+N
+N
+s/(.*)\n/( /
+s/;\n/, /g
+s/;$/)/
+}' \
+ -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
+ -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
+ -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
+ -e '1,$s/ret\([^u]\)/__ret\1/g' \
+ -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
+ -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
+ if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
+ true
+ else
+ echo Fixed $file_to_fix
+ rm -f ${LIB}/$file
+ cp /tmp/$base.sed ${LIB}/$file
+ chmod a+r ${LIB}/$file
+ fi
+ rm -f /tmp/$base /tmp/$base.sed
fi
# Sony NEWSOS 5.0 does not support the complete ANSI C standard.
' /tmp/$base > /tmp/$base.sed
mv /tmp/$base.sed /tmp/$base
if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
- echo No change needed in $file_to_fix
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base
fi
' /tmp/$base > /tmp/$base.sed
mv /tmp/$base.sed /tmp/$base
if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
- echo No change needed in $file_to_fix
+ true
else
echo Fixed $file_to_fix
rm -f ${LIB}/$file
cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
fi
rm -f /tmp/$base
fi
fi
fi
+# In limits.h, put #ifndefs around things that are supposed to be defined
+# in float.h to avoid redefinition errors if float.h is included first.
+# Solaris 2.1 has this problem.
+
+file=limits.h
+base=`basename $file`
+if [ -r ${LIB}/$file ]; then
+ file_to_fix=${LIB}/$file
+else
+ if [ -r ${INPUT}/$file ]; then
+ file_to_fix=${INPUT}/$file
+ else
+ file_to_fix=""
+ fi
+fi
+if [ \! -z "$file_to_fix" ]; then
+ echo Checking $file_to_fix
+ 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' $file_to_fix > /tmp/$base
+ if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
+ true
+ else
+ echo Fixed $file_to_fix
+ rm -f ${LIB}/$file
+ cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
+ fi
+ rm -f /tmp/$base
+fi
+
+# Completely replace <sys/varargs.h> with a file that includes gcc's
+# stdarg.h or varargs.h files as appropriate.
+
+file=sys/varargs.h
+if [ -r ${INPUT}/$file ]; then
+ echo Replacing $file
+ cat > ${LIB}/$file << EOF
+/* This file was generated by fixincludes. */
+#ifndef _SYS_VARARGS_H
+#define _SYS_VARARGS_H
+
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#endif /* _SYS_VARARGS_H */
+EOF
+ chmod a+r ${LIB}/$file
+fi
+
echo 'Removing unneeded directories:'
cd $LIB
files=`find . -type d -print | sort -r`