diff options
author | Neil Booth <neil@daikokuya.co.uk> | 2003-04-23 22:44:06 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2003-04-23 22:44:06 +0000 |
commit | 6338b35872d465cf27fdbbc43b5a146363c8f246 (patch) | |
tree | e4f819e101d1dc188ae9d2012e0cb8ab2239160d /gcc/cppmacro.c | |
parent | 06f5e63748eeb66140858914bbffb149406789a9 (diff) | |
download | gcc-6338b35872d465cf27fdbbc43b5a146363c8f246.zip gcc-6338b35872d465cf27fdbbc43b5a146363c8f246.tar.gz gcc-6338b35872d465cf27fdbbc43b5a146363c8f246.tar.bz2 |
Makefile.in (c-lex.o, [...]): Update.
* Makefile.in (c-lex.o, LIBCPP_OBJS, cpplex.o): Update.
* c-lex.c (MULTIBYTE_CHARS): Remove conditionals.
(lex_string): Take cpp_string with full spelling.
(cb_ident): Update.
(c_lex): Update diagnostics.
* cpplex.c (SPELL_NUMBER, SPELL_STRING): Combine into SPELL_LITERAL.
(create_literal): New.
(lex_string): Unterminated literals have type CPP_OTHER.
(_cpp_lex_direct): Update calls to lex_string. Use create_literal
for CPP_OTHER.
(cpp_token_len, cpp_spell_token, cpp_output_token): Simplify.
(_cpp_equiv_tokens, cpp_interpret_charconst): Update.
* cpplib.c (parse_include, do_line, do_linemarker,
destringize_and_run): Update for token storing full spelling.
* cpplib.h: Update token spelling types.
* cppmacro.c (stringify_arg, check_trad_stringification):
Update for token storing full spelling.
cp:
* Make-lang.in (lex.o): Remove mbchar.h.
* lex.c (MULTIBYTE_CHARS): Lose.
* parser.c (cp_lexer_get_preprocessor_token): CPP_OTHER handled
in c-lex.c.
testsuite:
* gcc.dg/cpp/include2.c: Update.
* gcc.dg/cpp/multiline-2.c: New.
* gcc.dg/cpp/multiline.c: Update.
* gcc.dg/cpp/strify2.c: Update.
* gcc.dg/cpp/trad/literals-2.c: Update.
From-SVN: r66019
Diffstat (limited to 'gcc/cppmacro.c')
-rw-r--r-- | gcc/cppmacro.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index 84692f3..b0b10ae 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -340,11 +340,16 @@ stringify_arg (pfile, arg) cpp_reader *pfile; macro_arg *arg; { - unsigned char *dest = BUFF_FRONT (pfile->u_buff); + unsigned char *dest; unsigned int i, escape_it, backslash_count = 0; const cpp_token *source = NULL; size_t len; + if (BUFF_ROOM (pfile->u_buff) < 3) + _cpp_extend_buff (pfile, &pfile->u_buff, 3); + dest = BUFF_FRONT (pfile->u_buff); + *dest++ = '"'; + /* Loop, reading in the argument's tokens. */ for (i = 0; i < arg->count; i++) { @@ -361,11 +366,11 @@ stringify_arg (pfile, arg) || token->type == CPP_CHAR || token->type == CPP_WCHAR); /* Room for each char being written in octal, initial space and - final NUL. */ + final quote and NUL. */ len = cpp_token_len (token); if (escape_it) len *= 4; - len += 2; + len += 3; if ((size_t) (BUFF_LIMIT (pfile->u_buff) - dest) < len) { @@ -375,7 +380,7 @@ stringify_arg (pfile, arg) } /* Leading white space? */ - if (dest != BUFF_FRONT (pfile->u_buff)) + if (dest - 1 != BUFF_FRONT (pfile->u_buff)) { if (source == NULL) source = token; @@ -410,12 +415,7 @@ stringify_arg (pfile, arg) } /* Commit the memory, including NUL, and return the token. */ - if ((size_t) (BUFF_LIMIT (pfile->u_buff) - dest) < 1) - { - size_t len_so_far = dest - BUFF_FRONT (pfile->u_buff); - _cpp_extend_buff (pfile, &pfile->u_buff, 1); - dest = BUFF_FRONT (pfile->u_buff) + len_so_far; - } + *dest++ = '"'; len = dest - BUFF_FRONT (pfile->u_buff); BUFF_FRONT (pfile->u_buff) = dest + 1; return new_string_token (pfile, dest - len, len); @@ -1638,10 +1638,11 @@ check_trad_stringification (pfile, macro, string) const cpp_string *string; { unsigned int i, len; - const uchar *p, *q, *limit = string->text + string->len; + const uchar *p, *q, *limit; /* Loop over the string. */ - for (p = string->text; p < limit; p = q) + limit = string->text + string->len - 1; + for (p = string->text + 1; p < limit; p = q) { /* Find the start of an identifier. */ while (p < limit && !is_idstart (*p)) |