aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpphash.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-03-13 22:01:08 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-03-13 22:01:08 +0000
commit45b966db65e4ab054d31f01f65b7a98023dbcb54 (patch)
tree665428b0af6694941ce92f0755dc66596d94fa55 /gcc/cpphash.c
parent46089b8642e5054073af90a85cfdd07f0f09353b (diff)
downloadgcc-45b966db65e4ab054d31f01f65b7a98023dbcb54.zip
gcc-45b966db65e4ab054d31f01f65b7a98023dbcb54.tar.gz
gcc-45b966db65e4ab054d31f01f65b7a98023dbcb54.tar.bz2
Makefile.in (LIBCPP_OBJS): Add cpplex.o.
* Makefile.in (LIBCPP_OBJS): Add cpplex.o. (cpplex.o): New target. * po/POTFILES.in: Add cpplex.c. * cpplex.c (_cpp_grow_token_buffer, null_cleanup, cpp_push_buffer, cpp_pop_buffer, cpp_scan_buffer, cpp_expand_to_buffer, cpp_buf_line_and_col, cpp_file_buffer, skip_block_comment, skip_line_comment, skip_comment, copy_comment, _cpp_skip_hspace, _cpp_skip_rest_of_line, _cpp_parse_name, skip_string, parse_string, _cpp_parse_assertion, cpp_get_token, cpp_get_non_space_token, _cpp_get_directive_token, find_position, _cpp_read_and_prescan, _cpp_init_input_buffer): Move here. (maybe_macroexpand, _cpp_lex_token): New functions. * cpplib.c (SKIP_WHITE_SPACE, eval_if_expr, parse_set_mark, parse_goto_mark): Delete. (_cpp_handle_eof): New function. (_cpp_handle_directive): Rename from handle_directive. (_cpp_output_line_command): Rename from output_line_command. (do_if, do_elif): Call _cpp_parse_expr directly. * cppfiles.c (_cpp_read_include_file): Don't call init_input_buffer here. * cpphash.c (quote_string): Move here, rename _cpp_quote_string. * cppexp.c (_cpp_parse_expr): Diddle parsing_if_directive here; pop the token_buffer and skip the rest of the line here. * cppinit.c (cpp_start_read): Call _cpp_init_input_buffer here. * cpphash.h (CPP_RESERVE, CPP_IS_MACRO_BUFFER, ACTIVE_MARK_P): Define here. (CPP_SET_BUF_MARK, CPP_GOTO_BUF_MARK, CPP_SET_MARK, CPP_GOTO_MARK): New macros. (_cpp_quote_string, _cpp_parse_name, _cpp_skip_rest_of_line, _cpp_skip_hspace, _cpp_parse_assertion, _cpp_lex_token, _cpp_read_and_prescan, _cpp_init_input_buffer, _cpp_grow_token_buffer, _cpp_get_directive_token, _cpp_handle_directive, _cpp_handle_eof, _cpp_output_line_command): Prototype them here. * cpplib.h (enum cpp_token): Add CPP_MACRO. (CPP_RESERVE, get_directive_token, cpp_grow_buffer, quote_string, output_line_command): Remove. From-SVN: r32513
Diffstat (limited to 'gcc/cpphash.c')
-rw-r--r--gcc/cpphash.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/gcc/cpphash.c b/gcc/cpphash.c
index 3d48e8c..d3dac0b 100644
--- a/gcc/cpphash.c
+++ b/gcc/cpphash.c
@@ -307,7 +307,7 @@ collect_expansion (pfile, arglist)
last -= 2; /* two extra chars for the leading escape */
for (;;)
{
- /* We use cpp_get_token because get_directive_token would
+ /* We use cpp_get_token because _cpp_get_directive_token would
discard whitespace and we can't cope with that yet. Macro
expansion is off, so we are guaranteed not to see POP or EOF. */
@@ -570,7 +570,7 @@ collect_formal_parameters (pfile)
long old_written;
old_written = CPP_WRITTEN (pfile);
- token = get_directive_token (pfile);
+ token = _cpp_get_directive_token (pfile);
if (token != CPP_LPAREN)
{
cpp_ice (pfile, "first token = %d not %d in collect_formal_parameters",
@@ -584,7 +584,7 @@ collect_formal_parameters (pfile)
for (;;)
{
CPP_SET_WRITTEN (pfile, old_written);
- token = get_directive_token (pfile);
+ token = _cpp_get_directive_token (pfile);
switch (token)
{
case CPP_NAME:
@@ -660,7 +660,7 @@ collect_formal_parameters (pfile)
argv[argc].rest_arg = 1;
- token = get_directive_token (pfile);
+ token = _cpp_get_directive_token (pfile);
if (token != CPP_RPAREN)
{
cpp_error (pfile, "another parameter follows `...'");
@@ -826,6 +826,43 @@ static const char * const monthnames[] =
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
};
+/* Place into PFILE a quoted string representing the string SRC.
+ Caller must reserve enough space in pfile->token_buffer. */
+
+void
+_cpp_quote_string (pfile, src)
+ cpp_reader *pfile;
+ const char *src;
+{
+ U_CHAR c;
+
+ CPP_PUTC_Q (pfile, '\"');
+ for (;;)
+ switch ((c = *src++))
+ {
+ default:
+ if (ISPRINT (c))
+ CPP_PUTC_Q (pfile, c);
+ else
+ {
+ sprintf ((char *)CPP_PWRITTEN (pfile), "\\%03o", c);
+ CPP_ADJUST_WRITTEN (pfile, 4);
+ }
+ break;
+
+ case '\"':
+ case '\\':
+ CPP_PUTC_Q (pfile, '\\');
+ CPP_PUTC_Q (pfile, c);
+ break;
+
+ case '\0':
+ CPP_PUTC_Q (pfile, '\"');
+ CPP_NUL_TERMINATE_Q (pfile);
+ return;
+ }
+}
+
/*
* expand things like __FILE__. Place the expansion into the output
* buffer *without* rescanning.
@@ -857,7 +894,7 @@ special_symbol (hp, pfile)
if (!buf)
buf = "";
CPP_RESERVE (pfile, 3 + 4 * strlen (buf));
- quote_string (pfile, buf);
+ _cpp_quote_string (pfile, buf);
return;
}
@@ -1597,7 +1634,7 @@ _cpp_dump_definition (pfile, sym, len, defn)
DEFINITION *defn;
{
if (pfile->lineno == 0)
- output_line_command (pfile, same_file);
+ _cpp_output_line_command (pfile, same_file);
CPP_RESERVE (pfile, len + sizeof "#define ");
CPP_PUTS_Q (pfile, "#define ", sizeof "#define " -1);