Commit 87062813 by Neil Booth Committed by Neil Booth

cpplex.c (handle_newline, [...]): Update to do more stepping back.

	* cpplex.c (handle_newline, skip_escaped_newlines,
	get_effective_char, skip_block_comment, skip_line_comment,
	parse_identifier_slow, parse_number, parse_string,
	_cpp_lex_direct): Update to do more stepping back.
	(trigraph_ok): Similarly.  Rename trigraph_p.
	(SAVE_STATE, RESTORE_STATE): Remove.
	(BUFF_SIZE_UPPER_BOUND): Tweak.  Add sanity check.

	* cpplib.c (destringize): Rename destringize_and_run, and
	call run_directive directly.
	(_cpp_do__Pragma): Simplify.

From-SVN: r46373
parent 3c1ef3c1
2001-10-20 Neil Booth <neil@daikokuya.demon.co.uk>
* cpplex.c (handle_newline, skip_escaped_newlines,
get_effective_char, skip_block_comment, skip_line_comment,
parse_identifier_slow, parse_number, parse_string,
_cpp_lex_direct): Update to do more stepping back.
(trigraph_ok): Similarly. Rename trigraph_p.
(SAVE_STATE, RESTORE_STATE): Remove.
(BUFF_SIZE_UPPER_BOUND): Tweak. Add sanity check.
* cpplib.c (destringize): Rename destringize_and_run, and
call run_directive directly.
(_cpp_do__Pragma): Simplify.
2001-10-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2001-10-19 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* pe.c (arm_pe_unique_section): Const-ify. * pe.c (arm_pe_unique_section): Const-ify.
......
...@@ -120,8 +120,7 @@ static void do_pragma_system_header PARAMS ((cpp_reader *)); ...@@ -120,8 +120,7 @@ static void do_pragma_system_header PARAMS ((cpp_reader *));
static void do_pragma_dependency PARAMS ((cpp_reader *)); static void do_pragma_dependency PARAMS ((cpp_reader *));
static const cpp_token *get_token_no_padding PARAMS ((cpp_reader *)); static const cpp_token *get_token_no_padding PARAMS ((cpp_reader *));
static const cpp_token *get__Pragma_string PARAMS ((cpp_reader *)); static const cpp_token *get__Pragma_string PARAMS ((cpp_reader *));
static unsigned char *destringize PARAMS ((const cpp_string *, static void destringize_and_run PARAMS ((cpp_reader *, const cpp_string *));
unsigned int *));
static int parse_answer PARAMS ((cpp_reader *, struct answer **, int)); static int parse_answer PARAMS ((cpp_reader *, struct answer **, int));
static cpp_hashnode *parse_assertion PARAMS ((cpp_reader *, struct answer **, static cpp_hashnode *parse_assertion PARAMS ((cpp_reader *, struct answer **,
int)); int));
...@@ -1149,17 +1148,17 @@ get__Pragma_string (pfile) ...@@ -1149,17 +1148,17 @@ get__Pragma_string (pfile)
return string; return string;
} }
/* Returns a malloced buffer containing a destringized cpp_string by /* Destringize IN into a temporary buffer, by removing the first \ of
removing the first \ of \" and \\ sequences. */ \" and \\ sequences, and process the result as a #pragma directive. */
static unsigned char * static void
destringize (in, len) destringize_and_run (pfile, in)
cpp_reader *pfile;
const cpp_string *in; const cpp_string *in;
unsigned int *len;
{ {
const unsigned char *src, *limit; const unsigned char *src, *limit;
unsigned char *dest, *result; char *dest, *result;
dest = result = (unsigned char *) xmalloc (in->len); dest = result = alloca (in->len);
for (src = in->text, limit = src + in->len; src < limit;) for (src = in->text, limit = src + in->len; src < limit;)
{ {
/* We know there is a character following the backslash. */ /* We know there is a character following the backslash. */
...@@ -1168,17 +1167,15 @@ destringize (in, len) ...@@ -1168,17 +1167,15 @@ destringize (in, len)
*dest++ = *src++; *dest++ = *src++;
} }
*len = dest - result; run_directive (pfile, T_PRAGMA, result, dest - result);
return result;
} }
/* Handle the _Pragma operator. */
void void
_cpp_do__Pragma (pfile) _cpp_do__Pragma (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
const cpp_token *string = get__Pragma_string (pfile); const cpp_token *string = get__Pragma_string (pfile);
unsigned char *buffer;
unsigned int len;
if (!string) if (!string)
cpp_error (pfile, "_Pragma takes a parenthesized string literal"); cpp_error (pfile, "_Pragma takes a parenthesized string literal");
...@@ -1195,9 +1192,7 @@ _cpp_do__Pragma (pfile) ...@@ -1195,9 +1192,7 @@ _cpp_do__Pragma (pfile)
Getting these correct line markers is a little tricky. */ Getting these correct line markers is a little tricky. */
unsigned int orig_line = pfile->line; unsigned int orig_line = pfile->line;
buffer = destringize (&string->val.str, &len); destringize_and_run (pfile, &string->val.str);
run_directive (pfile, T_PRAGMA, (char *) buffer, len);
free ((PTR) buffer);
pfile->line = orig_line; pfile->line = orig_line;
pfile->buffer->saved_flags = BOL; pfile->buffer->saved_flags = BOL;
} }
......
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