diff options
| author | 2013-12-09 02:35:09 +0000 | |
|---|---|---|
| committer | 2013-12-09 02:35:09 +0000 | |
| commit | 80cb84630260ef89982d781cc49992a725cfd868 (patch) | |
| tree | fd2f0e3b0652e14de93d9359a9317e1271722f5c /usr.bin/cpp | |
| parent | document the global systq. (diff) | |
| download | wireguard-openbsd-80cb84630260ef89982d781cc49992a725cfd868.tar.xz wireguard-openbsd-80cb84630260ef89982d781cc49992a725cfd868.zip | |
Use shell arrays to store arguments instead of building a string for eval.
Add option argument handling for all the options that take an argument.
Handle -I with separate path argument.
Retire gcc2-specific bits.
Handle -U__GNUC__ correctly on gcc4 systems.
ok jca@ millert@
Diffstat (limited to 'usr.bin/cpp')
| -rw-r--r-- | usr.bin/cpp/Makefile | 6 | ||||
| -rw-r--r-- | usr.bin/cpp/cpp.sh | 37 |
2 files changed, 27 insertions, 16 deletions
diff --git a/usr.bin/cpp/Makefile b/usr.bin/cpp/Makefile index 4cd42f4706d..a028dbd0281 100644 --- a/usr.bin/cpp/Makefile +++ b/usr.bin/cpp/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.11 2013/08/06 19:11:53 miod Exp $ +# $OpenBSD: Makefile,v 1.12 2013/12/09 02:35:09 guenther Exp $ .include <bsd.own.mk> @@ -10,9 +10,9 @@ INSTALL_STRIP= cpp: cpp.sh .if ${COMPILER_VERSION:L} == "gcc3" - sed -e 's/@GNUC@/-D__GNUC__/' -e 's/@dollaropt@//' ${.CURDIR}/cpp.sh >$@ + sed -e 's/@GNUC@/-D__GNUC__/' ${.CURDIR}/cpp.sh >$@ .else - sed -e 's/@GNUC@//' -e 's/@dollaropt@//' ${.CURDIR}/cpp.sh >$@ + sed -e 's/@GNUC@//' ${.CURDIR}/cpp.sh >$@ .endif .include <bsd.prog.mk> diff --git a/usr.bin/cpp/cpp.sh b/usr.bin/cpp/cpp.sh index ca5ffea78db..e842ad665fb 100644 --- a/usr.bin/cpp/cpp.sh +++ b/usr.bin/cpp/cpp.sh @@ -1,5 +1,5 @@ -#!/bin/sh -# $OpenBSD: cpp.sh,v 1.8 2010/05/03 18:34:01 drahn Exp $ +#!/bin/ksh +# $OpenBSD: cpp.sh,v 1.9 2013/12/09 02:35:09 guenther Exp $ # # Copyright (c) 1990 The Regents of the University of California. @@ -43,9 +43,8 @@ PATH=/usr/bin:/bin TRAD=-traditional DGNUC="@GNUC@" STDINC="-I/usr/include" -DOLLAR="@dollaropt@" -OPTS="" -INCS="-nostdinc" +set -A OPTS +set -A INCS -- "-nostdinc" FOUNDFILES=false CPP=/usr/libexec/cpp @@ -72,22 +71,34 @@ do -notraditional) TRAD= ;; + # options that take an argument and that should be sorted before + # the $STDINC option + -I | -imacros | -include | -idirafter | -iprefix | -iwithprefix | \ + -iwithprefixbefore | -isysroot | -imultilib | -isystem | -iquote) + INCS[${#INCS[@]}]=$A + INCS[${#INCS[@]}]=$1 + shift + ;; -I*) - INCS="$INCS $A" + INCS[${#INCS[@]}]=$A + ;; + # other options that take an argument + -MF | -MT | -MQ | -x | -D | -U | -o | -A) + OPTS[${#OPTS[@]}]=$A + OPTS[${#OPTS[@]}]=$1 + shift ;; -U__GNUC__) DGNUC= - ;; - -imacros|-include|-idirafter|-iprefix|-iwithprefix) - INCS="$INCS '$A' '$1'" - shift + OPTS[${#OPTS[@]}]=$A ;; -*) - OPTS="$OPTS '$A'" + OPTS[${#OPTS[@]}]=$A ;; *) FOUNDFILES=true - eval $CPP $TRAD $DGNUC $DOLLAR $INCS $STDINC $OPTS $A || exit $? + $CPP $TRAD $DGNUC "${INCS[@]}" $STDINC "${OPTS[@]}" "$A" || + exit ;; esac done @@ -95,7 +106,7 @@ done if ! $FOUNDFILES then # read standard input - eval exec $CPP $TRAD $DGNUC $DOLLAR $INCS $STDINC $OPTS + exec $CPP $TRAD $DGNUC "${INCS[@]}" $STDINC "${OPTS[@]}" fi exit 0 |
