From 5ba3700755947a6416e1a609455171e0b8de7767 Mon Sep 17 00:00:00 2001 From: zack Date: Fri, 29 Oct 1999 04:31:14 +0000 Subject: 1999-10-28 21:27 -0700 Zack Weinberg * cpplib.h (struct cpp_buffer: fname, nominal_fname, last_nominal_fname): Mark const. (struct include_hash: name, nshort, control_macro): Mark const. (struct macrodef: symnam): Mark const. (struct if_stack: fname): Mark const. (is_idchar, is_idstart, is_hor_space, trigraph_table): Delete. (IStable): New character-syntax array which encompasses all the old is_foo arrays. (is_idchar, is_numchar, is_idstart, is_numstart, is_hspace, is_space): New macros for interrogating IStable. (check_macro_name): Kill last argument. All callers changed. * cppinit.c (initialize_char_syntax): Delete. (is_idchar, is_idstart, is_hor_space, is_space, trigraph_table): Delete. (IStable): New. Initialize with clever macros to avoid information duplication. (builtin_array): Table of builtins to get rid of explicit list in initialize_builtins. (initialize_builtins): Use builtins_array. (cpp_start_read): Call init_IStable, and set IStable['$'] if opts->dollars_in_ident. * cppexp.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (cpp_parse_expr): Avoid 'format string is not constant' warning. Use ISGRAPH to identify printable chars. * cppfiles.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. (read_and_prescan): Map trigraphs to chars with open-coded if-else-if-... sequence, not a lookup table. * cpphash.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. * cpplib.c: Change all refs to is_xyz[] arrays to use new is_xyz() macros. Kill SKIP_ALL_WHITE_SPACE (unused). (check_macro_name): Remove ability to report an invalid assertion name, which is never used. (do_line): Constify a couple of char *'s. * cppmain.c (main): Call cpp_cleanup before returning. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30252 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cppfiles.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'gcc/cppfiles.c') diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index 2aa2eebdeb0..dfeddcc8ca2 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -437,10 +437,10 @@ read_filename_string (ch, f) len = 20; set = alloc = xmalloc (len + 1); - if (! is_space[ch]) + if (! is_space(ch)) { *set++ = ch; - while ((ch = getc (f)) != EOF && ! is_space[ch]) + while ((ch = getc (f)) != EOF && ! is_space(ch)) { if (set - alloc == len) { @@ -503,10 +503,10 @@ read_name_map (pfile, dirname) char *from, *to; struct file_name_map *ptr; - if (is_space[ch]) + if (is_space(ch)) continue; from = read_filename_string (ch, f); - while ((ch = getc (f)) != EOF && is_hor_space[ch]) + while ((ch = getc (f)) != EOF && is_hspace(ch)) ; to = read_filename_string (ch, f); @@ -976,7 +976,7 @@ read_and_prescan (pfile, fp, desc, len) case SPECCASE_QUESTION: /* ? */ { - unsigned int d; + unsigned int d, t; /* If we're at the end of the intermediate buffer, we have to shift the ?'s down to the start and come back next pass. */ @@ -998,12 +998,27 @@ read_and_prescan (pfile, fp, desc, len) *--ibase = '?'; goto read_next; } - if (!trigraph_table[d]) + + /* Trigraph map: + * from to from to from to + * ?? = # ?? ) ] ?? ! | + * ?? ( [ ?? ' ^ ?? > } + * ?? / \ ?? < { ?? - ~ + */ + if (d == '=') t = '#'; + else if (d == ')') t = ']'; + else if (d == '!') t = '|'; + else if (d == '(') t = '['; + else if (d == '\'') t = '^'; + else if (d == '>') t = '}'; + else if (d == '/') t = '\\'; + else if (d == '<') t = '{'; + else if (d == '-') t = '~'; + else { *op++ = '?'; break; } - if (CPP_OPTIONS (pfile)->warn_trigraphs) { unsigned long col; @@ -1014,10 +1029,10 @@ read_and_prescan (pfile, fp, desc, len) } if (CPP_OPTIONS (pfile)->trigraphs) { - if (trigraph_table[d] == '\\') + if (t == '\\') goto backslash; else - *op++ = trigraph_table[d]; + *op++ = t; } else { -- cgit v1.2.3