*** cccp.c 1997/04/25 18:13:41 1.1 --- cccp.c 1997/05/26 15:11:14 1.4 *************** *** 3,8 **** --- 3,12 ---- Written by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 + Modified by Andrew M. Bishop to provide better input to + C documentation program `cxref' 1995,1996. + All AMB hacks are indicated as such in the code (grep AMB). + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any *************** *** 406,411 **** --- 410,425 ---- static enum {dump_none, dump_only, dump_names, dump_definitions} dump_macros = dump_none; + /* Start new option added by AMB */ + + /* Nonzero means that the #include lines are to be passed through to + output. + */ + + static int dump_includes = 0; + + /* End new option added by AMB */ + /* Nonzero means pass all #define and #undef directives which we actually process through to the output stream. This feature is used primarily to allow cc1 to record the #defines and #undefs for the sake of *************** *** 964,970 **** /* Here is the actual list of #-directives, most-often-used first. */ static struct directive directive_table[] = { ! { 6, do_define, "define", T_DEFINE, 0, 1}, { 2, do_if, "if", T_IF}, { 5, do_xifdef, "ifdef", T_IFDEF}, { 6, do_xifdef, "ifndef", T_IFNDEF}, --- 978,984 ---- /* Here is the actual list of #-directives, most-often-used first. */ static struct directive directive_table[] = { ! { 6, do_define, "define", T_DEFINE, 0, 1, 1}, /* The last 1 is in future cccp.c added by AMB. */ { 2, do_if, "if", T_IF}, { 5, do_xifdef, "ifdef", T_IFDEF}, { 6, do_xifdef, "ifndef", T_IFNDEF}, *************** *** 1355,1360 **** --- 1369,1377 ---- no_line_directives = 0; no_trigraphs = 1; dump_macros = dump_none; + /* Start new option added by AMB */ + dump_includes = 0; + /* End new option added by AMB */ no_output = 0; cplusplus = 0; cplusplus_comments = 1; *************** *** 1666,1671 **** --- 1683,1693 ---- case 'D': dump_macros = dump_definitions; break; + /* Start new option added by AMB */ + case 'I': + dump_includes = 1; + break; + /* End new option added by AMB */ } } } *************** *** 3841,3850 **** bp = ip->bufp; /* No need to copy the directive because of a comment at the end; just don't include the comment in the directive. */ ! if (bp == limit || *bp == '\n') { ! bp = obp; ! goto endloop1; } /* Don't remove the comments if -traditional. */ if (! keep_comments) copy_directive++; --- 3863,3879 ---- bp = ip->bufp; /* No need to copy the directive because of a comment at the end; just don't include the comment in the directive. */ ! /* Start of code from future cccp.c added by AMB */ ! if (!put_out_comments) { ! U_CHAR *p; ! for (p = bp; *p == ' ' || *p == '\t'; p++) ! continue; ! if (*p == '\n') { ! bp = obp; ! goto endloop1; ! } } + /* End of code from future cccp.c added by AMB */ /* Don't remove the comments if -traditional. */ if (! keep_comments) copy_directive++; *************** *** 3874,3880 **** /* If a directive should be copied through, and -E was given, pass it through before removing comments. */ ! if (!no_output && kt->pass_thru && put_out_comments) { int len; /* Output directive name. */ --- 3903,3912 ---- /* If a directive should be copied through, and -E was given, pass it through before removing comments. */ ! if (!no_output && put_out_comments && ! /* Start new option added by AMB */ ! (kt->pass_thru || (kt->type == T_INCLUDE && dump_includes))) { ! /* End new option added by AMB */ int len; /* Output directive name. */ *************** *** 4002,4007 **** --- 4034,4043 ---- if (!no_output && already_output == 0 && (kt->pass_thru + /* Start new option added by AMB */ + || (kt->type == T_INCLUDE + && dump_includes) + /* End new option added by AMB */ || (kt->type == T_DEFINE && (dump_macros == dump_names || dump_macros == dump_definitions)))) { *************** *** 4013,4019 **** bcopy (kt->name, (char *) op->bufp, kt->length); op->bufp += kt->length; ! if (kt->pass_thru || dump_macros == dump_definitions) { /* Output arguments. */ len = (cp - buf); check_expand (op, len); --- 4049,4059 ---- bcopy (kt->name, (char *) op->bufp, kt->length); op->bufp += kt->length; ! if (kt->pass_thru || dump_macros == dump_definitions ! /* Start new option added by AMB */ ! || dump_includes ! /* End new option added by AMB */ ! ) { /* Output arguments. */ len = (cp - buf); check_expand (op, len);