diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2000-08-02 01:13:45 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-08-02 01:13:45 +0000 |
commit | 58fea6afd912f7c309c156522391b20462372ceb (patch) | |
tree | af945d1943c9c6b458fec03b961f8f0d523896bf /gcc/cppmacro.c | |
parent | 8cd8f856b33bbd6c6627eb0a18e34b046e2163f1 (diff) | |
download | gcc-58fea6afd912f7c309c156522391b20462372ceb.zip gcc-58fea6afd912f7c309c156522391b20462372ceb.tar.gz gcc-58fea6afd912f7c309c156522391b20462372ceb.tar.bz2 |
cpperror.c (v_message): Split into _cpp_begin_message and v_message macro.
* cpperror.c (v_message): Split into _cpp_begin_message and
v_message macro. All callers updated.
(_cpp_begin_message): Do inhibit_errors/inhibit_warnings
checks here.
* cppfiles.c (cpp_syshdr_flags): New function.
(read_include_file): Don't call cpp_output_tokens. Call
enter_file hook.
* cppinit.c (dump_macros_helper): Moved to cppmain.c.
(cpp_reader_init): Don't initialize token_buffer. Call
_cpp_init_internal_pragmas.
(cpp_cleanup): Don't clear token_buffer.
(cpp_start_read): Don't worry about output from -D processing.
Don't call cpp_output_tokens.
(cpp_finish): Don't dump macros here. Don't call
cpp_output_tokens.
* cppmacro.c (_cpp_dump_definition): Rename
cpp_dump_definition. Write directly to a FILE *.
(dump_funlike_macro): Delete.
(dump_macro_args): New.
* cpplex.c (TOKEN_LEN): Convert to inline function.
(_cpp_grow_token_buffer, safe_fwrite, cpp_output_tokens,
cpp_scan_line, _cpp_dump_list): Delete.
(cpp_printf, cpp_output_list): New.
(output_line_command): Don't worry about entering or leaving files.
(cpp_scan_buffer): Just output each token as we hit it.
(process_directive): Don't call cpp_output_tokens.
(_cpp_glue_header_name): Don't use token_buffer.
(output_token, dump_param_spelling): Write directly to a FILE *.
* cpplib.c (pass_thru_directive, dump_macro_name,
pragma_dispatch, do_pragma_gcc): Delete.
(do_define, do_undef, parse_include, do_line, do_ident, do_pragma,
do_pragma_poison, cpp_pop_buffer): Call the appropriate hook
functions.
(do_error, do_warning, pragma_dependency): Call
_cpp_begin_message, then cpp_output_list.
(cpp_register_pragma, cpp_register_pragma_space,
_cpp_init_internal_pragmas): New.
(do_pragma): Walk the pragmas table here.
(do_pragma_once, do_pragma_poison, do_pragma_system_header,
do_pragma_dependency): Return void.
(do_pragma_implementation): Moved to cppmain.c.
* cpplib.h: Update prototypes.
(struct cpp_reader): Remove printer, token_buffer,
token_buffer_size, and limit. Add struct cb, and pragmas.
(struct cpp_printer): Remove last_id and written.
(CPP_WRITTEN, CPP_PWRITTEN, CPP_SET_WRITTEN,
CPP_ADJUST_WRITTEN): Delete.
* cpphash.h: Update prototypes.
(ufputs): New wrapper.
* cppmain.c (cb_define, cb_undef, cb_include, cb_ident,
cb_enter_file, cb_leave_file, cb_def_pragma): New functions.
(main): Set up callbacks. Register #pragma implementation.
Dump macros from here.
From-SVN: r35415
Diffstat (limited to 'gcc/cppmacro.c')
-rw-r--r-- | gcc/cppmacro.c | 69 |
1 files changed, 28 insertions, 41 deletions
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index 8d53baf..5ff49a8 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -40,7 +40,7 @@ struct macro_info unsigned char flags; }; -static void dump_funlike_macro PARAMS ((cpp_reader *, cpp_hashnode *)); +static void dump_macro_args PARAMS ((FILE *, const cpp_toklist *)); static void count_params PARAMS ((cpp_reader *, struct macro_info *)); static int is__va_args__ PARAMS ((cpp_reader *, const cpp_token *)); @@ -554,66 +554,53 @@ _cpp_create_definition (pfile, hp) return 1; } -/* Dump the definition of macro MACRO on stdout. The format is suitable - to be read back in again. */ +/* Dump the definition of macro MACRO on FP. The format is suitable + to be read back in again. Caller is expected to generate the + "#define NAME" bit. */ void -_cpp_dump_definition (pfile, hp) +cpp_dump_definition (pfile, fp, hp) cpp_reader *pfile; - cpp_hashnode *hp; + FILE *fp; + const cpp_hashnode *hp; { - CPP_RESERVE (pfile, hp->length + sizeof "#define "); - CPP_PUTS_Q (pfile, "#define ", sizeof "#define " - 1); - CPP_PUTS_Q (pfile, hp->name, hp->length); + const cpp_toklist *list = hp->value.expansion; - if (hp->type == T_MACRO) + if (hp->type != T_MACRO) { - if (hp->value.expansion->paramc >= 0) - dump_funlike_macro (pfile, hp); - else - { - const cpp_toklist *list = hp->value.expansion; - list->tokens[0].flags &= ~BOL; - list->tokens[0].flags |= PREV_WHITE; - _cpp_dump_list (pfile, list, list->tokens, 1); - } + cpp_ice (pfile, "invalid hash type %d in dump_definition", hp->type); + return; } - else - cpp_ice (pfile, "invalid hash type %d in dump_definition", hp->type); - if (CPP_BUFFER (pfile) == 0 || ! pfile->done_initializing) - CPP_PUTC (pfile, '\n'); + if (list->paramc >= 0) + dump_macro_args (fp, list); + + putc (' ', fp); + cpp_output_list (pfile, fp, list, list->tokens); } static void -dump_funlike_macro (pfile, node) - cpp_reader *pfile; - cpp_hashnode *node; +dump_macro_args (fp, list) + FILE *fp; + const cpp_toklist *list; { - int i = 0; - const cpp_toklist * list = node->value.expansion; - const U_CHAR *param; + int i; + const U_CHAR *param = list->namebuf; - param = list->namebuf; - CPP_PUTC_Q (pfile, '('); + putc ('(', fp); for (i = 0; i++ < list->paramc;) { unsigned int len; len = ustrlen (param); - CPP_PUTS (pfile, param, len); + if (!list->flags & VAR_ARGS || ustrcmp (param, U"__VA_ARGS__")) + ufputs (param, fp); if (i < list->paramc) - CPP_PUTS(pfile, ", ", 2); + fputs (", ", fp); else if (list->flags & VAR_ARGS) - { - if (!ustrcmp (param, U"__VA_ARGS__")) - pfile->limit -= sizeof (U"__VA_ARGS__") - 1; - CPP_PUTS_Q (pfile, "...", 3); - } + fputs ("...", fp); + param += len + 1; } - CPP_PUTC (pfile, ')'); - list->tokens[0].flags &= ~BOL; - list->tokens[0].flags |= PREV_WHITE; - _cpp_dump_list (pfile, list, list->tokens, 1); + putc (')', fp); } |