diff options
author | Zack Weinberg <zack@rabi.phys.columbia.edu> | 1998-12-07 13:35:20 +0000 |
---|---|---|
committer | Dave Brolley <brolley@gcc.gnu.org> | 1998-12-07 08:35:20 -0500 |
commit | f1a86df6cbc181439d3c1b402275110c9debd76d (patch) | |
tree | 8639ccd7c1c382473eaf051751bf1a983dde27b5 /gcc/cpplib.c | |
parent | 93447205e549088d1d5208e82462b5f681030632 (diff) | |
download | gcc-f1a86df6cbc181439d3c1b402275110c9debd76d.zip gcc-f1a86df6cbc181439d3c1b402275110c9debd76d.tar.gz gcc-f1a86df6cbc181439d3c1b402275110c9debd76d.tar.bz2 |
cpplib.h (struct cpp_buffer): Replace dir and dlen members with a struct file_name_list pointer.
1998-11-26 01:17 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
* cpplib.h (struct cpp_buffer): Replace dir and dlen members
with a struct file_name_list pointer.
(struct cpp_reader): Add pointer to chain of `actual
directory' include searchpath entries.
(struct file_name_list): Add *alloc pointer for the sake of
the actual-directory chain.
Move definition of HOST_WIDE_INT here.
(cpp_parse_escape): Change prototype to match changes in
cppexp.c.
* cppfiles.c (actual_directory): New function.
(finclude): Use it to initialize the buffer's actual_dir
entry.
(find_include_file): We don't need to fix up max_include_len
here.
* cpplib.c (do_include): Don't allocate a file_name_list on
the fly for current directory "" includes, use the one that's
been preallocated in pfile->buffer->actual_dir. Hoist out
duplicate code from the search_start selection logic.
(cpp_reader_init): Initialize pfile->actual_dirs.
Remove definition of HOST_WIDE_INT. Change calls
to cpp_parse_escape to match changes in cppexp.c (note
hardcoded MASK, which is safe since this is the source
character set).
* cppexp.c: Bring over changes to cpp_parse_escape from cccp.c
to handle wide character constants in #if directives. The
function now returns a HOST_WIDE_INT, and takes a third
argument which is a binary mask for all legal values (0x00ff
for 8-bit `char', 0xffff for 16-bit `wchar_t', etc.) Define
MAX_CHAR_TYPE_MASK and MAX_WCHAR_TYPE_MASK. Change callers of
cpp_parse_escape to match. [Fixes c-torture/execute/widechar-1.c]
From-SVN: r24153
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r-- | gcc/cpplib.c | 93 |
1 files changed, 30 insertions, 63 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c index a9bb550..dbdf2f4 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -50,27 +50,6 @@ extern char *update_path PARAMS ((char *, char *)); #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) #define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) -/* Find the largest host integer type and set its size and type. - Watch out: on some crazy hosts `long' is shorter than `int'. */ - -#ifndef HOST_WIDE_INT -# if HAVE_INTTYPES_H -# include <inttypes.h> -# define HOST_WIDE_INT intmax_t -# else -# if (HOST_BITS_PER_LONG <= HOST_BITS_PER_INT \ - && HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_INT) -# define HOST_WIDE_INT int -# else -# if (HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_LONG \ - || ! (defined LONG_LONG_MAX || defined LLONG_MAX)) -# define HOST_WIDE_INT long -# else -# define HOST_WIDE_INT long long -# endif -# endif -# endif -#endif /* By default, colon separates directories in a path. */ #ifndef PATH_SEPARATOR @@ -2932,7 +2911,7 @@ do_include (pfile, keyword, unused1, unused2) int before; /* included before? */ long flen; char *fbeg, *fend; - struct file_name_list *srcdir = 0; /* for "" includes */ + cpp_buffer *fp; enum cpp_token token; @@ -3015,48 +2994,39 @@ do_include (pfile, keyword, unused1, unused2) cpp_error (pfile, "empty file name in `#%s'", keyword->name); return 0; } + + search_start = 0; + + for (fp = CPP_BUFFER (pfile); + fp != CPP_NULL_BUFFER (pfile); + fp = CPP_PREV_BUFFER (fp)) + if (fp->fname != NULL) + break; + + if (fp == CPP_NULL_BUFFER (pfile)) + fp = NULL; /* For #include_next, skip in the search path past the dir in which the containing file was found. */ if (skip_dirs) { - cpp_buffer *fp = CPP_BUFFER (pfile); - for (; fp != CPP_NULL_BUFFER (pfile); fp = CPP_PREV_BUFFER (fp)) - if (fp->fname != NULL) - { - /* Don't skip anything if the containing file was found - by an absolute path. */ - if (fp->ihash->foundhere == ABSOLUTE_PATH) - search_start = angle_brackets - ? CPP_OPTIONS (pfile)->bracket_include - : CPP_OPTIONS (pfile)->quote_include; - else - search_start = fp->ihash->foundhere->next; - break; - } + if (fp) + search_start = fp->ihash->foundhere->next; } else - search_start = angle_brackets - ? CPP_OPTIONS (pfile)->bracket_include - : CPP_OPTIONS (pfile)->quote_include; - - /* For "" includes when ignore_srcdir is off, tack the actual directory - of the current file onto the beginning of the search path. - The block must be permanently allocated since it may wind up - in the include hash. */ - if (!angle_brackets - && search_start == CPP_OPTIONS (pfile)->quote_include - && !CPP_OPTIONS (pfile)->ignore_srcdir) { - srcdir = (struct file_name_list *) - xmalloc (sizeof (struct file_name_list)); - srcdir->next = CPP_OPTIONS (pfile)->quote_include; - srcdir->name = CPP_BUFFER (pfile)->dir; - srcdir->nlen = CPP_BUFFER (pfile)->dlen; - srcdir->sysp = 0; - srcdir->name_map = NULL; - - search_start = srcdir; + if (angle_brackets) + search_start = CPP_OPTIONS (pfile)->bracket_include; + else + { + if (!CPP_OPTIONS (pfile)->ignore_srcdir) + { + if (fp) + search_start = fp->actual_dir; + } + else + search_start = CPP_OPTIONS (pfile)->quote_include; + } } if (!search_start) @@ -3067,10 +3037,6 @@ do_include (pfile, keyword, unused1, unused2) fd = find_include_file (pfile, fbeg, search_start, &ihash, &before); - if (srcdir - && (ihash == (struct include_hash *)-1 || srcdir != ihash->foundhere)) - free (srcdir); - if (fd == -2) return 0; @@ -3128,8 +3094,8 @@ do_include (pfile, keyword, unused1, unused2) /* Handle -H option. */ if (CPP_OPTIONS(pfile)->print_include_names) { - cpp_buffer *buf = CPP_BUFFER (pfile); - while ((buf = CPP_PREV_BUFFER (buf)) != CPP_NULL_BUFFER (pfile)) + fp = CPP_BUFFER (pfile); + while ((fp = CPP_PREV_BUFFER (fp)) != CPP_NULL_BUFFER (pfile)) putc ('.', stderr); fprintf (stderr, " %s\n", ihash->name); } @@ -3282,7 +3248,7 @@ convert_string (pfile, result, in, limit, handle_escapes) if (handle_escapes) { char *bpc = (char *) in; - int i = (U_CHAR) cpp_parse_escape (pfile, &bpc); + int i = (U_CHAR) cpp_parse_escape (pfile, &bpc, 0x00ffU); in = (U_CHAR *) bpc; if (i >= 0) *result++ = (U_CHAR)c; @@ -5380,6 +5346,7 @@ cpp_reader_init (pfile) pfile->timebuf = NULL; pfile->only_seen_white = 1; pfile->buffer = CPP_NULL_BUFFER(pfile); + pfile->actual_dirs = NULL; } static struct cpp_pending * |