# (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
INPUT=${2-${INPUT-/usr/include}}
-# This prevents /bin/ex from failing if the current terminal type is
-# unrecognizable.
-TERM=unknown
-export TERM
-# This prevents two problems:
-# Either ex might find a .exrc file and get confused,
-# or ex might complain if the EXINIT variable is invalid.
-# We know there is no .exrc in the GCC source.
-# `set' is a no-op ex command.
-EXINIT=set
-export EXINIT
+# Directory in which to store the results.
+LIB=${1?"fixincludes: output directory not specified"}
# Define PWDCMD as a command to use to get the working dir
# in the form that we want.
;;
esac
-# Directory in which to store the results.
-LIB=${1?"fixincludes: output directory not specified"}
-
# Make sure it exists.
if [ ! -d $LIB ]; then
mkdir $LIB || exit 1
' $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
fi
fi
if [ -r ${LIB}/$file ]; then
echo Fixing $file comment
- ex ${LIB}/$file <<EOF
- g/doesn't/s/doesn't/does not/
- wq
-EOF
+ sed -e "s/doesn't/does not/" ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm ${LIB}/$file
fi
fi
if [ -r ${LIB}/$file ]; then
echo Fixing $file
- ex ${LIB}/$file <<EOF
- /size_t.*;/
- i
-#ifndef _GCC_SIZE_T
-#define _GCC_SIZE_T
-.
- /size_t/+1
- i
-#endif
-.
- /ptrdiff_t.*;/
- i
-#ifndef _GCC_PTRDIFF_T
-#define _GCC_PTRDIFF_T
-.
- /ptrdiff_t/+1
- i
-#endif
-.
- /wchar_t.*;/
- i
-#ifndef _GCC_WCHAR_T
-#define _GCC_WCHAR_T
-.
- /wchar_t/+1
- i
-#endif
-.
- wq
-EOF
+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' ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm ${LIB}/$file
fi
fi
if [ -r ${LIB}/$file ]; then
echo Fixing $file
- ex ${LIB}/$file <<EOF
- /typedef.*[ ]size_t.*;/
- i
-#ifndef _GCC_SIZE_T
-#define _GCC_SIZE_T
-.
- /size_t/+1
- i
-#endif
-.
- wq
-EOF
+sed -e '/size_t.*;/i\
+#ifndef _GCC_SIZE_T\
+#define _GCC_SIZE_T' \
+ -e '/size_t.*;/a\
+#endif' ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm ${LIB}/$file
fi
fi
if [ -r ${LIB}/$file ]; then
echo Fixing $file, definition of statsswtch
- ex ${LIB}/$file <<EOF
- g/boottime$/s//&;/
- wq
-EOF
+ sed -e 's/boottime$/boottime;/' ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm ${LIB}/$file
fi
fi
if [ -r ${LIB}/$file ]; then
echo Fixing $file, definition of nodeent
- ex ${LIB}/$file <<EOF
- g/char.*na_addr *$/s//&;/
- wq
-EOF
+ sed -e 's/char.*na_addr *$/char *na_addr;/' ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm ${LIB}/$file
fi
fi
if [ -r ${LIB}/$file ]; then
echo Fixing $file, bad \#ifdef line
- ex ${LIB}/$file <<EOF
- g/^#ifdef KERNEL && !defined/
- s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
- wq
-EOF
+ sed -e 's/#ifdef KERNEL/#if defined(KERNEL)/' ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm ${LIB}/$file
fi
fi
# sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed
# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
# if cmp $file ${LIB}/$file >/dev/null 2>&1; then
-# echo Deleting ${LIB}/$file\; no fixes were needed.
# rm -f ${LIB}/$file
# fi
#fi
if [ -r ${LIB}/$file ]; then
echo Fixing $file, superfluous static
- ex ${LIB}/$file <<EOF
- g/^static struct tlb_pid_state/
- s/static//
- wq
-EOF
+ sed -e 's/^static struct tlb_pid_state/struct tlb_pid_state/' ${LIB}/$file > ${LIB}/${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm ${LIB}/$file
else
# This file has an alternative name, mips/cpu.h. Fix that name, too.
if [ -r ${LIB}/$file ]; then
echo Fixing $file sprintf declaration
- ex ${LIB}/$file <<EOF
- /^extern char \* sprintf();$/c
-#ifndef __STDC__
-extern char * sprintf();
-#endif /* !defined __STDC__ */
-.
- wq
-EOF
+ sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
+extern char * sprintf();\
+#endif /* !defined __STDC__ */,' ${LIB}/$file > ${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm ${LIB}/$file
fi
fi
if [ -r ${LIB}/$file ]; then
echo Fixing $file sprintf declaration
- ex ${LIB}/$file <<EOF
- /^extern char \* sprintf();$/c
-#ifndef __STDC__
-extern char * sprintf();
-#endif /* !defined __STDC__ */
-.
- wq
-EOF
+ sed -e 's,^extern char \* sprintf();$,#ifndef __STDC__\
+extern char * sprintf();\
+#endif /* !defined __STDC__ */,' ${LIB}/$file > ${file}.sed
+ rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm ${LIB}/$file
fi
fi
sed -e '/^struct/,/^};/s/}$/};/' ${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
' ${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
-e 's/int exit/void exit/g' ${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
sed -e 's%#endif / \*%#endif /\* %g' ${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi
${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- echo Deleting ${LIB}/$file\; no fixes were needed.
rm -f ${LIB}/$file
fi
fi