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.h | |
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.h')
-rw-r--r-- | gcc/cpplib.h | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 3880f2c..f18a61d 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -96,11 +96,11 @@ struct cpp_buffer struct cpp_buffer *prev; /* Real filename. (Alias to ->ihash->fname, obsolete). */ - char *fname; + const char *fname; /* Filename specified with #line command. */ - char *nominal_fname; + const char *nominal_fname; /* Last filename specified with #line command. */ - char *last_nominal_fname; + const char *last_nominal_fname; /* Actual directory of this file, used only for "" includes */ struct file_name_list *actual_dir; @@ -550,11 +550,12 @@ struct include_hash /* Location of the file in the include search path. Used for include_next */ struct file_name_list *foundhere; - char *name; /* (partial) pathname of file */ - char *nshort; /* name of file as referenced in #include */ - const char *control_macro; /* macro, if any, preventing reinclusion - see - redundant_include_p */ - char *buf, *limit; /* for file content cache, not yet implemented */ + const char *name; /* (partial) pathname of file */ + const char *nshort; /* name of file as referenced in #include */ + const char *control_macro; /* macro, if any, preventing reinclusion - + see redundant_include_p */ + char *buf, *limit; /* for file content cache, + not yet implemented */ }; /* Name under which this program was invoked. */ @@ -610,7 +611,7 @@ typedef struct macrodef MACRODEF; struct macrodef { struct definition *defn; - unsigned char *symnam; + const U_CHAR *symnam; int symlen; }; @@ -665,18 +666,30 @@ struct definition { } 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 - of the library. We let the rest of the library think they are `const' - to get better code and some additional sanity checks. */ + of the library. We let the rest of the library think it is `const' + to get better code and some additional compile-time checks. */ #ifndef FAKE_CONST #define FAKE_CONST const #endif -extern FAKE_CONST unsigned char is_idstart[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]; +extern FAKE_CONST unsigned char IStable[256]; #undef FAKE_CONST /* Stack of conditionals currently in progress @@ -684,7 +697,7 @@ extern FAKE_CONST unsigned char trigraph_table[256]; struct if_stack { 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 if_succeeded; /* true if a leg of this if-group has been passed through rescan */ @@ -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 *, int)); 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. */ enum file_change_code {same_file, enter_file, leave_file}; |