mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-26 17:41:35 +08:00
cpplib.c (initialize_char_syntax): Use ISALPHA and ISALNUM so it'll work on non-ASCII platforms.
1998-12-07 Zack Weinberg <zack@rabi.phys.columbia.edu> * cpplib.c (initialize_char_syntax): Use ISALPHA and ISALNUM so it'll work on non-ASCII platforms. Always consider $ an identifier character. Take no arguments. (cpp_reader_init): Call initialize_char_syntax with no arguments. (cpp_start_read): Don't call initialize_char_syntax again. Clear is_idchar['$'] and is_idstart['$'] if not opts->dollars_in_ident. * cpplib.h (struct cpp_reader): Replace void *data element by cpp_options *opts. Rearrange elements to make gdb printout less annoying (put buffer stack at end). (CPP_OPTIONS): Get rid of now-unnecessary cast. * cppmain.c: s/data/opts/ when initializing cpp_reader structure. * c-decl.c: Likewise. * objc/objc-act.c: Likewise. * fix-header.c: Likewise. From-SVN: r24154
This commit is contained in:
parent
f1a86df6cb
commit
c50bca0894
@ -1,4 +1,26 @@
|
|||||||
1998-11-26 01:17 -0500 Zack Weinberg <zack@rabi.phys.columbia.edu>
|
1998-12-07 Zack Weinberg <zack@rabi.phys.columbia.edu>
|
||||||
|
|
||||||
|
* cpplib.c (initialize_char_syntax): Use ISALPHA and ISALNUM
|
||||||
|
so it'll work on non-ASCII platforms. Always consider $ an
|
||||||
|
identifier character. Take no arguments.
|
||||||
|
(cpp_reader_init): Call initialize_char_syntax with no
|
||||||
|
arguments.
|
||||||
|
(cpp_start_read): Don't call initialize_char_syntax again.
|
||||||
|
Clear is_idchar['$'] and is_idstart['$'] if not
|
||||||
|
opts->dollars_in_ident.
|
||||||
|
|
||||||
|
* cpplib.h (struct cpp_reader): Replace void *data element by
|
||||||
|
cpp_options *opts. Rearrange elements to make gdb printout
|
||||||
|
less annoying (put buffer stack at end).
|
||||||
|
(CPP_OPTIONS): Get rid of now-unnecessary cast.
|
||||||
|
|
||||||
|
* cppmain.c: s/data/opts/ when initializing cpp_reader
|
||||||
|
structure.
|
||||||
|
* c-decl.c: Likewise.
|
||||||
|
* objc/objc-act.c: Likewise.
|
||||||
|
* fix-header.c: Likewise.
|
||||||
|
|
||||||
|
1998-12-07 Zack Weinberg <zack@rabi.phys.columbia.edu>
|
||||||
|
|
||||||
* cpplib.h (struct cpp_buffer): Replace dir and dlen members
|
* cpplib.h (struct cpp_buffer): Replace dir and dlen members
|
||||||
with a struct file_name_list pointer.
|
with a struct file_name_list pointer.
|
||||||
|
@ -618,7 +618,7 @@ c_decode_option (argc, argv)
|
|||||||
if (! cpp_initialized)
|
if (! cpp_initialized)
|
||||||
{
|
{
|
||||||
cpp_reader_init (&parse_in);
|
cpp_reader_init (&parse_in);
|
||||||
parse_in.data = &parse_options;
|
parse_in.opts = &parse_options;
|
||||||
cpp_options_init (&parse_options);
|
cpp_options_init (&parse_options);
|
||||||
cpp_initialized = 1;
|
cpp_initialized = 1;
|
||||||
}
|
}
|
||||||
|
36
gcc/cpplib.c
36
gcc/cpplib.c
@ -169,7 +169,7 @@ static char *my_strerror PROTO ((int));
|
|||||||
static void make_assertion PROTO ((cpp_reader *, char *, U_CHAR *));
|
static void make_assertion PROTO ((cpp_reader *, char *, U_CHAR *));
|
||||||
static void path_include PROTO ((cpp_reader *, char *));
|
static void path_include PROTO ((cpp_reader *, char *));
|
||||||
static void initialize_builtins PROTO ((cpp_reader *));
|
static void initialize_builtins PROTO ((cpp_reader *));
|
||||||
static void initialize_char_syntax PROTO ((struct cpp_options *));
|
static void initialize_char_syntax PROTO ((void));
|
||||||
#if 0
|
#if 0
|
||||||
static void trigraph_pcp ();
|
static void trigraph_pcp ();
|
||||||
#endif
|
#endif
|
||||||
@ -340,10 +340,8 @@ U_CHAR is_hor_space[256] = { 0 };
|
|||||||
U_CHAR is_space[256] = { 0 };
|
U_CHAR is_space[256] = { 0 };
|
||||||
|
|
||||||
/* Initialize syntactic classifications of characters. */
|
/* Initialize syntactic classifications of characters. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
initialize_char_syntax (opts)
|
initialize_char_syntax ()
|
||||||
struct cpp_options *opts;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
@ -352,19 +350,20 @@ initialize_char_syntax (opts)
|
|||||||
* faster than saying (is_alpha (c) || c == '_'), etc.
|
* faster than saying (is_alpha (c) || c == '_'), etc.
|
||||||
* Set up these things before calling any routines tthat
|
* Set up these things before calling any routines tthat
|
||||||
* refer to them.
|
* refer to them.
|
||||||
|
* XXX We should setlocale(LC_CTYPE, "C") here for safety.
|
||||||
*/
|
*/
|
||||||
for (i = 'a'; i <= 'z'; i++) {
|
for (i = 0; i < 256; i++)
|
||||||
is_idchar[i - 'a' + 'A'] = 1;
|
{
|
||||||
is_idchar[i] = 1;
|
is_idchar[i] = ISALNUM (i);
|
||||||
is_idstart[i - 'a' + 'A'] = 1;
|
is_idstart[i] = ISALPHA (i);
|
||||||
is_idstart[i] = 1;
|
|
||||||
}
|
}
|
||||||
for (i = '0'; i <= '9'; i++)
|
|
||||||
is_idchar[i] = 1;
|
|
||||||
is_idchar['_'] = 1;
|
is_idchar['_'] = 1;
|
||||||
is_idstart['_'] = 1;
|
is_idstart['_'] = 1;
|
||||||
is_idchar['$'] = opts->dollars_in_ident;
|
|
||||||
is_idstart['$'] = opts->dollars_in_ident;
|
/* These will be reset later if -$ is in effect. */
|
||||||
|
is_idchar['$'] = 1;
|
||||||
|
is_idstart['$'] = 1;
|
||||||
|
|
||||||
/* horizontal space table */
|
/* horizontal space table */
|
||||||
is_hor_space[' '] = 1;
|
is_hor_space[' '] = 1;
|
||||||
@ -595,9 +594,8 @@ cpp_options_init (opts)
|
|||||||
opts->in_fname = NULL;
|
opts->in_fname = NULL;
|
||||||
opts->out_fname = NULL;
|
opts->out_fname = NULL;
|
||||||
|
|
||||||
/* Initialize is_idchar to allow $. */
|
|
||||||
opts->dollars_in_ident = 1;
|
opts->dollars_in_ident = 1;
|
||||||
initialize_char_syntax (opts);
|
initialize_char_syntax ();
|
||||||
|
|
||||||
opts->no_line_commands = 0;
|
opts->no_line_commands = 0;
|
||||||
opts->no_trigraphs = 1;
|
opts->no_trigraphs = 1;
|
||||||
@ -4837,6 +4835,11 @@ cpp_start_read (pfile, fname)
|
|||||||
variable specifies other defaults. */
|
variable specifies other defaults. */
|
||||||
struct default_include *include_defaults = include_defaults_array;
|
struct default_include *include_defaults = include_defaults_array;
|
||||||
|
|
||||||
|
/* Now that we know dollars_in_ident for real,
|
||||||
|
reset is_idchar/is_idstart. */
|
||||||
|
is_idchar['$'] = opts->dollars_in_ident;
|
||||||
|
is_idstart['$'] = opts->dollars_in_ident;
|
||||||
|
|
||||||
/* Add dirs from CPATH after dirs from -I. */
|
/* Add dirs from CPATH after dirs from -I. */
|
||||||
/* There seems to be confusion about what CPATH should do,
|
/* There seems to be confusion about what CPATH should do,
|
||||||
so for the moment it is not documented. */
|
so for the moment it is not documented. */
|
||||||
@ -4847,9 +4850,6 @@ cpp_start_read (pfile, fname)
|
|||||||
if (p != 0 && ! opts->no_standard_includes)
|
if (p != 0 && ! opts->no_standard_includes)
|
||||||
path_include (pfile, p);
|
path_include (pfile, p);
|
||||||
|
|
||||||
/* Now that dollars_in_ident is known, initialize is_idchar. */
|
|
||||||
initialize_char_syntax (opts);
|
|
||||||
|
|
||||||
/* 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). */
|
||||||
fp = cpp_push_buffer (pfile, NULL, 0);
|
fp = cpp_push_buffer (pfile, NULL, 0);
|
||||||
|
17
gcc/cpplib.h
17
gcc/cpplib.h
@ -156,13 +156,11 @@ typedef struct assertion_hashnode ASSERTION_HASHNODE;
|
|||||||
Applying cpp_get_token repeatedly yields a stream of pre-processor
|
Applying cpp_get_token repeatedly yields a stream of pre-processor
|
||||||
tokens. Usually, there is only one cpp_reader object active. */
|
tokens. Usually, there is only one cpp_reader object active. */
|
||||||
|
|
||||||
struct cpp_reader {
|
struct cpp_reader
|
||||||
|
{
|
||||||
parse_underflow_t get_token;
|
parse_underflow_t get_token;
|
||||||
cpp_buffer *buffer;
|
cpp_buffer *buffer;
|
||||||
cpp_buffer buffer_stack[CPP_STACK_MAX];
|
cpp_options *opts;
|
||||||
|
|
||||||
int errors; /* Error counter for exit code */
|
|
||||||
void *data;
|
|
||||||
|
|
||||||
/* A buffer used for both for cpp_get_token's output, and also internally. */
|
/* A buffer used for both for cpp_get_token's output, and also internally. */
|
||||||
unsigned char *token_buffer;
|
unsigned char *token_buffer;
|
||||||
@ -171,6 +169,9 @@ struct cpp_reader {
|
|||||||
/* End of the written part of token_buffer. */
|
/* End of the written part of token_buffer. */
|
||||||
unsigned char *limit;
|
unsigned char *limit;
|
||||||
|
|
||||||
|
/* Error counter for exit code */
|
||||||
|
int errors;
|
||||||
|
|
||||||
/* Line where a newline was first seen in a string constant. */
|
/* Line where a newline was first seen in a string constant. */
|
||||||
int multiline_string_line;
|
int multiline_string_line;
|
||||||
|
|
||||||
@ -247,6 +248,8 @@ struct cpp_reader {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
~cpp_reader () { cpp_cleanup (this); }
|
~cpp_reader () { cpp_cleanup (this); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
cpp_buffer buffer_stack[CPP_STACK_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CPP_FATAL_LIMIT 1000
|
#define CPP_FATAL_LIMIT 1000
|
||||||
@ -288,14 +291,14 @@ struct cpp_reader {
|
|||||||
#define CPP_ADJUST_WRITTEN(PFILE,DELTA) ((PFILE)->limit += (DELTA))
|
#define CPP_ADJUST_WRITTEN(PFILE,DELTA) ((PFILE)->limit += (DELTA))
|
||||||
#define CPP_SET_WRITTEN(PFILE,N) ((PFILE)->limit = (PFILE)->token_buffer + (N))
|
#define CPP_SET_WRITTEN(PFILE,N) ((PFILE)->limit = (PFILE)->token_buffer + (N))
|
||||||
|
|
||||||
#define CPP_OPTIONS(PFILE) ((cpp_options *) (PFILE)->data)
|
#define CPP_OPTIONS(PFILE) ((PFILE)->opts)
|
||||||
|
|
||||||
#define CPP_BUFFER(PFILE) ((PFILE)->buffer)
|
#define CPP_BUFFER(PFILE) ((PFILE)->buffer)
|
||||||
#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)+1)
|
#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)+1)
|
||||||
/* The bottom of the buffer stack. */
|
/* The bottom of the buffer stack. */
|
||||||
#define CPP_NULL_BUFFER(PFILE) (&(PFILE)->buffer_stack[CPP_STACK_MAX])
|
#define CPP_NULL_BUFFER(PFILE) (&(PFILE)->buffer_stack[CPP_STACK_MAX])
|
||||||
|
|
||||||
/* Pointed to by cpp_reader::data. */
|
/* Pointed to by cpp_reader.opts. */
|
||||||
struct cpp_options {
|
struct cpp_options {
|
||||||
char *in_fname;
|
char *in_fname;
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ main (argc, argv)
|
|||||||
progname = p;
|
progname = p;
|
||||||
|
|
||||||
cpp_reader_init (&parse_in);
|
cpp_reader_init (&parse_in);
|
||||||
parse_in.data = opts;
|
parse_in.opts = opts;
|
||||||
|
|
||||||
cpp_options_init (opts);
|
cpp_options_init (opts);
|
||||||
|
|
||||||
|
@ -632,7 +632,7 @@ read_scan_file (in_fname, argc, argv)
|
|||||||
obstack_init (&scan_file_obstack);
|
obstack_init (&scan_file_obstack);
|
||||||
|
|
||||||
cpp_reader_init (&scan_in);
|
cpp_reader_init (&scan_in);
|
||||||
scan_in.data = &scan_options;
|
scan_in.opts = &scan_options;
|
||||||
cpp_options_init (&scan_options);
|
cpp_options_init (&scan_options);
|
||||||
i = cpp_handle_options (&scan_in, argc, argv);
|
i = cpp_handle_options (&scan_in, argc, argv);
|
||||||
if (i < argc && ! CPP_FATAL_ERRORS (&scan_in))
|
if (i < argc && ! CPP_FATAL_ERRORS (&scan_in))
|
||||||
|
@ -694,7 +694,7 @@ lang_decode_option (argc, argv)
|
|||||||
if (! cpp_initialized)
|
if (! cpp_initialized)
|
||||||
{
|
{
|
||||||
cpp_reader_init (&parse_in);
|
cpp_reader_init (&parse_in);
|
||||||
parse_in.data = &parse_options;
|
parse_in.opts = &parse_options;
|
||||||
cpp_options_init (&parse_options);
|
cpp_options_init (&parse_options);
|
||||||
cpp_initialized = 1;
|
cpp_initialized = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user