diff options
author | Zack Weinberg <zack@midnite.ec.rhno.columbia.edu> | 1999-01-26 09:12:47 +0000 |
---|---|---|
committer | Dave Brolley <brolley@gcc.gnu.org> | 1999-01-26 04:12:47 -0500 |
commit | 554fbeef31814272ba1b41d16669e372df3123b8 (patch) | |
tree | 3123f9a18afb9afd6a268cc6ba587e9baa25bf6e /gcc/cpplib.c | |
parent | 0034cf7299679aa804e365e087d390b9cabb646c (diff) | |
download | gcc-554fbeef31814272ba1b41d16669e372df3123b8.zip gcc-554fbeef31814272ba1b41d16669e372df3123b8.tar.gz gcc-554fbeef31814272ba1b41d16669e372df3123b8.tar.bz2 |
cppfiles.c (safe_read): Deleted.
1999-01-26 12:11 -0500 Zack Weinberg <zack@midnite.ec.rhno.columbia.edu>
* cppfiles.c (safe_read): Deleted.
(read_and_prescan): New function, replaces safe_read, converts
and/or warns about trigraphs, silently converts odd line
terminators (\r, \n\r, \r\n). Warns about no newline at EOF.
(finclude): Use read_and_prescan; turn off nonblocking mode on
the input descriptor; remove file-size-examination and
no-newline-at-EOF gunk which is longer necessary; be more
careful about checking that we've been handed a legitimate
file to read (only real files, pipes, and ttys are acceptable).
* cpplib.h (cpp_options): Rename no_trigraphs flag to
`trigraphs' and invert its sense.
(trigraph_table): Declare.
(cpp_warning_with_line): Prototype.
* cpplib.c: Remove all references to trigraph_pcp. Define
trigraph_table; initialize it in initialize_char_syntax. Open
files in nonblocking mode. s/no_trigraphs/trigraphs/
throughout, and invert sense. Put cpp_warning_with_line back
in and export it.
From-SVN: r24870
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r-- | gcc/cpplib.c | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 8aa20c4..df2dbc7 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -130,9 +130,6 @@ static void make_assertion PROTO ((cpp_reader *, char *, U_CHAR *)); static void path_include PROTO ((cpp_reader *, char *)); static void initialize_builtins PROTO ((cpp_reader *)); static void initialize_char_syntax PROTO ((void)); -#if 0 -static void trigraph_pcp (); -#endif static void validate_else PROTO ((cpp_reader *, char *)); static int comp_def_part PROTO ((int, U_CHAR *, int, U_CHAR *, int, int)); @@ -290,6 +287,18 @@ U_CHAR is_idstart[256] = { 0 }; U_CHAR is_hor_space[256] = { 0 }; /* table to tell if c is horizontal or vertical space. */ U_CHAR is_space[256] = { 0 }; +/* 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] = { 0 }; /* Initialize syntactic classifications of characters. */ static void @@ -330,8 +339,14 @@ initialize_char_syntax () is_space['\f'] = 1; is_space['\n'] = 1; is_space['\r'] = 1; -} + /* trigraph conversion */ + trigraph_table['='] = '#'; trigraph_table[')'] = ']'; + trigraph_table['!'] = '|'; trigraph_table['('] = '['; + trigraph_table['\''] = '^'; trigraph_table['>'] = '}'; + trigraph_table['/'] = '\\'; trigraph_table['<'] = '{'; + trigraph_table['-'] = '~'; +} /* Place into PFILE a quoted string representing the string SRC. Caller must reserve enough space in pfile->token_buffer. */ @@ -554,7 +569,7 @@ cpp_options_init (opts) initialize_char_syntax (); opts->no_line_commands = 0; - opts->no_trigraphs = 1; + opts->trigraphs = 0; opts->put_out_comments = 0; opts->print_include_names = 0; opts->dump_macros = dump_none; @@ -4953,7 +4968,7 @@ cpp_start_read (pfile, fname) if (fname == NULL || *fname == 0) { fname = ""; f = 0; - } else if ((f = open (fname, O_RDONLY, 0666)) < 0) + } else if ((f = open (fname, O_RDONLY|O_NONBLOCK|O_NOCTTY, 0666)) < 0) cpp_pfatal_with_name (pfile, fname); /* -MG doesn't select the form of output and must be specified with one of @@ -5075,23 +5090,6 @@ cpp_start_read (pfile, fname) } } -#if 0 - /* Make sure data ends with a newline. And put a null after it. */ - - if ((fp->length > 0 && fp->buf[fp->length - 1] != '\n') - /* Backslash-newline at end is not good enough. */ - || (fp->length > 1 && fp->buf[fp->length - 2] == '\\')) { - fp->buf[fp->length++] = '\n'; - missing_newline = 1; - } - fp->buf[fp->length] = '\0'; - - /* Unless inhibited, convert trigraphs in the input. */ - - if (!no_trigraphs) - trigraph_pcp (fp); -#endif - /* Must call finclude() on the main input before processing -include switches; otherwise the -included text winds up after the main input. */ @@ -5123,7 +5121,7 @@ cpp_start_read (pfile, fname) { if (strcmp (pend->cmd, "-imacros") == 0) { - int fd = open (pend->arg, O_RDONLY, 0666); + int fd = open (pend->arg, O_RDONLY|O_NONBLOCK|O_NOCTTY, 0666); if (fd < 0) { cpp_perror_with_name (pfile, pend->arg); @@ -5155,7 +5153,7 @@ cpp_start_read (pfile, fname) { if (strcmp (pend->cmd, "-include") == 0) { - int fd = open (pend->arg, O_RDONLY, 0666); + int fd = open (pend->arg, O_RDONLY|O_NONBLOCK|O_NOCTTY, 0666); if (fd < 0) { cpp_perror_with_name (pfile, pend->arg); @@ -5505,7 +5503,7 @@ cpp_handle_option (pfile, argc, argv) opts->cplusplus_comments = 0; } else if (!strcmp (argv[i], "-trigraphs")) { if (!opts->chill) - opts->no_trigraphs = 0; + opts->trigraphs = 1; } break; @@ -5531,7 +5529,7 @@ cpp_handle_option (pfile, argc, argv) opts->for_lint = 1; if (! strcmp (argv[i], "-lang-chill")) opts->objc = 0, opts->cplusplus = 0, opts->chill = 1, - opts->traditional = 1, opts->no_trigraphs = 1; + opts->traditional = 1, opts->trigraphs = 0; break; case '+': @@ -6377,8 +6375,7 @@ v_cpp_warning_with_line (pfile, line, column, msg, ap) v_cpp_message (pfile, 0, msg, ap); } -#if 0 -static void +void cpp_warning_with_line VPROTO ((cpp_reader * pfile, int line, int column, const char *msg, ...)) { #ifndef ANSI_PROTOTYPES @@ -6401,7 +6398,6 @@ cpp_warning_with_line VPROTO ((cpp_reader * pfile, int line, int column, const c v_cpp_warning_with_line (pfile, line, column, msg, ap); va_end(ap); } -#endif void cpp_pedwarn_with_line VPROTO ((cpp_reader * pfile, int line, int column, const char *msg, ...)) @@ -6536,8 +6532,6 @@ cpp_perror_with_name (pfile, name) * * Find and cleanup remaining uses of static variables, * - * Support for trigraphs. - * * Support -dM flag (dump_all_macros). * * Support for_lint flag. |