From 26889d37629ceba8942e33c2dc23c18d04fef174 Mon Sep 17 00:00:00 2001 From: cjhjacobs Date: Thu, 30 Jun 2005 16:54:15 +0000 Subject: [PATCH] Fix: did not deal with quotes in macro definitions properly --- util/cpp/domacro.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/util/cpp/domacro.c b/util/cpp/domacro.c index 5fd71eba5..4ef021f9d 100644 --- a/util/cpp/domacro.c +++ b/util/cpp/domacro.c @@ -608,6 +608,7 @@ get_text(formals, length) register unsigned int text_size; char *text = Malloc(text_size = ITEXTSIZE); register unsigned int pos = 0; + int match = 0; LoadChar(c); @@ -621,15 +622,19 @@ get_text(formals, length) */ text[pos++] = ' '; ++LineNumber; - LoadChar(c); } - else + else { text[pos++] = '\\'; - if (pos == text_size) - text = Realloc(text, text_size <<= 1); + if (pos == text_size) + text = Realloc(text, text_size <<= 1); + text[pos++] = c; + if (pos == text_size) + text = Realloc(text, text_size <<= 1); + } + LoadChar(c); } else - if ( c == '/') { + if (match == 0 && c == '/') { LoadChar(c); if (c == '*') { skipcomment(); @@ -642,7 +647,19 @@ get_text(formals, length) text = Realloc(text, text_size <<= 1); } else - if (formals && class(c) == STIDF) { + if (c == '\'' || c == '"') { + text[pos++] = c; + if (pos == text_size) + text = Realloc(text, text_size <<= 1); + if (match == c) { + match = 0; + } else if (match == 0) { + match = c; + } + LoadChar(c); + } + else + if (match == 0 && formals && class(c) == STIDF) { char id_buf[IDFSIZE + 1]; register char *idp = id_buf; int n; -- 2.34.1