summaryrefslogtreecommitdiff
path: root/unproto/cpp.sh
diff options
context:
space:
mode:
Diffstat (limited to 'unproto/cpp.sh')
-rw-r--r--unproto/cpp.sh36
1 files changed, 31 insertions, 5 deletions
diff --git a/unproto/cpp.sh b/unproto/cpp.sh
index 8122b68..a039146 100644
--- a/unproto/cpp.sh
+++ b/unproto/cpp.sh
@@ -1,9 +1,35 @@
#!/bin/sh
-# @(#) cpp.sh 1.2 91/09/22 21:21:43
+# @(#) cpp.sh 1.3 92/01/15 21:53:22
-# Unprototypeing preprocessor for non-ANSI C compilers. Define __STDC__
-# if you have enough courage. You will have to modify this script if
-# your cc(1) command specifies output file names to the preprocessor.
+# Unprototypeing preprocessor for pre-ANSI C compilers. On some systems,
+# this script can be as simple as:
+#
+# /lib/cpp "$@" | unproto
+#
+# However, some cc(1) drivers specify output file names on the
+# preprocessor command line, so this shell script must be prepared to
+# intercept them. Depending on the driver program, the cpp options may
+# even go before or after the file name argument(s). The script below
+# tries to tackle all these cases.
+#
+# You may want to add -Ipath_to_stdarg.h_file, -Dvoid=, -Dvolatile=,
+# and even -D__STDC__.
-exec /lib/cpp "$@" -Dconst= -Dvolatile= | unproto
+cpp_args=""
+
+while :
+do
+ case $1 in
+ "") break;;
+ -*) cpp_args="$cpp_args $1";;
+ *) cpp_args="$cpp_args $1"
+ case $2 in
+ ""|-*) ;;
+ *) exec 1> $2 || exit 1; shift;;
+ esac;;
+ esac
+ shift
+done
+
+/lib/cpp $cpp_args | unproto