From 5648866613a7d3a348a5a29c6494f1fe8ab0364a Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Tue, 14 Mar 2000 17:25:24 +0000 Subject: cppfiles.c (find_include_file): Don't assume nshort is a substring of name. * cppfiles.c (find_include_file): Don't assume nshort is a substring of name. From-SVN: r32533 --- gcc/cppfiles.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'gcc/cppfiles.c') diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index cff8cd2..98b79af 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -257,13 +257,20 @@ find_include_file (pfile, fname, search_start, ihash, before) if (f == -1) return -1; - ih = (IHASH *) xmalloc (sizeof (IHASH) + strlen (name)); - strcpy ((char *)ih->name, name); - ih->foundhere = path; if (path == ABSOLUTE_PATH) - ih->nshort = ih->name; + { + ih = (IHASH *) xmalloc (sizeof (IHASH) + strlen (name)); + ih->nshort = ih->name; + } else - ih->nshort = strstr (ih->name, fname); + { + ih = (IHASH *) xmalloc (sizeof (IHASH) + strlen (name) + + strlen (fname) + 1); + ih->nshort = ih->name + strlen (fname) + 1; + strcpy ((char *)ih->nshort, fname); + } + strcpy ((char *)ih->name, name); + ih->foundhere = path; ih->control_macro = NULL; ih->hash = dummy.hash; -- cgit v1.1