diff options
author | obrien <obrien@FreeBSD.org> | 2002-05-09 20:02:13 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2002-05-09 20:02:13 +0000 |
commit | c8f5fc7032940ad6633f932ac40cade82ec4d0cc (patch) | |
tree | 29a0f0a6c79a69ecc64f612947a0fe5904311713 /contrib/gcc/cppmacro.c | |
parent | c9ab9ae440a8066b2c2b85b157b1fdadcf09916a (diff) | |
download | FreeBSD-src-c8f5fc7032940ad6633f932ac40cade82ec4d0cc.zip FreeBSD-src-c8f5fc7032940ad6633f932ac40cade82ec4d0cc.tar.gz |
Gcc 3.1.0 pre-release from the FSF anoncvs repo on 9-May-2002 15:57:15 EDT.
Diffstat (limited to 'contrib/gcc/cppmacro.c')
-rw-r--r-- | contrib/gcc/cppmacro.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/contrib/gcc/cppmacro.c b/contrib/gcc/cppmacro.c index 538c689..b351f96 100644 --- a/contrib/gcc/cppmacro.c +++ b/contrib/gcc/cppmacro.c @@ -64,9 +64,6 @@ static cpp_context *next_context PARAMS ((cpp_reader *)); static const cpp_token *padding_token PARAMS ((cpp_reader *, const cpp_token *)); static void expand_arg PARAMS ((cpp_reader *, macro_arg *)); -static unsigned char *quote_string PARAMS ((unsigned char *, - const unsigned char *, - unsigned int)); static const cpp_token *new_string_token PARAMS ((cpp_reader *, U_CHAR *, unsigned int)); static const cpp_token *new_number_token PARAMS ((cpp_reader *, unsigned int)); @@ -163,7 +160,7 @@ builtin_macro (pfile, node) name = map->to_file; len = strlen (name); buf = _cpp_unaligned_alloc (pfile, len * 4 + 1); - len = quote_string (buf, (const unsigned char *) name, len) - buf; + len = cpp_quote_string (buf, (const unsigned char *) name, len) - buf; result = new_string_token (pfile, buf, len); } @@ -243,9 +240,10 @@ builtin_macro (pfile, node) /* Copies SRC, of length LEN, to DEST, adding backslashes before all backslashes and double quotes. Non-printable characters are - converted to octal. DEST must be of sufficient size. */ -static U_CHAR * -quote_string (dest, src, len) + converted to octal. DEST must be of sufficient size. Returns + a pointer to the end of the string. */ +U_CHAR * +cpp_quote_string (dest, src, len) U_CHAR *dest; const U_CHAR *src; unsigned int len; @@ -330,7 +328,7 @@ stringify_arg (pfile, arg) _cpp_buff *buff = _cpp_get_buff (pfile, len); unsigned char *buf = BUFF_FRONT (buff); len = cpp_spell_token (pfile, token, buf) - buf; - dest = quote_string (dest, buf, len); + dest = cpp_quote_string (dest, buf, len); _cpp_release_buff (pfile, buff); } else @@ -648,12 +646,17 @@ funlike_invocation_p (pfile, node) return collect_args (pfile, node); } - /* Back up. We may have skipped padding, in which case backing up - more than one token when expanding macros is in general too - difficult. We re-insert it in its own context. */ - _cpp_backup_tokens (pfile, 1); - if (padding) - push_token_context (pfile, NULL, padding, 1); + /* CPP_EOF can be the end of macro arguments, or the end of the + file. We mustn't back up over the latter. Ugh. */ + if (token->type != CPP_EOF || token == &pfile->eof) + { + /* Back up. We may have skipped padding, in which case backing + up more than one token when expanding macros is in general + too difficult. We re-insert it in its own context. */ + _cpp_backup_tokens (pfile, 1); + if (padding) + push_token_context (pfile, NULL, padding, 1); + } return NULL; } @@ -1529,10 +1532,10 @@ cpp_macro_definition (pfile, node) len = NODE_LEN (node) + 1; /* ' ' */ if (macro->fun_like) { - len += 3; /* "()" plus possible final "." of named - varargs (we have + 2 below). */ + len += 4; /* "()" plus possible final ".." of named + varargs (we have + 1 below). */ for (i = 0; i < macro->paramc; i++) - len += NODE_LEN (macro->params[i]) + 2; /* ", " */ + len += NODE_LEN (macro->params[i]) + 1; /* "," */ } for (i = 0; i < macro->count; i++) @@ -1575,17 +1578,23 @@ cpp_macro_definition (pfile, node) } if (i + 1 < macro->paramc) - *buffer++ = ',', *buffer++ = ' '; + /* Don't emit a space after the comma here; we're trying + to emit a Dwarf-friendly definition, and the Dwarf spec + forbids spaces in the argument list. */ + *buffer++ = ','; else if (macro->variadic) *buffer++ = '.', *buffer++ = '.', *buffer++ = '.'; } *buffer++ = ')'; } + /* The Dwarf spec requires a space after the macro name, even if the + definition is the empty string. */ + *buffer++ = ' '; + /* Expansion tokens. */ if (macro->count) { - *buffer++ = ' '; for (i = 0; i < macro->count; i++) { cpp_token *token = ¯o->expansion[i]; |