summaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2003-04-19 00:22:51 +0000
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2003-04-19 00:22:51 +0000
commita54e0bf8102a75fd6b85a7cfbb6b9b1a553befcf (patch)
tree6e2502497aefe03b070107d7b41bbe6be454b727 /gcc/cpplib.c
parentd3b199e5d0150d54e10b768227d381837a9f02d8 (diff)
downloadgcc-a54e0bf8102a75fd6b85a7cfbb6b9b1a553befcf.tar.gz
* cppfiles.c (ENABLE_VALGRIND_CHECKING, VALGRIND_DISCARD,
MMAP_THRESHOLD, TEST_THRESHOLD, SHOULD_MMAP): Remove. (struct include_file): Remove fefcnt, mapped members. (open_file, stack_include_file, _cpp_pop_file_buffer): Disable caching. (read_include_file): Don't use mmap, terminate buffers in '\r'. (purge_cache): Don't use munmap. * cpphash.h (CPP_BUF_COLUMN): Update. (lexer_state): Remove lexing_comment. (struct _cpp_line_note): New. (struct cpp_buffer): New members cur_note, notes_used, notes_cap, next_line and need_line. Remove col_adjust and saved_flags. (_cpp_process_line_notes, _cpp_clean_line, _cpp_get_fresh_line, _cpp_skip_block_comment, scan_out_logical_line): New. (_cpp_init_mbchar): Remove. * cppinit.c (init_library): Remove call to _cpp_init_mbchar. (cpp_read_main_file): Set line to 1 earlier. (post_options): -traditional-cpp doesn't want trigraphs. * cpplex.c (MULTIBYTE_CHARS): Remove code predicated on this. (add_line_note, _cpp_clean_line, _cpp_process_line_notes, _cpp_get_fresh_line): New. (handle_newline, skip_escaped_newlines, trigraph_p, continue_after_nul, _cpp_init_mbchar): Remove. (get_effective_char): Update. (_cpp_skip_block_comment): Rename from skip_block_comment, simplify. (skip_line_comment): Simplify. (skip_whitespace, parse_identifier, parse_slow, parse_number, parse_string): Update. (cpp_lex_direct): Use clean lines and process line notes. Update. (cpp_interpret_charconst): No MULTIBYTE_CHARS. * cpplib.c (prepare_directive_trad): Call scan_out_logical_line directly. (_cpp_handle_directive): Don't set saved_flags. (run_directive, destringize_and_run, cpp_define, cpp_define_builtin, cpp_undef, handle_assertion, cpp_push_buffer): Update. (_cpp_pop_buffer): Free notes. * cppmacro.c (builtin_macro, paste_tokens): \n terminate buffer. * cpppch.c (cpp_read_state): \n terminate buffer. * cpptrad.c (skip_escaped_newlines, handle_newline): Remove. (copy_comment): Use _cpp_skip_block_comment. (skip_whitespace, lex_identifier, _cpp_read_logical_line_trad): Simplify. (_cpp_overlay_buffer, _cpp_remove_overlay, push_replacement_text, save_replacement_text): Update. (scan_out_logical_line): Update to use clean lines and process line notes. * fix-header.c (read_scan_file): Update. testsuite: * gcc.dg/cpp/_Pragma4.c: Remove stray space. * gcc.dg/cpp/trad/escaped-eof.c: Correct line number. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65808 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 7d2d9652477..bb983b04a29 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -295,7 +295,7 @@ prepare_directive_trad (pfile)
|| pfile->directive == &dtable[T_ELIF]);
if (no_expand)
pfile->state.prevent_expansion++;
- _cpp_read_logical_line_trad (pfile);
+ scan_out_logical_line (pfile, NULL);
if (no_expand)
pfile->state.prevent_expansion--;
pfile->state.skipping = was_skipping;
@@ -451,13 +451,12 @@ _cpp_handle_directive (pfile, indented)
/* Restore state when within macro args. */
pfile->state.parsing_args = 2;
pfile->state.prevent_expansion = 1;
- pfile->buffer->saved_flags |= PREV_WHITE;
}
return skip;
}
/* Directive handler wrapper used by the command line option
- processor. */
+ processor. BUF is \n terminated. */
static void
run_directive (pfile, dir_no, buf, count)
cpp_reader *pfile;
@@ -471,8 +470,11 @@ run_directive (pfile, dir_no, buf, count)
if (dir_no == T_PRAGMA)
pfile->buffer->inc = pfile->buffer->prev->inc;
start_directive (pfile);
- /* We don't want a leading # to be interpreted as a directive. */
- pfile->buffer->saved_flags = 0;
+
+ /* This is a short-term fix to prevent a leading '#' being
+ interpreted as a directive. */
+ _cpp_clean_line (pfile);
+
pfile->directive = &dtable[dir_no];
if (CPP_OPTION (pfile, traditional))
prepare_directive_trad (pfile);
@@ -1378,7 +1380,7 @@ destringize_and_run (pfile, in)
src++;
*dest++ = *src++;
}
- *dest = '\0';
+ *dest = '\n';
/* Ugh; an awful kludge. We are really not set up to be lexing
tokens when in the middle of a macro expansion. Use a new
@@ -1904,7 +1906,7 @@ cpp_define (pfile, str)
buf[count++] = ' ';
buf[count++] = '1';
}
- buf[count] = '\0';
+ buf[count] = '\n';
run_directive (pfile, T_DEFINE, buf, count);
}
@@ -1915,7 +1917,11 @@ _cpp_define_builtin (pfile, str)
cpp_reader *pfile;
const char *str;
{
- run_directive (pfile, T_DEFINE, str, strlen (str));
+ size_t len = strlen (str);
+ char *buf = alloca (len + 1);
+ memcpy (buf, str, len);
+ buf[len] = '\n';
+ run_directive (pfile, T_DEFINE, buf, len);
}
/* Process MACRO as if it appeared as the body of an #undef. */
@@ -1924,7 +1930,11 @@ cpp_undef (pfile, macro)
cpp_reader *pfile;
const char *macro;
{
- run_directive (pfile, T_UNDEF, macro, strlen (macro));
+ size_t len = strlen (macro);
+ char *buf = alloca (len + 1);
+ memcpy (buf, macro, len);
+ buf[len] = '\n';
+ run_directive (pfile, T_UNDEF, buf, len);
}
/* Process the string STR as if it appeared as the body of a #assert. */
@@ -1955,18 +1965,18 @@ handle_assertion (pfile, str, type)
size_t count = strlen (str);
const char *p = strchr (str, '=');
+ /* Copy the entire option so we can modify it. Change the first
+ "=" in the string to a '(', and tack a ')' on the end. */
+ char *buf = (char *) alloca (count + 2);
+
+ memcpy (buf, str, count);
if (p)
{
- /* Copy the entire option so we can modify it. Change the first
- "=" in the string to a '(', and tack a ')' on the end. */
- char *buf = (char *) alloca (count + 2);
-
- memcpy (buf, str, count);
buf[p - str] = '(';
buf[count++] = ')';
- buf[count] = '\0';
- str = buf;
}
+ buf[count] = '\n';
+ str = buf;
run_directive (pfile, type, str, count);
}
@@ -2028,15 +2038,14 @@ cpp_push_buffer (pfile, buffer, len, from_stage3, return_at_eof)
/* Clears, amongst other things, if_stack and mi_cmacro. */
memset (new, 0, sizeof (cpp_buffer));
- new->line_base = new->buf = new->cur = buffer;
+ new->next_line = new->buf = buffer;
new->rlimit = buffer + len;
- new->from_stage3 = from_stage3 || CPP_OPTION (pfile, traditional);
+ new->from_stage3 = from_stage3;
new->prev = pfile->buffer;
new->return_at_eof = return_at_eof;
- new->saved_flags = BOL;
+ new->need_line = true;
pfile->buffer = new;
-
return new;
}
@@ -2062,6 +2071,8 @@ _cpp_pop_buffer (pfile)
/* _cpp_do_file_change expects pfile->buffer to be the new one. */
pfile->buffer = buffer->prev;
+ free (buffer->notes);
+
/* Free the buffer object now; we may want to push a new buffer
in _cpp_push_next_include_file. */
obstack_free (&pfile->buffer_ob, buffer);