Commit 554fbeef by Zack Weinberg Committed by Dave Brolley

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
parent 0034cf72
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.
Tue Jan 26 23:21:49 1999 Michael Hayes <m.hayes@elec.canterbury.ac.nz> Tue Jan 26 23:21:49 1999 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
* config/c4x/c4x.h (COUNTER_REGS): New register class. * config/c4x/c4x.h (COUNTER_REGS): New register class.
......
...@@ -130,9 +130,6 @@ static void make_assertion PROTO ((cpp_reader *, char *, U_CHAR *)); ...@@ -130,9 +130,6 @@ 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 ((void)); static void initialize_char_syntax PROTO ((void));
#if 0
static void trigraph_pcp ();
#endif
static void validate_else PROTO ((cpp_reader *, char *)); static void validate_else PROTO ((cpp_reader *, char *));
static int comp_def_part PROTO ((int, U_CHAR *, int, U_CHAR *, static int comp_def_part PROTO ((int, U_CHAR *, int, U_CHAR *,
int, int)); int, int));
...@@ -290,6 +287,18 @@ U_CHAR is_idstart[256] = { 0 }; ...@@ -290,6 +287,18 @@ U_CHAR is_idstart[256] = { 0 };
U_CHAR is_hor_space[256] = { 0 }; U_CHAR is_hor_space[256] = { 0 };
/* table to tell if c is horizontal or vertical space. */ /* table to tell if c is horizontal or vertical space. */
U_CHAR is_space[256] = { 0 }; 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. */ /* Initialize syntactic classifications of characters. */
static void static void
...@@ -330,8 +339,14 @@ initialize_char_syntax () ...@@ -330,8 +339,14 @@ initialize_char_syntax ()
is_space['\f'] = 1; is_space['\f'] = 1;
is_space['\n'] = 1; is_space['\n'] = 1;
is_space['\r'] = 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. /* Place into PFILE a quoted string representing the string SRC.
Caller must reserve enough space in pfile->token_buffer. */ Caller must reserve enough space in pfile->token_buffer. */
...@@ -554,7 +569,7 @@ cpp_options_init (opts) ...@@ -554,7 +569,7 @@ cpp_options_init (opts)
initialize_char_syntax (); initialize_char_syntax ();
opts->no_line_commands = 0; opts->no_line_commands = 0;
opts->no_trigraphs = 1; opts->trigraphs = 0;
opts->put_out_comments = 0; opts->put_out_comments = 0;
opts->print_include_names = 0; opts->print_include_names = 0;
opts->dump_macros = dump_none; opts->dump_macros = dump_none;
...@@ -4953,7 +4968,7 @@ cpp_start_read (pfile, fname) ...@@ -4953,7 +4968,7 @@ cpp_start_read (pfile, fname)
if (fname == NULL || *fname == 0) { if (fname == NULL || *fname == 0) {
fname = ""; fname = "";
f = 0; 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); cpp_pfatal_with_name (pfile, fname);
/* -MG doesn't select the form of output and must be specified with one of /* -MG doesn't select the form of output and must be specified with one of
...@@ -5075,23 +5090,6 @@ cpp_start_read (pfile, fname) ...@@ -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 /* Must call finclude() on the main input before processing
-include switches; otherwise the -included text winds up -include switches; otherwise the -included text winds up
after the main input. */ after the main input. */
...@@ -5123,7 +5121,7 @@ cpp_start_read (pfile, fname) ...@@ -5123,7 +5121,7 @@ cpp_start_read (pfile, fname)
{ {
if (strcmp (pend->cmd, "-imacros") == 0) 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) if (fd < 0)
{ {
cpp_perror_with_name (pfile, pend->arg); cpp_perror_with_name (pfile, pend->arg);
...@@ -5155,7 +5153,7 @@ cpp_start_read (pfile, fname) ...@@ -5155,7 +5153,7 @@ cpp_start_read (pfile, fname)
{ {
if (strcmp (pend->cmd, "-include") == 0) 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) if (fd < 0)
{ {
cpp_perror_with_name (pfile, pend->arg); cpp_perror_with_name (pfile, pend->arg);
...@@ -5505,7 +5503,7 @@ cpp_handle_option (pfile, argc, argv) ...@@ -5505,7 +5503,7 @@ cpp_handle_option (pfile, argc, argv)
opts->cplusplus_comments = 0; opts->cplusplus_comments = 0;
} else if (!strcmp (argv[i], "-trigraphs")) { } else if (!strcmp (argv[i], "-trigraphs")) {
if (!opts->chill) if (!opts->chill)
opts->no_trigraphs = 0; opts->trigraphs = 1;
} }
break; break;
...@@ -5531,7 +5529,7 @@ cpp_handle_option (pfile, argc, argv) ...@@ -5531,7 +5529,7 @@ cpp_handle_option (pfile, argc, argv)
opts->for_lint = 1; opts->for_lint = 1;
if (! strcmp (argv[i], "-lang-chill")) if (! strcmp (argv[i], "-lang-chill"))
opts->objc = 0, opts->cplusplus = 0, opts->chill = 1, opts->objc = 0, opts->cplusplus = 0, opts->chill = 1,
opts->traditional = 1, opts->no_trigraphs = 1; opts->traditional = 1, opts->trigraphs = 0;
break; break;
case '+': case '+':
...@@ -6377,8 +6375,7 @@ v_cpp_warning_with_line (pfile, line, column, msg, ap) ...@@ -6377,8 +6375,7 @@ v_cpp_warning_with_line (pfile, line, column, msg, ap)
v_cpp_message (pfile, 0, msg, ap); v_cpp_message (pfile, 0, msg, ap);
} }
#if 0 void
static void
cpp_warning_with_line VPROTO ((cpp_reader * pfile, int line, int column, const char *msg, ...)) cpp_warning_with_line VPROTO ((cpp_reader * pfile, int line, int column, const char *msg, ...))
{ {
#ifndef ANSI_PROTOTYPES #ifndef ANSI_PROTOTYPES
...@@ -6401,7 +6398,6 @@ cpp_warning_with_line VPROTO ((cpp_reader * pfile, int line, int column, const c ...@@ -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); v_cpp_warning_with_line (pfile, line, column, msg, ap);
va_end(ap); va_end(ap);
} }
#endif
void void
cpp_pedwarn_with_line VPROTO ((cpp_reader * pfile, int line, int column, const char *msg, ...)) 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) ...@@ -6536,8 +6532,6 @@ cpp_perror_with_name (pfile, name)
* *
* Find and cleanup remaining uses of static variables, * Find and cleanup remaining uses of static variables,
* *
* Support for trigraphs.
*
* Support -dM flag (dump_all_macros). * Support -dM flag (dump_all_macros).
* *
* Support for_lint flag. * Support for_lint flag.
......
...@@ -334,9 +334,9 @@ struct cpp_options { ...@@ -334,9 +334,9 @@ struct cpp_options {
char put_out_comments; char put_out_comments;
/* Nonzero means don't process the ANSI trigraph sequences. */ /* Nonzero means process the ANSI trigraph sequences. */
char no_trigraphs; char trigraphs;
/* Nonzero means print the names of included files rather than /* Nonzero means print the names of included files rather than
the preprocessed output. 1 means just the #include "...", the preprocessed output. 1 means just the #include "...",
...@@ -642,6 +642,7 @@ struct definition { ...@@ -642,6 +642,7 @@ struct definition {
extern unsigned char is_idchar[256]; extern unsigned char is_idchar[256];
extern unsigned char is_hor_space[256]; extern unsigned char is_hor_space[256];
extern unsigned char is_space[256]; extern unsigned char is_space[256];
extern unsigned char trigraph_table[256];
/* Stack of conditionals currently in progress /* Stack of conditionals currently in progress
(including both successful and failing conditionals). */ (including both successful and failing conditionals). */
...@@ -677,6 +678,8 @@ extern void cpp_pedwarn PVPROTO ((cpp_reader *, const char *, ...)) ...@@ -677,6 +678,8 @@ extern void cpp_pedwarn PVPROTO ((cpp_reader *, const char *, ...))
ATTRIBUTE_PRINTF_2; ATTRIBUTE_PRINTF_2;
extern void cpp_error_with_line PVPROTO ((cpp_reader *, int, int, const char *, ...)) extern void cpp_error_with_line PVPROTO ((cpp_reader *, int, int, const char *, ...))
ATTRIBUTE_PRINTF_4; ATTRIBUTE_PRINTF_4;
extern void cpp_warning_with_line PVPROTO ((cpp_reader *, int, int, const char *, ...))
ATTRIBUTE_PRINTF_4;
extern void cpp_pedwarn_with_line PVPROTO ((cpp_reader *, int, int, const char *, ...)) extern void cpp_pedwarn_with_line PVPROTO ((cpp_reader *, int, int, const char *, ...))
ATTRIBUTE_PRINTF_4; ATTRIBUTE_PRINTF_4;
extern void cpp_pedwarn_with_file_and_line PVPROTO ((cpp_reader *, char *, int, const char *, ...)) extern void cpp_pedwarn_with_file_and_line PVPROTO ((cpp_reader *, char *, int, const char *, ...))
......
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