ref: 11c2f9d8aedc5338cdb03b6c53d9461e12f9aaaa
parent: 1126acd115d8cded1f3b6a6e20134b60266f382e
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon May 11 12:29:28 EDT 2015
Merge consecutive strings
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -1,5 +1,4 @@
-#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <setjmp.h>
@@ -353,21 +352,36 @@
static uint8_t
string(void)
{- static char buf[STRINGSIZ+1];
+ char buf[STRINGSIZ+1];
Symbol *sym;
char *bp = buf, c;
- assert(STRINGSIZ <= INPUTSIZ);
- for (++input->p; (c = *input->p) != '\0'; ++input->p) {- if (c == '"')
- break;
+repeat:
+ for (++input->p; (c = *input->p) != '\0' && c != '"'; ++input->p) {if (c == '\\')
c = escape();
+ if (bp == &buf[STRINGSIZ])
+ error("string too long");*bp++ = c;
}
if (c == '\0')
error("missing terminating '\"' character");+ ++input->p;
+
+ for (;;) {+ if (isspace((c = *input->p))) {+ ++input->p;
+ } else if (c == '\0') {+ input->begin = input->p;
+ fill();
+ } else if (c == '"') {+ goto repeat;
+ } else {+ break;
+ }
+ }
+
*bp = '\0';
sym = install("", NS_IDEN);sym->u.s = xstrdup(buf);
--
⑨