diff options
author | Neil Booth <neil@daikokuya.demon.co.uk> | 2001-11-26 23:44:54 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2001-11-26 23:44:54 +0000 |
commit | 4d6baafa31576db4b1f5bc2d79913c9ce96e3a61 (patch) | |
tree | c1a2c9c7c2d1ce0412550e13966b5458cdbb8bbe /gcc/cpplib.c | |
parent | d4b4b319a23400caa59bbf0e2db01a8f0e38b34e (diff) | |
download | gcc-4d6baafa31576db4b1f5bc2d79913c9ce96e3a61.zip gcc-4d6baafa31576db4b1f5bc2d79913c9ce96e3a61.tar.gz gcc-4d6baafa31576db4b1f5bc2d79913c9ce96e3a61.tar.bz2 |
cppfiles.c (stack_include_file): Don't optimize zero-length files.
* cppfiles.c (stack_include_file): Don't optimize zero-length
files.
(read_include_file): NUL-terminate read files.
* cpplex.c (handle_newline, skip_escaped_newlines,
get_effective_char, skip_whitespace, parse_identifier,
parse_identifier_slow, parse_number, parse_string,
_cpp_lex_direct): Optimize for the fact that buffers are guaranteed
NUL-terminated.
* cpplib.c (destringize_and_run, cpp_define, handle_assertion):
Be sure buffers are NUL terminated.
* cppmacro.c (warn_of_redefinition): Kill compile warning.
* c-common.c: Include tree-inline.h.
(c_language): Move separate definitions here.
(c_common_init_options, c_common_post_options): New.
(c_common_lang_init): Rename c_common_init.
* c-common.h (c_common_lang_init): Similarly.
(c_common_init_options, c_common_post_options): New.
* c-lang.c (c_post_options): Move body to c_common_post_options.
(c_init_options): Use c_common_init_options.
(c_init): Update.
* langhooks.def: Rearrange.
* langhooks.h: Rearrange, and improve comments.
* toplev.c (do_compile): New function.
(toplev_main): Use it.
(lang_independent_f_options, parse_options_and_default_flags,
process_options): Remove trailing periods.
* Makefile.in: Update.
cp: * decl2.c (c_language): Move to c-common.c.
* lex.c (cxx_post_options, cxx_init_options): Use c-common.c
functions.
(cxx_init): Update.
objc: * objc-act.c (objc_post_options, objc_init_options): Use c-common.c
functions.
(ojbc_init): Update.
From-SVN: r47362
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r-- | gcc/cpplib.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 324c7b2..ea1d9f8 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -1158,7 +1158,7 @@ destringize_and_run (pfile, in) const unsigned char *src, *limit; char *dest, *result; - dest = result = alloca (in->len); + dest = result = alloca (in->len + 1); for (src = in->text, limit = src + in->len; src < limit;) { /* We know there is a character following the backslash. */ @@ -1166,6 +1166,7 @@ destringize_and_run (pfile, in) src++; *dest++ = *src++; } + *dest = '\0'; run_directive (pfile, T_PRAGMA, result, dest - result); } @@ -1647,9 +1648,8 @@ cpp_define (pfile, str) Change the first "=" in the string to a space. If there is none, tack " 1" on the end. */ - /* Length including the null. */ count = strlen (str); - buf = (char *) alloca (count + 2); + buf = (char *) alloca (count + 3); memcpy (buf, str, count); p = strchr (str, '='); @@ -1660,6 +1660,7 @@ cpp_define (pfile, str) buf[count++] = ' '; buf[count++] = '1'; } + buf[count] = '\0'; run_directive (pfile, T_DEFINE, buf, count); } @@ -1714,11 +1715,12 @@ handle_assertion (pfile, str, type) { /* Copy the entire option so we can modify it. Change the first "=" in the string to a '(', and tack a ')' on the end. */ - char *buf = (char *) alloca (count + 1); + char *buf = (char *) alloca (count + 2); memcpy (buf, str, count); buf[p - str] = '('; buf[count++] = ')'; + buf[count] = '\0'; str = buf; } |