diff options
author | Zack Weinberg <zack@bitmover.com> | 1999-10-29 04:31:14 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 1999-10-29 04:31:14 +0000 |
commit | a9ae448346792bff101f82eceebcbe4807e85766 (patch) | |
tree | b2a0aa8d86d67e1213ffbe961148d1038e5ba877 /gcc/cpplib.c | |
parent | 3277221c451318748ffe73c4205ca474fd0b806c (diff) | |
download | gcc-a9ae448346792bff101f82eceebcbe4807e85766.zip gcc-a9ae448346792bff101f82eceebcbe4807e85766.tar.gz gcc-a9ae448346792bff101f82eceebcbe4807e85766.tar.bz2 |
cpplib.h (struct cpp_buffer: fname, [...]): Mark const.
1999-10-28 21:27 -0700 Zack Weinberg <zack@bitmover.com>
* 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.
From-SVN: r30252
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r-- | gcc/cpplib.c | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 7e41d1b..c3e3960 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -25,8 +25,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "cpphash.h" #include "intl.h" -#define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0) -#define SKIP_ALL_WHITE_SPACE(p) do { while (is_space[*p]) p++; } while (0) +#define SKIP_WHITE_SPACE(p) do { while (is_hspace(*p)) p++; } while (0) #define PEEKN(N) (CPP_BUFFER (pfile)->rlimit - CPP_BUFFER (pfile)->cur >= (N) ? CPP_BUFFER (pfile)->cur[N] : EOF) #define FORWARD(N) CPP_FORWARD (CPP_BUFFER (pfile), (N)) @@ -411,7 +410,7 @@ cpp_skip_hspace (pfile) c = GETC(); if (c == EOF) return; - else if (is_hor_space[c]) + else if (is_hspace(c)) { if ((c == '\f' || c == '\v') && CPP_PEDANTIC (pfile)) cpp_pedwarn (pfile, "%s in preprocessing directive", @@ -596,36 +595,29 @@ pass_thru_directive (buf, len, pfile, keyword) CPP_PUTS_Q (pfile, buf, len); } -/* Check a purported macro name SYMNAME, and yield its length. - ASSERTION is nonzero if this is really for an assertion name. */ +/* Check a purported macro name SYMNAME, and yield its length. */ int -check_macro_name (pfile, symname, assertion) +check_macro_name (pfile, symname) cpp_reader *pfile; const U_CHAR *symname; - int assertion; { const U_CHAR *p; int sym_length; - for (p = symname; is_idchar[*p]; p++) + for (p = symname; is_idchar(*p); p++) ; sym_length = p - symname; if (sym_length == 0 || (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"'))) - cpp_error (pfile, - assertion ? "invalid assertion name" : "invalid macro name"); - else if (!is_idstart[*symname] + cpp_error (pfile, "invalid macro name"); + else if (!is_idstart(*symname) || (! strncmp (symname, "defined", 7) && sym_length == 7)) { U_CHAR *msg; /* what pain... */ msg = (U_CHAR *) alloca (sym_length + 1); bcopy (symname, msg, sym_length); msg[sym_length] = 0; - cpp_error (pfile, - (assertion - ? "invalid assertion name `%s'" - : "invalid macro name `%s'"), - msg); + cpp_error (pfile, "invalid macro name `%s'", msg); } return sym_length; } @@ -1354,7 +1346,7 @@ do_line (pfile, keyword) if (strcmp (fname, ip->nominal_fname)) { - char *newname, *oldname; + const char *newname, *oldname; if (!strcmp (fname, ip->fname)) newname = ip->fname; else if (ip->last_nominal_fname @@ -1370,7 +1362,7 @@ do_line (pfile, keyword) && ip->last_nominal_fname != oldname && ip->last_nominal_fname != newname && ip->last_nominal_fname != ip->fname) - free (ip->last_nominal_fname); + free ((void *) ip->last_nominal_fname); if (newname == ip->fname) ip->last_nominal_fname = NULL; @@ -1415,7 +1407,7 @@ do_undef (pfile, keyword) cpp_skip_hspace (pfile); c = GETC(); - if (! is_idstart[c]) + if (! is_idstart(c)) { cpp_error (pfile, "token after #undef is not an identifier"); skip_rest_of_line (pfile); @@ -1440,7 +1432,7 @@ do_undef (pfile, keyword) CPP_SET_WRITTEN (pfile, here); - sym_length = check_macro_name (pfile, buf, 0); + sym_length = check_macro_name (pfile, buf); while ((hp = cpp_lookup (pfile, name, sym_length, -1)) != NULL) { @@ -1643,10 +1635,10 @@ do_pragma (pfile, keyword) { U_CHAR *end = syms; - while (is_idchar[*end]) + while (is_idchar(*end)) end++; - if (!is_hor_space[*end] && *end != '\0') + if (!is_hspace(*end) && *end != '\0') { cpp_error (pfile, "invalid #pragma poison directive"); return 1; @@ -1924,7 +1916,7 @@ do_xifdef (pfile, keyword) else { U_CHAR *cp = buf; fprintf (pcp_outfile, "#undef "); - while (is_idchar[*cp]) /* Ick! */ + while (is_idchar(*cp)) /* Ick! */ fputc (*cp++, pcp_outfile); putc ('\n', pcp_outfile); } @@ -2573,7 +2565,7 @@ cpp_get_token (pfile) c = PEEKC (); if (c == EOF) break; - if (!is_idchar[c] && c != '.' + if (!is_idchar(c) && c != '.' && ((c2 != 'e' && c2 != 'E' && ((c2 != 'p' && c2 != 'P') || CPP_C89 (pfile))) || (c != '+' && c != '-'))) @@ -2598,7 +2590,7 @@ cpp_get_token (pfile) c = GETC(); if (c == EOF) goto chill_number_eof; - if (!is_idchar[c]) + if (!is_idchar(c)) break; CPP_PUTC (pfile, c); } @@ -2720,7 +2712,7 @@ cpp_get_token (pfile) { CPP_PUTC (pfile, c); c = PEEKC (); - if (c == EOF || !is_hor_space[c]) + if (c == EOF || !is_hspace(c)) break; FORWARD(1); } @@ -2816,7 +2808,7 @@ parse_name (pfile, c) { for (;;) { - if (! is_idchar[c]) + if (! is_idchar(c)) { FORWARD (-1); break; @@ -2939,7 +2931,7 @@ parse_assertion (pfile) int c, dropwhite; cpp_skip_hspace (pfile); c = PEEKC(); - if (! is_idstart[c]) + if (! is_idstart(c)) { cpp_error (pfile, "assertion predicate is not an identifier"); return 0; @@ -2951,7 +2943,7 @@ parse_assertion (pfile) c = PEEKC(); if (c != '(') { - if (is_hor_space[c] || c == '\r') + if (is_hspace(c) || c == '\r') cpp_skip_hspace (pfile); c = PEEKC(); } @@ -2963,7 +2955,7 @@ parse_assertion (pfile) dropwhite = 1; while ((c = GETC()) != ')') { - if (is_hor_space[c]) + if (is_space(c)) { if (! dropwhite) { |