diff options
author | Michael Forney <mforney@mforney.org> | 2020-03-22 13:12:35 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2020-03-22 13:21:21 -0700 |
commit | caa4368d89116077fe94191e6e3ee67b6a8b092b (patch) | |
tree | 7e5af80ed6d83f6be1fac08f372c0ac43dce4466 | |
parent | ed8f52d4a65d8a06aa01a247eab39e65ec5334e1 (diff) |
pp: Don't add leading space for first stringized token
-rw-r--r-- | pp.c | 2 | ||||
-rw-r--r-- | test/preprocess-macro-stringize-2.c | 1 | ||||
-rw-r--r-- | test/preprocess-macro-stringize-2.pp | 1 |
3 files changed, 3 insertions, 1 deletions
@@ -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 index 81862b6..5631883 100644 --- 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 index 1dad46c..975126d 100644 --- a/test/preprocess-macro-stringize-2.pp +++ b/test/preprocess-macro-stringize-2.pp @@ -1,3 +1,4 @@ "@" "12 x- 3 abc" "'\"' \"\\\\\"" +"abc" |