cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit caa4368d89116077fe94191e6e3ee67b6a8b092b
parent ed8f52d4a65d8a06aa01a247eab39e65ec5334e1
Author: Michael Forney <mforney@mforney.org>
Date:   Sun, 22 Mar 2020 13:12:35 -0700

pp: Don't add leading space for first stringized token

Diffstat:
Mpp.c | 2+-
Mtest/preprocess-macro-stringize-2.c | 1+
Mtest/preprocess-macro-stringize-2.pp | 1+
3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/pp.c b/pp.c @@ -403,7 +403,7 @@ stringize(struct array *buf, struct token *t) { const char *lit; - if ((t->space || t->kind == TNEWLINE) && ((char *)buf->val)[buf->len - 1] != ' ') + if ((t->space || t->kind == TNEWLINE) && buf->len > 1 && ((char *)buf->val)[buf->len - 1] != ' ') arrayaddbuf(buf, " ", 1); lit = t->lit ? t->lit : tokstr[t->kind]; if (t->kind == TSTRINGLIT || t->kind == TCHARCONST) { diff --git a/test/preprocess-macro-stringize-2.c b/test/preprocess-macro-stringize-2.c @@ -3,3 +3,4 @@ str(@) str(12 x- 3 abc) str('"' "\\") +str( abc) diff --git a/test/preprocess-macro-stringize-2.pp b/test/preprocess-macro-stringize-2.pp @@ -1,3 +1,4 @@ "@" "12 x- 3 abc" "'\"' \"\\\\\"" +"abc"