From 4b0c16ee1c6fd58b8c303521b7b867ca61961ad1 Mon Sep 17 00:00:00 2001 From: neil Date: Sun, 4 Mar 2001 12:02:02 +0000 Subject: * cppfiles.c (_cpp_execute_include): Don't make a null-terminated copy of the filename. Don't use CPP_PREV_BUFFER. Don't call strlen or strcpy; we already know the length. (_cpp_compare_file_date): Similarly. * cpphash.h (struct cpp_reader): Delete done_initialising. (CPP_PREV_BUFFER): Delete. * cppinit.c (cpp_start_read): Don't set done_initialising. * cpplex.c (parse_string): Guarantee null-termination. (_cpp_equiv_toklists): Remove. * cpplib.c (glue_header_name): Null-terminate. (do_line): Don't leak memory. * cpplib.h (BT_WEAK): Delete. * cppmain.c (cb_ident): Strings are now null-terminated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@40233 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cppfiles.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'gcc/cppfiles.c') diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index 72af4333531..0dfd9d0db66 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -585,10 +585,9 @@ _cpp_execute_include (pfile, header, no_reinclude, include_next) int include_next; { struct search_path *search_start = 0; - unsigned int len = header->val.str.len; unsigned int angle_brackets = header->type == CPP_HEADER_NAME; + const char *fname = (const char *) header->val.str.text; struct include_file *inc; - char *fname; int print_dep; /* Help protect #include or similar from recursion. */ @@ -626,10 +625,6 @@ _cpp_execute_include (pfile, header, no_reinclude, include_next) } } - fname = alloca (len + 1); - memcpy (fname, header->val.str.text, len); - fname[len] = '\0'; - if (!search_start) { if (angle_brackets) @@ -660,8 +655,8 @@ _cpp_execute_include (pfile, header, no_reinclude, include_next) /* Handle -H option. */ if (CPP_OPTION (pfile, print_include_names)) { - cpp_buffer *fp = CPP_BUFFER (pfile); - while ((fp = CPP_PREV_BUFFER (fp)) != NULL) + cpp_buffer *fp = pfile->buffer; + while ((fp = fp->prev) != NULL) putc ('.', stderr); fprintf (stderr, " %s\n", inc->name); } @@ -692,13 +687,13 @@ _cpp_execute_include (pfile, header, no_reinclude, include_next) /* FIXME: ptr can be null, no? */ len = ptr->len; - p = (char *) alloca (len + strlen (fname) + 2); + p = (char *) alloca (len + header->val.str.len + 2); if (len) { memcpy (p, ptr->name, len); p[len++] = '/'; } - strcpy (p + len, fname); + memcpy (p + len, fname, header->val.str.len + 1); _cpp_simplify_pathname (p); deps_add_dep (pfile->deps, p); } @@ -722,8 +717,7 @@ _cpp_compare_file_date (pfile, f) cpp_reader *pfile; const cpp_token *f; { - unsigned int len = f->val.str.len; - char *fname; + const char *fname = (const char *) f->val.str.text; struct search_path *search_start; struct include_file *inc; @@ -732,9 +726,6 @@ _cpp_compare_file_date (pfile, f) else if (CPP_OPTION (pfile, ignore_srcdir)) search_start = pfile->buffer->search_from; - fname = alloca (len + 1); - memcpy (fname, f->val.str.text, len); - fname[len] = '\0'; inc = find_include_file (pfile, fname, search_start); if (!inc) -- cgit v1.2.1