tcc -E: preserve spaces (partial solution)
commit00f093276030ed87c3992a5bde22673f691b08c9
authorKirill Smelkov <kirr@landau.phys.spbu.ru>
Sun, 18 Jan 2009 13:52:09 +0000 (18 16:52 +0300)
committergrischka <grischka>
Sat, 18 Apr 2009 13:07:08 +0000 (18 15:07 +0200)
treef534aefcac8594866852a313b1475dcbbd08e1cd
parent6213d4b4b65f14c608686a4745797f534ba5c54d
tcc -E: preserve spaces  (partial solution)

Recently I needed to trim storage space on an embedded distro which has
X.

X depend on cpp which is ~8MB in size as shipped in Debian, so the idea
was to remove cpp and use `tcc -E` instead where appropriate.

I've done this with the following 'hack' put inplace of /usr/bin/cpp :

    #!/bin/sh -e
    TCC=/home/kirr/local/tcc/bin/tcc
    last="${!#}"

    # hack to distinguish between '... -D...'  and '... file'
    if test -r "$last"; then
        exec $TCC -E "$@"
    else
        exec $TCC -E "$@" -
    fi

But the problem turned out to be in `tcc -E` inability to preserve
spaces between tokens. So e.g. the following ~/.Xresources

    XTerm*VT100*foreground: black
    ...

got translated to

    XTerm * VT100 * foreground : black

which is bad, bacause now X don't understand it.

Below is a newbie "fix" for the problem.

It still does not preserve spaces on macro expansion, but since the fix
cures original problem, I think it is at least one step forward.

Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru>
tcc.c