Commit a9ae4483 by Zack Weinberg Committed by Zack Weinberg

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
parent 3277221c
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.
Thu Oct 28 21:16:35 1999 Mark Mitchell <mark@codesourcery.com> Thu Oct 28 21:16:35 1999 Mark Mitchell <mark@codesourcery.com>
* ggc.h (struct ggc_statistics): New type. * ggc.h (struct ggc_statistics): New type.
......
...@@ -457,12 +457,12 @@ cpp_lex (pfile, skip_evaluation) ...@@ -457,12 +457,12 @@ cpp_lex (pfile, skip_evaluation)
cpp_skip_hspace (pfile); cpp_skip_hspace (pfile);
} }
if (!is_idstart[*ip->cur]) if (!is_idstart(*ip->cur))
goto oops; goto oops;
if (ip->cur[0] == 'L' && (ip->cur[1] == '\'' || ip->cur[1] == '"')) if (ip->cur[0] == 'L' && (ip->cur[1] == '\'' || ip->cur[1] == '"'))
goto oops; goto oops;
tok = ip->cur; tok = ip->cur;
while (is_idchar[*ip->cur]) while (is_idchar(*ip->cur))
++ip->cur; ++ip->cur;
len = ip->cur - tok; len = ip->cur - tok;
cpp_skip_hspace (pfile); cpp_skip_hspace (pfile);
...@@ -1010,10 +1010,10 @@ cpp_parse_expr (pfile) ...@@ -1010,10 +1010,10 @@ cpp_parse_expr (pfile)
} }
break; break;
default: default:
cpp_error (pfile, if (ISGRAPH (top[1].op))
(top[1].op >= ' ' && top[1].op <= '~' cpp_error (pfile, "unimplemented operator '%c'\n", top[1].op);
? "unimplemented operator '%c'\n" else
: "unimplemented operator '\\%03o'\n"), cpp_error (pfile, "unimplemented operator '\\%03o'\n",
top[1].op); top[1].op);
} }
} }
......
...@@ -437,10 +437,10 @@ read_filename_string (ch, f) ...@@ -437,10 +437,10 @@ read_filename_string (ch, f)
len = 20; len = 20;
set = alloc = xmalloc (len + 1); set = alloc = xmalloc (len + 1);
if (! is_space[ch]) if (! is_space(ch))
{ {
*set++ = ch; *set++ = ch;
while ((ch = getc (f)) != EOF && ! is_space[ch]) while ((ch = getc (f)) != EOF && ! is_space(ch))
{ {
if (set - alloc == len) if (set - alloc == len)
{ {
...@@ -503,10 +503,10 @@ read_name_map (pfile, dirname) ...@@ -503,10 +503,10 @@ read_name_map (pfile, dirname)
char *from, *to; char *from, *to;
struct file_name_map *ptr; struct file_name_map *ptr;
if (is_space[ch]) if (is_space(ch))
continue; continue;
from = read_filename_string (ch, f); 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); to = read_filename_string (ch, f);
...@@ -976,7 +976,7 @@ read_and_prescan (pfile, fp, desc, len) ...@@ -976,7 +976,7 @@ read_and_prescan (pfile, fp, desc, len)
case SPECCASE_QUESTION: /* ? */ case SPECCASE_QUESTION: /* ? */
{ {
unsigned int d; unsigned int d, t;
/* If we're at the end of the intermediate buffer, /* If we're at the end of the intermediate buffer,
we have to shift the ?'s down to the start and we have to shift the ?'s down to the start and
come back next pass. */ come back next pass. */
...@@ -998,12 +998,27 @@ read_and_prescan (pfile, fp, desc, len) ...@@ -998,12 +998,27 @@ read_and_prescan (pfile, fp, desc, len)
*--ibase = '?'; *--ibase = '?';
goto read_next; 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++ = '?'; *op++ = '?';
break; break;
} }
if (CPP_OPTIONS (pfile)->warn_trigraphs) if (CPP_OPTIONS (pfile)->warn_trigraphs)
{ {
unsigned long col; unsigned long col;
...@@ -1014,10 +1029,10 @@ read_and_prescan (pfile, fp, desc, len) ...@@ -1014,10 +1029,10 @@ read_and_prescan (pfile, fp, desc, len)
} }
if (CPP_OPTIONS (pfile)->trigraphs) if (CPP_OPTIONS (pfile)->trigraphs)
{ {
if (trigraph_table[d] == '\\') if (t == '\\')
goto backslash; goto backslash;
else else
*op++ = trigraph_table[d]; *op++ = t;
} }
else else
{ {
......
...@@ -40,7 +40,7 @@ static struct tm *timestamp PARAMS ((cpp_reader *)); ...@@ -40,7 +40,7 @@ static struct tm *timestamp PARAMS ((cpp_reader *));
static void special_symbol PARAMS ((HASHNODE *, cpp_reader *)); static void special_symbol PARAMS ((HASHNODE *, cpp_reader *));
#define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0) #define SKIP_WHITE_SPACE(p) do { while (is_hspace(*p)) p++; } while (0)
#define CPP_IS_MACRO_BUFFER(PBUF) ((PBUF)->data != NULL) #define CPP_IS_MACRO_BUFFER(PBUF) ((PBUF)->data != NULL)
#define FORWARD(N) CPP_FORWARD (CPP_BUFFER (pfile), (N)) #define FORWARD(N) CPP_FORWARD (CPP_BUFFER (pfile), (N))
...@@ -131,7 +131,7 @@ cpp_lookup (pfile, name, len, hash) ...@@ -131,7 +131,7 @@ cpp_lookup (pfile, name, len, hash)
if (len < 0) if (len < 0)
{ {
for (bp = name; is_idchar[*bp]; bp++); for (bp = name; is_idchar(*bp); bp++);
len = bp - name; len = bp - name;
} }
...@@ -224,7 +224,7 @@ cpp_install (pfile, name, len, type, value, hash) ...@@ -224,7 +224,7 @@ cpp_install (pfile, name, len, type, value, hash)
if (len < 0) if (len < 0)
{ {
p = name; p = name;
while (is_idchar[*p]) while (is_idchar(*p))
p++; p++;
len = p - name; len = p - name;
} }
...@@ -306,7 +306,7 @@ collect_expansion (pfile, buf, limit, nargs, arglist) ...@@ -306,7 +306,7 @@ collect_expansion (pfile, buf, limit, nargs, arglist)
/* Find the beginning of the trailing whitespace. */ /* Find the beginning of the trailing whitespace. */
p = buf; p = buf;
while (p < limit && is_space[limit[-1]]) while (p < limit && is_space(limit[-1]))
limit--; limit--;
/* Allocate space for the text in the macro definition. /* Allocate space for the text in the macro definition.
...@@ -376,7 +376,7 @@ collect_expansion (pfile, buf, limit, nargs, arglist) ...@@ -376,7 +376,7 @@ collect_expansion (pfile, buf, limit, nargs, arglist)
/* ##: concatenate preceding and following tokens. */ /* ##: concatenate preceding and following tokens. */
/* Take out the first #, discard preceding whitespace. */ /* Take out the first #, discard preceding whitespace. */
exp_p--; exp_p--;
while (exp_p > lastp && is_hor_space[exp_p[-1]]) while (exp_p > lastp && is_hspace(exp_p[-1]))
--exp_p; --exp_p;
/* Skip the second #. */ /* Skip the second #. */
p++; p++;
...@@ -392,7 +392,7 @@ collect_expansion (pfile, buf, limit, nargs, arglist) ...@@ -392,7 +392,7 @@ collect_expansion (pfile, buf, limit, nargs, arglist)
Don't leave the # in the expansion. */ Don't leave the # in the expansion. */
exp_p--; exp_p--;
SKIP_WHITE_SPACE (p); SKIP_WHITE_SPACE (p);
if (p == limit || !is_idstart[*p] if (p == limit || !is_idstart(*p)
|| (*p == 'L' && p + 1 < limit && (p[1] == '\'' || || (*p == 'L' && p + 1 < limit && (p[1] == '\'' ||
p[1] == '"'))) p[1] == '"')))
cpp_error (pfile, cpp_error (pfile,
...@@ -457,17 +457,17 @@ collect_expansion (pfile, buf, limit, nargs, arglist) ...@@ -457,17 +457,17 @@ collect_expansion (pfile, buf, limit, nargs, arglist)
} }
/* Handle the start of a symbol. */ /* Handle the start of a symbol. */
if (is_idchar[c] && nargs > 0) if (is_idchar(c) && nargs > 0)
{ {
U_CHAR *id_beg = p - 1; U_CHAR *id_beg = p - 1;
int id_len; int id_len;
--exp_p; --exp_p;
while (p != limit && is_idchar[*p]) while (p != limit && is_idchar(*p))
p++; p++;
id_len = p - id_beg; id_len = p - id_beg;
if (is_idstart[c] if (is_idstart(c)
&& !(id_len == 1 && c == 'L' && (*p == '\'' || *p == '"'))) && !(id_len == 1 && c == 'L' && (*p == '\'' || *p == '"')))
{ {
register struct arglist *arg; register struct arglist *arg;
...@@ -612,12 +612,12 @@ create_definition (buf, limit, pfile, predefinition) ...@@ -612,12 +612,12 @@ create_definition (buf, limit, pfile, predefinition)
bp = buf; bp = buf;
while (is_hor_space[*bp]) while (is_hspace(*bp))
bp++; bp++;
symname = bp; /* remember where it starts */ symname = bp; /* remember where it starts */
sym_length = check_macro_name (pfile, bp, 0); sym_length = check_macro_name (pfile, bp);
bp += sym_length; bp += sym_length;
/* Lossage will occur if identifiers or control keywords are broken /* Lossage will occur if identifiers or control keywords are broken
...@@ -648,11 +648,11 @@ create_definition (buf, limit, pfile, predefinition) ...@@ -648,11 +648,11 @@ create_definition (buf, limit, pfile, predefinition)
cpp_pedwarn (pfile, "another parameter follows `%s'", cpp_pedwarn (pfile, "another parameter follows `%s'",
rest_extension); rest_extension);
if (!is_idstart[*bp]) if (!is_idstart(*bp))
cpp_pedwarn (pfile, "invalid character in macro parameter name"); cpp_pedwarn (pfile, "invalid character in macro parameter name");
/* Find the end of the arg name. */ /* Find the end of the arg name. */
while (is_idchar[*bp]) while (is_idchar(*bp))
{ {
bp++; bp++;
/* do we have a "special" rest-args extension here? */ /* do we have a "special" rest-args extension here? */
...@@ -737,7 +737,7 @@ create_definition (buf, limit, pfile, predefinition) ...@@ -737,7 +737,7 @@ create_definition (buf, limit, pfile, predefinition)
if (bp < limit) if (bp < limit)
{ {
if (is_hor_space[*bp]) if (is_hspace(*bp))
{ {
bp++; bp++;
SKIP_WHITE_SPACE (bp); SKIP_WHITE_SPACE (bp);
...@@ -1141,7 +1141,7 @@ macroexpand (pfile, hp) ...@@ -1141,7 +1141,7 @@ macroexpand (pfile, hp)
/* cpp.texi says for foo ( ) we provide one argument. /* cpp.texi says for foo ( ) we provide one argument.
However, if foo wants just 0 arguments, treat this as 0. */ However, if foo wants just 0 arguments, treat this as 0. */
if (nargs == 0) if (nargs == 0)
while (bp != lim && is_space[*bp]) while (bp != lim && is_space(*bp))
bp++; bp++;
if (bp == lim) if (bp == lim)
i = 0; i = 0;
...@@ -1227,7 +1227,7 @@ macroexpand (pfile, hp) ...@@ -1227,7 +1227,7 @@ macroexpand (pfile, hp)
/* Internal sequences of whitespace are /* Internal sequences of whitespace are
replaced by one space except within replaced by one space except within
a string or char token. */ a string or char token. */
if (is_space[c]) if (is_space(c))
{ {
if (CPP_WRITTEN (pfile) > (unsigned) arg->stringified if (CPP_WRITTEN (pfile) > (unsigned) arg->stringified
&& (CPP_PWRITTEN (pfile))[-1] == '\r') && (CPP_PWRITTEN (pfile))[-1] == '\r')
...@@ -1333,11 +1333,11 @@ macroexpand (pfile, hp) ...@@ -1333,11 +1333,11 @@ macroexpand (pfile, hp)
&& last_ap->raw_after))) && last_ap->raw_after)))
{ {
/* Delete final whitespace. */ /* Delete final whitespace. */
while (totlen > count_before && is_space[xbuf[totlen - 1]]) while (totlen > count_before && is_space(xbuf[totlen - 1]))
totlen--; totlen--;
/* Delete the nonwhites before them. */ /* Delete the nonwhites before them. */
while (totlen > count_before && !is_space[xbuf[totlen - 1]]) while (totlen > count_before && !is_space(xbuf[totlen - 1]))
totlen--; totlen--;
} }
...@@ -1357,7 +1357,7 @@ macroexpand (pfile, hp) ...@@ -1357,7 +1357,7 @@ macroexpand (pfile, hp)
whitespace markers, and no-reexpansion markers. */ whitespace markers, and no-reexpansion markers. */
while (p1 != l1) while (p1 != l1)
{ {
if (is_space[p1[0]]) if (is_space(p1[0]))
p1++; p1++;
else if (p1[0] == '\r') else if (p1[0] == '\r')
p1 += 2; p1 += 2;
...@@ -1371,7 +1371,7 @@ macroexpand (pfile, hp) ...@@ -1371,7 +1371,7 @@ macroexpand (pfile, hp)
whitespace markers, and no-reexpansion markers. */ whitespace markers, and no-reexpansion markers. */
while (p1 != l1) while (p1 != l1)
{ {
if (is_space[l1[-1]]) if (is_space(l1[-1]))
l1--; l1--;
else if (l1[-1] == '\r') else if (l1[-1] == '\r')
l1--; l1--;
...@@ -1510,7 +1510,7 @@ unsafe_chars (c1, c2) ...@@ -1510,7 +1510,7 @@ unsafe_chars (c1, c2)
case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
letter: letter:
/* We're in the middle of either a name or a pre-processing number. */ /* We're in the middle of either a name or a pre-processing number. */
return (is_idchar[c2] || c2 == '.'); return (is_idchar(c2) || c2 == '.');
case '<': case '>': case '!': case '%': case '#': case ':': case '<': case '>': case '!': case '%': case '#': case ':':
case '^': case '&': case '|': case '*': case '/': case '=': case '^': case '&': case '|': case '*': case '/': case '=':
...@@ -1551,7 +1551,7 @@ push_macro_expansion (pfile, xbuf, xbuf_len, hp) ...@@ -1551,7 +1551,7 @@ push_macro_expansion (pfile, xbuf, xbuf_len, hp)
or some other (less common) characters. */ or some other (less common) characters. */
if (xbuf[0] == '\r' && xbuf[1] == ' ' if (xbuf[0] == '\r' && xbuf[1] == ' '
&& (is_idchar[xbuf[2]] || xbuf[2] == '(' || xbuf[2] == '\'' && (is_idchar(xbuf[2]) || xbuf[2] == '(' || xbuf[2] == '\''
|| xbuf[2] == '\"')) || xbuf[2] == '\"'))
mbuf->cur += 2; mbuf->cur += 2;
...@@ -1627,25 +1627,25 @@ comp_def_part (first, beg1, len1, beg2, len2, last) ...@@ -1627,25 +1627,25 @@ comp_def_part (first, beg1, len1, beg2, len2, last)
register U_CHAR *end2 = beg2 + len2; register U_CHAR *end2 = beg2 + len2;
if (first) if (first)
{ {
while (beg1 != end1 && is_space[*beg1]) while (beg1 != end1 && is_space(*beg1))
beg1++; beg1++;
while (beg2 != end2 && is_space[*beg2]) while (beg2 != end2 && is_space(*beg2))
beg2++; beg2++;
} }
if (last) if (last)
{ {
while (beg1 != end1 && is_space[end1[-1]]) while (beg1 != end1 && is_space(end1[-1]))
end1--; end1--;
while (beg2 != end2 && is_space[end2[-1]]) while (beg2 != end2 && is_space(end2[-1]))
end2--; end2--;
} }
while (beg1 != end1 && beg2 != end2) while (beg1 != end1 && beg2 != end2)
{ {
if (is_space[*beg1] && is_space[*beg2]) if (is_space(*beg1) && is_space(*beg2))
{ {
while (beg1 != end1 && is_space[*beg1]) while (beg1 != end1 && is_space(*beg1))
beg1++; beg1++;
while (beg2 != end2 && is_space[*beg2]) while (beg2 != end2 && is_space(*beg2))
beg2++; beg2++;
} }
else if (*beg1 == *beg2) else if (*beg1 == *beg2)
......
...@@ -194,7 +194,6 @@ struct pending_option ...@@ -194,7 +194,6 @@ struct pending_option
} while (0) } while (0)
#endif #endif
static void initialize_char_syntax PARAMS ((int));
static void print_help PARAMS ((void)); static void print_help PARAMS ((void));
static void path_include PARAMS ((cpp_reader *, static void path_include PARAMS ((cpp_reader *,
struct cpp_pending *, struct cpp_pending *,
...@@ -210,174 +209,57 @@ static void initialize_dependency_output PARAMS ((cpp_reader *)); ...@@ -210,174 +209,57 @@ static void initialize_dependency_output PARAMS ((cpp_reader *));
/* Last argument to append_include_chain: chain to use */ /* Last argument to append_include_chain: chain to use */
enum { QUOTE = 0, BRACKET, SYSTEM, AFTER }; enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
/* If gcc is in use (stage2/stage3) we can make these tables initialized /* If gcc is in use (stage2/stage3) we can make this table initialized data. */
data. */ #ifdef __STDC__
#define CAT(a, b) a##b
#else
#define CAT(a, b) a/**/b
#endif
#if HAVE_GCC_VERSION(2,7) #if HAVE_GCC_VERSION(2,7)
/* Table to tell if a character is legal as the second or later character #define TABLE(id) static inline void CAT(init_, id) PARAMS ((void)) {} \
of a C identifier. */ unsigned char id[256] = {
U_CHAR is_idchar[256] = #define s(p, v) [p] = v,
{ #define END };
['a'] = 1, ['b'] = 1, ['c'] = 1, ['d'] = 1, ['e'] = 1, ['f'] = 1, #else
['g'] = 1, ['h'] = 1, ['i'] = 1, ['j'] = 1, ['k'] = 1, ['l'] = 1, #define TABLE(id) unsigned char id[256] = { 0 }; \
['m'] = 1, ['n'] = 1, ['o'] = 1, ['p'] = 1, ['q'] = 1, ['r'] = 1, static void CAT(init_, id) PARAMS ((void)) { \
['s'] = 1, ['t'] = 1, ['u'] = 1, ['v'] = 1, ['w'] = 1, ['x'] = 1, unsigned char *x = id;
['y'] = 1, ['z'] = 1, #define s(p, v) x[p] = v;
#define END }
['A'] = 1, ['B'] = 1, ['C'] = 1, ['D'] = 1, ['E'] = 1, ['F'] = 1, #endif
['G'] = 1, ['H'] = 1, ['I'] = 1, ['J'] = 1, ['K'] = 1, ['L'] = 1,
['M'] = 1, ['N'] = 1, ['O'] = 1, ['P'] = 1, ['Q'] = 1, ['R'] = 1,
['S'] = 1, ['T'] = 1, ['U'] = 1, ['V'] = 1, ['W'] = 1, ['X'] = 1,
['Y'] = 1, ['Z'] = 1,
['1'] = 1, ['2'] = 1, ['3'] = 1, ['4'] = 1, ['5'] = 1, ['6'] = 1,
['7'] = 1, ['8'] = 1, ['9'] = 1, ['0'] = 1,
['_'] = 1,
};
/* Table to tell if a character is legal as the first character of #define A(x) s(x, ISidnum|ISidstart)
a C identifier. */ #define N(x) s(x, ISidnum|ISnumstart)
U_CHAR is_idstart[256] = #define H(x) s(x, IShspace|ISspace)
{ #define S(x) s(x, ISspace)
['a'] = 1, ['b'] = 1, ['c'] = 1, ['d'] = 1, ['e'] = 1, ['f'] = 1,
['g'] = 1, ['h'] = 1, ['i'] = 1, ['j'] = 1, ['k'] = 1, ['l'] = 1,
['m'] = 1, ['n'] = 1, ['o'] = 1, ['p'] = 1, ['q'] = 1, ['r'] = 1,
['s'] = 1, ['t'] = 1, ['u'] = 1, ['v'] = 1, ['w'] = 1, ['x'] = 1,
['y'] = 1, ['z'] = 1,
['A'] = 1, ['B'] = 1, ['C'] = 1, ['D'] = 1, ['E'] = 1, ['F'] = 1,
['G'] = 1, ['H'] = 1, ['I'] = 1, ['J'] = 1, ['K'] = 1, ['L'] = 1,
['M'] = 1, ['N'] = 1, ['O'] = 1, ['P'] = 1, ['Q'] = 1, ['R'] = 1,
['S'] = 1, ['T'] = 1, ['U'] = 1, ['V'] = 1, ['W'] = 1, ['X'] = 1,
['Y'] = 1, ['Z'] = 1,
['_'] = 1,
};
/* Table to tell if a character is horizontal space. TABLE (IStable)
\r is magical, so it is not in here. */ A('_')
U_CHAR is_hor_space[256] =
{
[' '] = 1, ['\t'] = 1, ['\v'] = 1, ['\f'] = 1,
};
/* table to tell if a character is horizontal or vertical space. */
U_CHAR is_space[256] =
{
[' '] = 1, ['\t'] = 1, ['\v'] = 1, ['\f'] = 1, ['\n'] = 1,
};
/* Table to handle trigraph conversion, which occurs before all other
processing, everywhere in the file. (This is necessary since one
of the trigraphs encodes backslash.) Note it's off by default.
from to from to from to
?? = # ?? ) ] ?? ! |
?? ( [ ?? ' ^ ?? > }
?? / \ ?? < { ?? - ~
There is not a space between the ?? and the third char. I put spaces
there to avoid warnings when compiling this file. */
U_CHAR trigraph_table[256] =
{
['='] = '#', [')'] = ']', ['!'] = '|',
['('] = '[', ['\''] = '^', ['>'] = '}',
['/'] = '\\', ['<'] = '{', ['-'] = '~',
};
/* This function will be entirely removed soon. */ A('a') A('b') A('c') A('d') A('e') A('f') A('g') A('h') A('i')
static inline void A('j') A('k') A('l') A('m') A('n') A('o') A('p') A('q') A('r')
initialize_char_syntax (dollar_in_ident) A('s') A('t') A('u') A('v') A('w') A('x') A('y') A('z')
int dollar_in_ident;
{
is_idchar['$'] = dollar_in_ident;
is_idstart['$'] = dollar_in_ident;
}
#else /* Not GCC. */ A('A') A('B') A('C') A('D') A('E') A('F') A('G') A('H') A('I')
A('J') A('K') A('L') A('M') A('N') A('O') A('P') A('Q') A('R')
A('S') A('T') A('U') A('V') A('W') A('X') A('Y') A('Z')
U_CHAR is_idchar[256] = { 0 }; N('1') N('2') N('3') N('4') N('5') N('6') N('7') N('8') N('9') N('0')
U_CHAR is_idstart[256] = { 0 };
U_CHAR is_hor_space[256] = { 0 };
U_CHAR is_space[256] = { 0 };
U_CHAR trigraph_table[256] = { 0 };
/* Initialize syntactic classifications of characters. */ H(' ') H('\t') H('\v') H('\f')
static void
initialize_char_syntax (dollar_in_ident) S('\n')
int dollar_in_ident; END
{
is_idstart['a'] = 1; is_idstart['b'] = 1; is_idstart['c'] = 1;
is_idstart['d'] = 1; is_idstart['e'] = 1; is_idstart['f'] = 1;
is_idstart['g'] = 1; is_idstart['h'] = 1; is_idstart['i'] = 1;
is_idstart['j'] = 1; is_idstart['k'] = 1; is_idstart['l'] = 1;
is_idstart['m'] = 1; is_idstart['n'] = 1; is_idstart['o'] = 1;
is_idstart['p'] = 1; is_idstart['q'] = 1; is_idstart['r'] = 1;
is_idstart['s'] = 1; is_idstart['t'] = 1; is_idstart['u'] = 1;
is_idstart['v'] = 1; is_idstart['w'] = 1; is_idstart['x'] = 1;
is_idstart['y'] = 1; is_idstart['z'] = 1;
is_idstart['A'] = 1; is_idstart['B'] = 1; is_idstart['C'] = 1;
is_idstart['D'] = 1; is_idstart['E'] = 1; is_idstart['F'] = 1;
is_idstart['G'] = 1; is_idstart['H'] = 1; is_idstart['I'] = 1;
is_idstart['J'] = 1; is_idstart['K'] = 1; is_idstart['L'] = 1;
is_idstart['M'] = 1; is_idstart['N'] = 1; is_idstart['O'] = 1;
is_idstart['P'] = 1; is_idstart['Q'] = 1; is_idstart['R'] = 1;
is_idstart['S'] = 1; is_idstart['T'] = 1; is_idstart['U'] = 1;
is_idstart['V'] = 1; is_idstart['W'] = 1; is_idstart['X'] = 1;
is_idstart['Y'] = 1; is_idstart['Z'] = 1;
is_idstart['_'] = 1;
is_idchar['a'] = 1; is_idchar['b'] = 1; is_idchar['c'] = 1;
is_idchar['d'] = 1; is_idchar['e'] = 1; is_idchar['f'] = 1;
is_idchar['g'] = 1; is_idchar['h'] = 1; is_idchar['i'] = 1;
is_idchar['j'] = 1; is_idchar['k'] = 1; is_idchar['l'] = 1;
is_idchar['m'] = 1; is_idchar['n'] = 1; is_idchar['o'] = 1;
is_idchar['p'] = 1; is_idchar['q'] = 1; is_idchar['r'] = 1;
is_idchar['s'] = 1; is_idchar['t'] = 1; is_idchar['u'] = 1;
is_idchar['v'] = 1; is_idchar['w'] = 1; is_idchar['x'] = 1;
is_idchar['y'] = 1; is_idchar['z'] = 1;
is_idchar['A'] = 1; is_idchar['B'] = 1; is_idchar['C'] = 1;
is_idchar['D'] = 1; is_idchar['E'] = 1; is_idchar['F'] = 1;
is_idchar['G'] = 1; is_idchar['H'] = 1; is_idchar['I'] = 1;
is_idchar['J'] = 1; is_idchar['K'] = 1; is_idchar['L'] = 1;
is_idchar['M'] = 1; is_idchar['N'] = 1; is_idchar['O'] = 1;
is_idchar['P'] = 1; is_idchar['Q'] = 1; is_idchar['R'] = 1;
is_idchar['S'] = 1; is_idchar['T'] = 1; is_idchar['U'] = 1;
is_idchar['V'] = 1; is_idchar['W'] = 1; is_idchar['X'] = 1;
is_idchar['Y'] = 1; is_idchar['Z'] = 1;
is_idchar['1'] = 1; is_idchar['2'] = 1; is_idchar['3'] = 1;
is_idchar['4'] = 1; is_idchar['5'] = 1; is_idchar['6'] = 1;
is_idchar['7'] = 1; is_idchar['8'] = 1; is_idchar['9'] = 1;
is_idchar['0'] = 1;
is_idchar['_'] = 1;
is_idchar['$'] = dollar_in_ident;
is_idstart['$'] = dollar_in_ident;
/* white space tables */
is_hor_space[' '] = 1;
is_hor_space['\t'] = 1;
is_hor_space['\v'] = 1;
is_hor_space['\f'] = 1;
is_space[' '] = 1;
is_space['\t'] = 1;
is_space['\v'] = 1;
is_space['\f'] = 1;
is_space['\n'] = 1;
/* trigraph conversion */
trigraph_table['='] = '#'; trigraph_table[')'] = ']';
trigraph_table['!'] = '|'; trigraph_table['('] = '[';
trigraph_table['\''] = '^'; trigraph_table['>'] = '}';
trigraph_table['/'] = '\\'; trigraph_table['<'] = '{';
trigraph_table['-'] = '~';
}
#endif /* Not GCC. */ #undef A
#undef N
#undef H
#undef S
#undef TABLE
#undef END
#undef s
#undef CAT
/* Given a colon-separated list of file names PATH, /* Given a colon-separated list of file names PATH,
add all the names to the search path for include files. */ add all the names to the search path for include files. */
...@@ -614,58 +496,89 @@ cpp_cleanup (pfile) ...@@ -614,58 +496,89 @@ cpp_cleanup (pfile)
} }
/* Initialize the built-in macros. */ /* This structure defines one built-in macro. A node of type TYPE will
static void be entered in the macro hash table under the name NAME, with value
initialize_builtins (pfile) VALUE (if any). FLAGS tweaks the behavior a little:
cpp_reader *pfile; DUMP write debug info for this macro
STDC define only if not -traditional
C89 define only if -lang-c89
C9X define only if -lang-c9x
ULP value is the global user_label_prefix (which can't be
put directly into the table).
*/
struct builtin
{ {
#define NAME(str) (const U_CHAR *)str, sizeof str - 1 const char *name;
cpp_install (pfile, NAME("__TIME__"), T_TIME, 0, -1); const char *value;
cpp_install (pfile, NAME("__DATE__"), T_DATE, 0, -1); unsigned short type;
cpp_install (pfile, NAME("__FILE__"), T_FILE, 0, -1); unsigned short flags;
cpp_install (pfile, NAME("__BASE_FILE__"), T_BASE_FILE, 0, -1); };
cpp_install (pfile, NAME("__LINE__"), T_SPECLINE, 0, -1); #define DUMP 0x01
cpp_install (pfile, NAME("__INCLUDE_LEVEL__"), T_INCLUDE_LEVEL, 0, -1); #define STDC 0x02
cpp_install (pfile, NAME("__VERSION__"), T_VERSION, 0, -1); #define C89 0x04
#define C9X 0x08
#define ULP 0x10
static const struct builtin builtin_array[] =
{
{ "__TIME__", 0, T_TIME, DUMP },
{ "__DATE__", 0, T_DATE, DUMP },
{ "__FILE__", 0, T_FILE, 0 },
{ "__BASE_FILE__", 0, T_BASE_FILE, DUMP },
{ "__LINE__", 0, T_SPECLINE, 0 },
{ "__INCLUDE_LEVEL__", 0, T_INCLUDE_LEVEL, 0 },
{ "__VERSION__", 0, T_VERSION, DUMP },
{ "__STDC__", 0, T_STDC, DUMP|STDC },
{ "__USER_LABEL_PREFIX__", 0, T_CONST, ULP },
{ "__REGISTER_PREFIX__", REGISTER_PREFIX, T_CONST, 0 },
{ "__HAVE_BUILTIN_SETJMP__", "1", T_CONST, 0 },
#ifndef NO_BUILTIN_SIZE_TYPE #ifndef NO_BUILTIN_SIZE_TYPE
cpp_install (pfile, NAME("__SIZE_TYPE__"), T_CONST, SIZE_TYPE, -1); { "__SIZE_TYPE__", SIZE_TYPE, T_CONST, DUMP },
#endif #endif
#ifndef NO_BUILTIN_PTRDIFF_TYPE #ifndef NO_BUILTIN_PTRDIFF_TYPE
cpp_install (pfile, NAME("__PTRDIFF_TYPE__ "), T_CONST, PTRDIFF_TYPE, -1); { "__PTRDIFF_TYPE__", PTRDIFF_TYPE, T_CONST, DUMP },
#endif #endif
cpp_install (pfile, NAME("__WCHAR_TYPE__"), T_CONST, WCHAR_TYPE, -1); { "__WCHAR_TYPE__", WCHAR_TYPE, T_CONST, DUMP },
cpp_install (pfile, NAME("__USER_LABEL_PREFIX__"), T_CONST, user_label_prefix, -1); { "__STDC_VERSION__", "199409L", T_CONST, DUMP|STDC|C89 },
cpp_install (pfile, NAME("__REGISTER_PREFIX__"), T_CONST, REGISTER_PREFIX, -1); { "__STDC_VERSION__", "199909L", T_CONST, DUMP|STDC|C9X },
cpp_install (pfile, NAME("__HAVE_BUILTIN_SETJMP__"), T_CONST, "1", -1); { 0, 0, 0, 0 }
if (!CPP_TRADITIONAL (pfile)) };
{
cpp_install (pfile, NAME("__STDC__"), T_STDC, 0, -1); /* Subroutine of cpp_start_read; reads the builtins table above and
#if 0 enters the macros into the hash table. */
if (CPP_OPTIONS (pfile)->c9x)
cpp_install (pfile, NAME("__STDC_VERSION__"),T_CONST, "199909L", -1);
else
#endif
cpp_install (pfile, NAME("__STDC_VERSION__"),T_CONST, "199409L", -1);
}
#undef NAME
if (CPP_OPTIONS (pfile)->debug_output) static void
initialize_builtins (pfile)
cpp_reader *pfile;
{
int len;
const struct builtin *b;
const char *val;
for(b = builtin_array; b->name; b++)
{ {
dump_special_to_buffer (pfile, "__BASE_FILE__"); if ((b->flags & STDC) && CPP_TRADITIONAL (pfile))
dump_special_to_buffer (pfile, "__VERSION__"); continue;
#ifndef NO_BUILTIN_SIZE_TYPE if ((b->flags & C89) && CPP_OPTIONS (pfile)->c9x)
dump_special_to_buffer (pfile, "__SIZE_TYPE__"); continue;
#endif if ((b->flags & C9X) && !CPP_OPTIONS (pfile)->c9x)
#ifndef NO_BUILTIN_PTRDIFF_TYPE continue;
dump_special_to_buffer (pfile, "__PTRDIFF_TYPE__");
#endif val = (b->flags & ULP) ? user_label_prefix : b->value;
dump_special_to_buffer (pfile, "__WCHAR_TYPE__"); len = strlen (b->name);
dump_special_to_buffer (pfile, "__DATE__");
dump_special_to_buffer (pfile, "__TIME__"); cpp_install (pfile, b->name, len, b->type, val, -1);
if (!CPP_TRADITIONAL (pfile)) if ((b->flags & DUMP) && CPP_OPTIONS (pfile)->debug_output)
dump_special_to_buffer (pfile, "__STDC__"); dump_special_to_buffer (pfile, b->name);
} }
} }
#undef DUMP
#undef STDC
#undef C89
#undef C9X
#undef ULP
/* Another subroutine of cpp_start_read. This one sets up to do /* Another subroutine of cpp_start_read. This one sets up to do
dependency-file output. */ dependency-file output. */
...@@ -802,7 +715,11 @@ cpp_start_read (pfile, fname) ...@@ -802,7 +715,11 @@ cpp_start_read (pfile, fname)
/* Now that we know dollars_in_ident, we can initialize the syntax /* Now that we know dollars_in_ident, we can initialize the syntax
tables. */ tables. */
initialize_char_syntax (opts->dollars_in_ident); init_IStable ();
/* XXX Get rid of code that depends on this, then IStable can
be truly const. */
if (opts->dollars_in_ident)
IStable['$'] = ISidstart|ISidnum;
/* Do partial setup of input buffer for the sake of generating /* Do partial setup of input buffer for the sake of generating
early #line directives (when -g is in effect). */ early #line directives (when -g is in effect). */
......
...@@ -25,8 +25,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ...@@ -25,8 +25,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "cpphash.h" #include "cpphash.h"
#include "intl.h" #include "intl.h"
#define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0) #define SKIP_WHITE_SPACE(p) do { while (is_hspace(*p)) p++; } while (0)
#define SKIP_ALL_WHITE_SPACE(p) do { while (is_space[*p]) p++; } while (0)
#define PEEKN(N) (CPP_BUFFER (pfile)->rlimit - CPP_BUFFER (pfile)->cur >= (N) ? CPP_BUFFER (pfile)->cur[N] : EOF) #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)) #define FORWARD(N) CPP_FORWARD (CPP_BUFFER (pfile), (N))
...@@ -411,7 +410,7 @@ cpp_skip_hspace (pfile) ...@@ -411,7 +410,7 @@ cpp_skip_hspace (pfile)
c = GETC(); c = GETC();
if (c == EOF) if (c == EOF)
return; return;
else if (is_hor_space[c]) else if (is_hspace(c))
{ {
if ((c == '\f' || c == '\v') && CPP_PEDANTIC (pfile)) if ((c == '\f' || c == '\v') && CPP_PEDANTIC (pfile))
cpp_pedwarn (pfile, "%s in preprocessing directive", cpp_pedwarn (pfile, "%s in preprocessing directive",
...@@ -596,36 +595,29 @@ pass_thru_directive (buf, len, pfile, keyword) ...@@ -596,36 +595,29 @@ pass_thru_directive (buf, len, pfile, keyword)
CPP_PUTS_Q (pfile, buf, len); CPP_PUTS_Q (pfile, buf, len);
} }
/* Check a purported macro name SYMNAME, and yield its length. /* Check a purported macro name SYMNAME, and yield its length. */
ASSERTION is nonzero if this is really for an assertion name. */
int int
check_macro_name (pfile, symname, assertion) check_macro_name (pfile, symname)
cpp_reader *pfile; cpp_reader *pfile;
const U_CHAR *symname; const U_CHAR *symname;
int assertion;
{ {
const U_CHAR *p; const U_CHAR *p;
int sym_length; int sym_length;
for (p = symname; is_idchar[*p]; p++) for (p = symname; is_idchar(*p); p++)
; ;
sym_length = p - symname; sym_length = p - symname;
if (sym_length == 0 if (sym_length == 0
|| (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"'))) || (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"')))
cpp_error (pfile, cpp_error (pfile, "invalid macro name");
assertion ? "invalid assertion name" : "invalid macro name"); else if (!is_idstart(*symname)
else if (!is_idstart[*symname]
|| (! strncmp (symname, "defined", 7) && sym_length == 7)) { || (! strncmp (symname, "defined", 7) && sym_length == 7)) {
U_CHAR *msg; /* what pain... */ U_CHAR *msg; /* what pain... */
msg = (U_CHAR *) alloca (sym_length + 1); msg = (U_CHAR *) alloca (sym_length + 1);
bcopy (symname, msg, sym_length); bcopy (symname, msg, sym_length);
msg[sym_length] = 0; msg[sym_length] = 0;
cpp_error (pfile, cpp_error (pfile, "invalid macro name `%s'", msg);
(assertion
? "invalid assertion name `%s'"
: "invalid macro name `%s'"),
msg);
} }
return sym_length; return sym_length;
} }
...@@ -1354,7 +1346,7 @@ do_line (pfile, keyword) ...@@ -1354,7 +1346,7 @@ do_line (pfile, keyword)
if (strcmp (fname, ip->nominal_fname)) if (strcmp (fname, ip->nominal_fname))
{ {
char *newname, *oldname; const char *newname, *oldname;
if (!strcmp (fname, ip->fname)) if (!strcmp (fname, ip->fname))
newname = ip->fname; newname = ip->fname;
else if (ip->last_nominal_fname else if (ip->last_nominal_fname
...@@ -1370,7 +1362,7 @@ do_line (pfile, keyword) ...@@ -1370,7 +1362,7 @@ do_line (pfile, keyword)
&& ip->last_nominal_fname != oldname && ip->last_nominal_fname != oldname
&& ip->last_nominal_fname != newname && ip->last_nominal_fname != newname
&& ip->last_nominal_fname != ip->fname) && ip->last_nominal_fname != ip->fname)
free (ip->last_nominal_fname); free ((void *) ip->last_nominal_fname);
if (newname == ip->fname) if (newname == ip->fname)
ip->last_nominal_fname = NULL; ip->last_nominal_fname = NULL;
...@@ -1415,7 +1407,7 @@ do_undef (pfile, keyword) ...@@ -1415,7 +1407,7 @@ do_undef (pfile, keyword)
cpp_skip_hspace (pfile); cpp_skip_hspace (pfile);
c = GETC(); c = GETC();
if (! is_idstart[c]) if (! is_idstart(c))
{ {
cpp_error (pfile, "token after #undef is not an identifier"); cpp_error (pfile, "token after #undef is not an identifier");
skip_rest_of_line (pfile); skip_rest_of_line (pfile);
...@@ -1440,7 +1432,7 @@ do_undef (pfile, keyword) ...@@ -1440,7 +1432,7 @@ do_undef (pfile, keyword)
CPP_SET_WRITTEN (pfile, here); 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) while ((hp = cpp_lookup (pfile, name, sym_length, -1)) != NULL)
{ {
...@@ -1643,10 +1635,10 @@ do_pragma (pfile, keyword) ...@@ -1643,10 +1635,10 @@ do_pragma (pfile, keyword)
{ {
U_CHAR *end = syms; U_CHAR *end = syms;
while (is_idchar[*end]) while (is_idchar(*end))
end++; end++;
if (!is_hor_space[*end] && *end != '\0') if (!is_hspace(*end) && *end != '\0')
{ {
cpp_error (pfile, "invalid #pragma poison directive"); cpp_error (pfile, "invalid #pragma poison directive");
return 1; return 1;
...@@ -1924,7 +1916,7 @@ do_xifdef (pfile, keyword) ...@@ -1924,7 +1916,7 @@ do_xifdef (pfile, keyword)
else { else {
U_CHAR *cp = buf; U_CHAR *cp = buf;
fprintf (pcp_outfile, "#undef "); fprintf (pcp_outfile, "#undef ");
while (is_idchar[*cp]) /* Ick! */ while (is_idchar(*cp)) /* Ick! */
fputc (*cp++, pcp_outfile); fputc (*cp++, pcp_outfile);
putc ('\n', pcp_outfile); putc ('\n', pcp_outfile);
} }
...@@ -2573,7 +2565,7 @@ cpp_get_token (pfile) ...@@ -2573,7 +2565,7 @@ cpp_get_token (pfile)
c = PEEKC (); c = PEEKC ();
if (c == EOF) if (c == EOF)
break; break;
if (!is_idchar[c] && c != '.' if (!is_idchar(c) && c != '.'
&& ((c2 != 'e' && c2 != 'E' && ((c2 != 'e' && c2 != 'E'
&& ((c2 != 'p' && c2 != 'P') || CPP_C89 (pfile))) && ((c2 != 'p' && c2 != 'P') || CPP_C89 (pfile)))
|| (c != '+' && c != '-'))) || (c != '+' && c != '-')))
...@@ -2598,7 +2590,7 @@ cpp_get_token (pfile) ...@@ -2598,7 +2590,7 @@ cpp_get_token (pfile)
c = GETC(); c = GETC();
if (c == EOF) if (c == EOF)
goto chill_number_eof; goto chill_number_eof;
if (!is_idchar[c]) if (!is_idchar(c))
break; break;
CPP_PUTC (pfile, c); CPP_PUTC (pfile, c);
} }
...@@ -2720,7 +2712,7 @@ cpp_get_token (pfile) ...@@ -2720,7 +2712,7 @@ cpp_get_token (pfile)
{ {
CPP_PUTC (pfile, c); CPP_PUTC (pfile, c);
c = PEEKC (); c = PEEKC ();
if (c == EOF || !is_hor_space[c]) if (c == EOF || !is_hspace(c))
break; break;
FORWARD(1); FORWARD(1);
} }
...@@ -2816,7 +2808,7 @@ parse_name (pfile, c) ...@@ -2816,7 +2808,7 @@ parse_name (pfile, c)
{ {
for (;;) for (;;)
{ {
if (! is_idchar[c]) if (! is_idchar(c))
{ {
FORWARD (-1); FORWARD (-1);
break; break;
...@@ -2939,7 +2931,7 @@ parse_assertion (pfile) ...@@ -2939,7 +2931,7 @@ parse_assertion (pfile)
int c, dropwhite; int c, dropwhite;
cpp_skip_hspace (pfile); cpp_skip_hspace (pfile);
c = PEEKC(); c = PEEKC();
if (! is_idstart[c]) if (! is_idstart(c))
{ {
cpp_error (pfile, "assertion predicate is not an identifier"); cpp_error (pfile, "assertion predicate is not an identifier");
return 0; return 0;
...@@ -2951,7 +2943,7 @@ parse_assertion (pfile) ...@@ -2951,7 +2943,7 @@ parse_assertion (pfile)
c = PEEKC(); c = PEEKC();
if (c != '(') if (c != '(')
{ {
if (is_hor_space[c] || c == '\r') if (is_hspace(c) || c == '\r')
cpp_skip_hspace (pfile); cpp_skip_hspace (pfile);
c = PEEKC(); c = PEEKC();
} }
...@@ -2963,7 +2955,7 @@ parse_assertion (pfile) ...@@ -2963,7 +2955,7 @@ parse_assertion (pfile)
dropwhite = 1; dropwhite = 1;
while ((c = GETC()) != ')') while ((c = GETC()) != ')')
{ {
if (is_hor_space[c]) if (is_space(c))
{ {
if (! dropwhite) if (! dropwhite)
{ {
......
...@@ -96,11 +96,11 @@ struct cpp_buffer ...@@ -96,11 +96,11 @@ struct cpp_buffer
struct cpp_buffer *prev; struct cpp_buffer *prev;
/* Real filename. (Alias to ->ihash->fname, obsolete). */ /* Real filename. (Alias to ->ihash->fname, obsolete). */
char *fname; const char *fname;
/* Filename specified with #line command. */ /* Filename specified with #line command. */
char *nominal_fname; const char *nominal_fname;
/* Last filename specified with #line command. */ /* Last filename specified with #line command. */
char *last_nominal_fname; const char *last_nominal_fname;
/* Actual directory of this file, used only for "" includes */ /* Actual directory of this file, used only for "" includes */
struct file_name_list *actual_dir; struct file_name_list *actual_dir;
...@@ -550,11 +550,12 @@ struct include_hash ...@@ -550,11 +550,12 @@ struct include_hash
/* Location of the file in the include search path. /* Location of the file in the include search path.
Used for include_next */ Used for include_next */
struct file_name_list *foundhere; struct file_name_list *foundhere;
char *name; /* (partial) pathname of file */ const char *name; /* (partial) pathname of file */
char *nshort; /* name of file as referenced in #include */ const char *nshort; /* name of file as referenced in #include */
const char *control_macro; /* macro, if any, preventing reinclusion - see const char *control_macro; /* macro, if any, preventing reinclusion -
redundant_include_p */ see redundant_include_p */
char *buf, *limit; /* for file content cache, not yet implemented */ char *buf, *limit; /* for file content cache,
not yet implemented */
}; };
/* Name under which this program was invoked. */ /* Name under which this program was invoked. */
...@@ -610,7 +611,7 @@ typedef struct macrodef MACRODEF; ...@@ -610,7 +611,7 @@ typedef struct macrodef MACRODEF;
struct macrodef struct macrodef
{ {
struct definition *defn; struct definition *defn;
unsigned char *symnam; const U_CHAR *symnam;
int symlen; int symlen;
}; };
...@@ -665,18 +666,30 @@ struct definition { ...@@ -665,18 +666,30 @@ struct definition {
} args; } args;
}; };
/* These tables are not really `const', but they are only modified at /* Character classes.
If the definition of `numchar' looks odd to you, please look up the
definition of a pp-number in the C standard [section 6.4.8 of C99] */
#define ISidnum 0x01 /* a-zA-Z0-9_ */
#define ISidstart 0x02 /* _a-zA-Z */
#define ISnumstart 0x04 /* 0-9 */
#define IShspace 0x08 /* ' ' \t \f \v */
#define ISspace 0x10 /* ' ' \t \f \v \n */
#define is_idchar(x) (IStable[x] & ISidnum)
#define is_numchar(x) (IStable[x] & ISidnum)
#define is_idstart(x) (IStable[x] & ISidstart)
#define is_numstart(x) (IStable[x] & ISnumstart)
#define is_hspace(x) (IStable[x] & IShspace)
#define is_space(x) (IStable[x] & ISspace)
/* This table is not really `const', but it is only modified at
initialization time, in a separate translation unit from the rest initialization time, in a separate translation unit from the rest
of the library. We let the rest of the library think they are `const' of the library. We let the rest of the library think it is `const'
to get better code and some additional sanity checks. */ to get better code and some additional compile-time checks. */
#ifndef FAKE_CONST #ifndef FAKE_CONST
#define FAKE_CONST const #define FAKE_CONST const
#endif #endif
extern FAKE_CONST unsigned char is_idstart[256]; extern FAKE_CONST unsigned char IStable[256];
extern FAKE_CONST unsigned char is_idchar[256];
extern FAKE_CONST unsigned char is_hor_space[256];
extern FAKE_CONST unsigned char is_space[256];
extern FAKE_CONST unsigned char trigraph_table[256];
#undef FAKE_CONST #undef FAKE_CONST
/* Stack of conditionals currently in progress /* Stack of conditionals currently in progress
...@@ -684,7 +697,7 @@ extern FAKE_CONST unsigned char trigraph_table[256]; ...@@ -684,7 +697,7 @@ extern FAKE_CONST unsigned char trigraph_table[256];
struct if_stack { struct if_stack {
struct if_stack *next; /* for chaining to the next stack frame */ struct if_stack *next; /* for chaining to the next stack frame */
char *fname; /* copied from input when frame is made */ const char *fname; /* copied from input when frame is made */
int lineno; /* similarly */ int lineno; /* similarly */
int if_succeeded; /* true if a leg of this if-group int if_succeeded; /* true if a leg of this if-group
has been passed through rescan */ has been passed through rescan */
...@@ -739,7 +752,7 @@ extern void quote_string PARAMS ((cpp_reader *, const char *)); ...@@ -739,7 +752,7 @@ extern void quote_string PARAMS ((cpp_reader *, const char *));
extern void cpp_expand_to_buffer PARAMS ((cpp_reader *, const U_CHAR *, extern void cpp_expand_to_buffer PARAMS ((cpp_reader *, const U_CHAR *,
int)); int));
extern void cpp_scan_buffer PARAMS ((cpp_reader *)); extern void cpp_scan_buffer PARAMS ((cpp_reader *));
extern int check_macro_name PARAMS ((cpp_reader *, const U_CHAR *, int)); extern int check_macro_name PARAMS ((cpp_reader *, const U_CHAR *));
/* Last arg to output_line_command. */ /* Last arg to output_line_command. */
enum file_change_code {same_file, enter_file, leave_file}; enum file_change_code {same_file, enter_file, leave_file};
......
...@@ -117,6 +117,8 @@ main (argc, argv) ...@@ -117,6 +117,8 @@ main (argc, argv)
< CPP_WRITTEN (&parse_in)) < CPP_WRITTEN (&parse_in))
cpp_pfatal_with_name (&parse_in, opts->out_fname); cpp_pfatal_with_name (&parse_in, opts->out_fname);
cpp_cleanup (&parse_in);
if (parse_in.errors) if (parse_in.errors)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
return (SUCCESS_EXIT_CODE); return (SUCCESS_EXIT_CODE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment