From e2f9a79f86f078c40323984d2ee549e1ba2b19d4 Mon Sep 17 00:00:00 2001 From: zack Date: Fri, 14 Apr 2000 23:29:45 +0000 Subject: * cpplex.c (cpp_output_tokens, cpp_scan_buffer_nooutput): New public interfaces. (safe_fwrite, output_line_command): New static functions. (cpp_expand_to_buffer): Now private to cpplib. (cpp_scan_buffer): Take a printer. * cpphash.h: Update prototypes. * cpplib.h: Update prototypes. (cpp_printer): New. (cpp_buffer): Remove last_nominal_fname. (cpp_reader): Remove lineno. * cppmain.c: Use a cpp_printer. * fix-header.c: No need to inhibit line commands. Call cpp_start_read with no printer. * cpperror.c (cpp_notice_from_errno): Provide default name. * cppfiles.c (make_IHASH, _cpp_fake_ihash): New functions. (find_include_file, cpp_read_file): Use make_IHASH. (file_cleanup): Set control_macro and clear input_stack_listing_current here. (_cpp_execute_include): Don't output entering-file marker. * cpphash.c (special_symbol): Look for the line number in the buffer, not the reader. (_cpp_macroexpand): No need to disable line commands. (_cpp_dump_definition): No need to generate line commands. (dump_hash_helper): Remove excess newline from output. * cppinit.c (dump_special_to_buffer): No need to generate line commands. (cpp_printer_init): New. (cpp_start_read): Take a printer, and start it up if it's not NULL. No need to generate line commands. (cpp_finish): Expect no buffers stacked at all. Take a printer argument, and flush the output buffer if it's not NULL. * cpplex.c (_cpp_lex_token): Return EOF if there's no buffer. Don't put two hashes at the beginning of an assertion. (cpp_get_token): Don't increment pfile->lineno or emit line commands here. Return EOF if there's no buffer when we get EOF. * cpplib.c (do_define, skip_if_group): No need to disable line commands. (_cpp_output_line_command): Delete function. (do_line): Don't emit line commands here, but set things up so they will be emitted if necessary. Use _cpp_fake_ihash to make unique nominal_fnames if necessary. (do_elif, do_else, _cpp_handle_eof): Call cpp_error_with_line with 0 for column, not -1. (_cpp_handle_eof): Don't set the control macro here. Don't clear input_stack_listing_current here. Don't emit line commands. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33159 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cpplib.h | 50 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 17 deletions(-) (limited to 'gcc/cpplib.h') diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 1465349698f..366196d686a 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -31,6 +31,7 @@ extern "C" { typedef struct cpp_reader cpp_reader; typedef struct cpp_buffer cpp_buffer; typedef struct cpp_options cpp_options; +typedef struct cpp_printer cpp_printer; enum cpp_ttype { @@ -74,8 +75,6 @@ struct cpp_buffer /* Filename specified with #line command. */ const char *nominal_fname; - /* Last filename specified with #line command. */ - const char *last_nominal_fname; /* Actual directory of this file, used only for "" includes */ struct file_name_list *actual_dir; @@ -98,6 +97,8 @@ struct cpp_buffer /* True if this is a header file included using . */ char system_header_p; + + /* True if end-of-file has already been hit once in this buffer. */ char seen_eof; /* True if buffer contains escape sequences. @@ -352,8 +353,6 @@ struct cpp_reader struct if_stack *if_stack; const unsigned char *potential_control_macro; - unsigned int lineno; - /* Buffer of -M output. */ struct deps *deps; @@ -402,6 +401,19 @@ struct cpp_reader unsigned char done_initializing; }; +/* struct cpp_printer encapsulates state used to convert the stream of + tokens coming from cpp_get_token back into a text file. Not + everyone wants to do that, hence we separate the function. */ + +struct cpp_printer +{ + FILE *outf; /* stream to write to */ + const char *last_fname; /* previous file name */ + unsigned int last_bsd; /* did we just push? */ + unsigned int lineno; /* line currently being written */ + unsigned int written; /* low water mark in token buffer */ +}; + #define CPP_FATAL_LIMIT 1000 /* True if we have seen a "fatal" error. */ #define CPP_FATAL_ERRORS(READER) ((READER)->errors >= CPP_FATAL_LIMIT) @@ -427,9 +439,11 @@ extern enum cpp_ttype cpp_get_token PARAMS ((cpp_reader *)); extern enum cpp_ttype cpp_get_non_space_token PARAMS ((cpp_reader *)); extern void cpp_reader_init PARAMS ((cpp_reader *)); -extern int cpp_start_read PARAMS ((cpp_reader *, const char *)); -extern void cpp_finish PARAMS ((cpp_reader *)); -extern void cpp_cleanup PARAMS ((cpp_reader *PFILE)); +extern cpp_printer *cpp_printer_init PARAMS ((cpp_reader *, cpp_printer *)); +extern int cpp_start_read PARAMS ((cpp_reader *, cpp_printer *, const char *)); +extern void cpp_output_tokens PARAMS ((cpp_reader *, cpp_printer *)); +extern void cpp_finish PARAMS ((cpp_reader *, cpp_printer *)); +extern void cpp_cleanup PARAMS ((cpp_reader *)); extern cpp_buffer *cpp_file_buffer PARAMS((cpp_reader *)); extern void cpp_define PARAMS ((cpp_reader *, const char *)); @@ -463,17 +477,19 @@ extern void cpp_pedwarn_with_line PARAMS ((cpp_reader *, int, int, const char *m ATTRIBUTE_PRINTF_4; extern void cpp_pedwarn_with_file_and_line PARAMS ((cpp_reader *, const char *, int, int, const char *msgid, ...)) ATTRIBUTE_PRINTF_5; -extern void cpp_error_from_errno PARAMS ((cpp_reader *, const char *)); -extern void cpp_notice_from_errno PARAMS ((cpp_reader *, const char *)); - -extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *, - const unsigned char *, long)); -extern cpp_buffer *cpp_pop_buffer PARAMS ((cpp_reader *)); -extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int)); - -extern void cpp_expand_to_buffer PARAMS ((cpp_reader *, +extern void cpp_error_from_errno PARAMS ((cpp_reader *, const char *)); +extern void cpp_notice_from_errno PARAMS ((cpp_reader *, const char *)); + +/* In cpplex.c */ +extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *, + const unsigned char *, long)); +extern cpp_buffer *cpp_pop_buffer PARAMS ((cpp_reader *)); +extern void cpp_scan_buffer PARAMS ((cpp_reader *, cpp_printer *)); +extern void cpp_scan_buffer_nooutput PARAMS ((cpp_reader *)); + +/* In cpphash.c */ +extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int)); -extern void cpp_scan_buffer PARAMS ((cpp_reader *)); /* In cppfiles.c */ extern int cpp_included PARAMS ((cpp_reader *, const char *)); -- cgit v1.2.1