scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit c31a24c04de5785a76725ea7e2fea652e192b107
parent 534a9fa01a8a0c080df60800a370421dc594532c
Author: Avi Halachmi (:avih) <avihpit@yahoo.com>
Date:   Sun, 15 Feb 2026 22:22:19 +0200

scc-cpp.sh and gcc-scc.sh: improve handling of arguments

Previously, any argument to scc-cpp.sh and some arguments to gcc-scc.sh
were broken if they contained any IFS chars, such as space.

Now correct quoting is used in these scripts, which do maintain the
arguments correctly.

In scc-cpp.sh the change is trivial from $@ to "$@" .

In gcc-scc.sh it's a bit more involved as arguments are handled
individually and iteratively.

The big change is replacing .c with .o for all file names for $ld,
where instead of converting the whole line in one sed, we now iterate
the files individually while maintaining any IFS chars in them

Diffstat:
Msrc/cmd/scc-cc/posix/scc-cpp.sh | 2+-
Msrc/libc/gcc-scc.sh | 21++++++++++++++++++---
2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/cmd/scc-cc/posix/scc-cpp.sh b/src/cmd/scc-cc/posix/scc-cpp.sh @@ -1,3 +1,3 @@ #/bin/sh -scc-cc -E $@ +scc-cc -E "$@" diff --git a/src/libc/gcc-scc.sh b/src/libc/gcc-scc.sh @@ -61,15 +61,30 @@ ldflags="-g -z nodefaultlib -static -L$lib" if test ${onlycc:-0} -eq 1 then - $cc $cflags $includes -c $@ + $cc $cflags $includes -c "$@" else for i do case $i in *.c) - $cc $cflags $includes -c $i + $cc $cflags $includes -c "$i" ;; esac done - $ld $ldflags $nopie `echo $@ | sed 's/\.c$/.o/g'` $crt -lc -lcrt -o $out + + # convert *.c args to *.o while correctly maintaing IFS chars + for i + do + shift + case $i in + *.c) + set -- "$@" "${i%c}o" + ;; + *) + set -- "$@" "$i" + ;; + esac + done + + $ld $ldflags $nopie "$@" $crt -lc -lcrt -o "$out" fi