X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/2f2892c2eae871c76b3acfd77a8accfb9f4c7322..11c40ce9ae842585926cc1abd029f9f5a6702827:/src/cpplib.c diff --git a/src/cpplib.c b/src/cpplib.c index 08e8f97..5aff1e9 100644 --- a/src/cpplib.c +++ b/src/cpplib.c @@ -1,6 +1,6 @@ /* ** Splint - annotation-assisted static program checker -** Copyright (C) 1994-2002 University of Virginia, +** Copyright (C) 1994-2003 University of Virginia, ** Massachusetts Institute of Technology ** ** This program is free software; you can redistribute it and/or modify it @@ -70,7 +70,11 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # include # if defined (WIN32) || defined (OS2) && defined (__IBMC__) # include +/* SMF */ +# ifndef BCC32 # include /* for __DATE__ and __TIME__ */ +# endif + # include # else # ifndef VMS @@ -93,14 +97,13 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # include # include "splintMacros.nf" -# include "llbasic.h" +# include "basic.h" # include "lcllib.h" # include "cpplib.h" # include "cpperror.h" # include "cpphash.h" # include "cppexp.h" # include "version.h" -# include "portab.h" # include "osd.h" /* @@ -112,6 +115,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* Warnings for using sprintf - suppress them all for now... */ /*@-bufferoverflowhigh@*/ +/*@-bounds@*/ #define NO_SHORTNAMES @@ -238,6 +242,10 @@ static int cpp_peekN (cppReader *p_pfile, int p_n) /*@*/ ; # define cppBuffer_get(BUFFER) \ ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur++ : EOF) +/*@function static int cppBuffer_reachedEOF (sef cppBuffer *p_b) modifies nothing; @*/ +# define cppBuffer_reachedEOF(b) \ + ((b)->cur < (b)->rlimit ? FALSE : TRUE) + /* Append string STR (of length N) to PFILE's output buffer. Make space. */ /*@function static void cppReader_puts (sef cppReader *p_file, char *p_str, sef size_t p_n) modifies *p_file; @*/ @@ -295,6 +303,9 @@ static void cppBuffer_forward (cppBuffer *p_buf, int p_n) /*@modifies *p_buf@*/ /*@function static int cppReader_getC (cppReader *p_pfile) modifies *p_pfile; @*/ # define cppReader_getC(pfile) (cppBuffer_get (cppReader_getBufferSafe (pfile))) +/*@function static int cppReader_reachedEOF (sef cppReader *p_pfile) modifies *p_pfile; @*/ +# define cppReader_reachedEOF(pfile) (cppBuffer_reachedEOF (cppReader_getBufferSafe (pfile))) + /*@function static int cppReader_peekC (cppReader *) modifies nothing;@*/ # define cppReader_peekC(pfile) (cpplib_bufPeek (cppReader_getBufferSafe (pfile))) @@ -349,6 +360,8 @@ static void cppReader_scanBuffer (cppReader *p_pfile); # if defined (WIN32) || defined (OS2) && defined (__IBMC__) +/* SMF */ +# ifndef BCC32 /* ** WIN32 (at least the VC++ include files) does not define mode_t. */ @@ -356,6 +369,7 @@ static void cppReader_scanBuffer (cppReader *p_pfile); /*@-incondefs@*/ /*@-czechtypes@*/ typedef unsigned int mode_t; /*@=incondefs@*/ /*@=czechtypes@*/ +# endif # endif @@ -762,11 +776,17 @@ cppReader_appendIncludeChain (cppReader *pfile, opts->first_bracket_include = first; for (dir = first; ; dir = dir->next) { - int len = cstring_length (dir->fname) + INCLUDE_LEN_FUDGE; + size_t len = cstring_length (dir->fname) + INCLUDE_LEN_FUDGE; + if (len > pfile->max_include_len) - pfile->max_include_len = len; + { + pfile->max_include_len = len; + } + if (dir == last) - break; + { + break; + } } } @@ -843,8 +863,9 @@ cppReader_addIncludeChain (cppReader *pfile, /*@only@*/ struct file_name_list *d if (opts->first_bracket_include == 0) { - int len = cstring_length (dir->fname) + INCLUDE_LEN_FUDGE; + size_t len = cstring_length (dir->fname) + INCLUDE_LEN_FUDGE; opts->first_bracket_include = dir; + if (len > pfile->max_include_len) { pfile->max_include_len = len; @@ -949,6 +970,9 @@ cppOptions_init (cppOptions *opts) opts->warn_comments = 0; opts->warnings_are_errors = 0; + /* Added 2003-07-10: */ + opts->traditional = FALSE; + opts->c89 = TRUE; initialize_char_syntax (opts); } @@ -1806,7 +1830,7 @@ collect_expansion (cppReader *pfile, char *buf, char *limit, llfatalbug (cstring_makeLiteral ("Maximum definition size exceeded.")); } - return defn; + /*@i1@*/ return defn; /* Spurious warning here */ } /* @@ -1870,7 +1894,6 @@ collect_expansionLoc (fileloc loc, char *buf, char *limit, defn->pattern = NULL; defn->nargs = nargs; defn->predefined = NULL; - exp_p = defn->expansion = (char *) defn + sizeof (*defn); defn->line = 0; @@ -2153,7 +2176,7 @@ collect_expansionLoc (fileloc loc, char *buf, char *limit, llfatalbug (cstring_makeLiteral ("Maximum definition size exceeded.")); } - return defn; + /*@i1@*/ return defn; /* Spurious warning here */ } /* @@ -2741,22 +2764,24 @@ compare_defs (DEFINITION *d1, DEFINITION *d2) if (a1 != a2) return TRUE; - if (comp_def_part (first, p1, d1->length - (p1 - d1->expansion), - p2, d2->length - (p2 - d2->expansion), 1)) + if (comp_def_part (first, p1, size_toInt (d1->length - (p1 - d1->expansion)), + p2, size_toInt (d2->length - (p2 - d2->expansion)), 1)) return TRUE; return FALSE; } -/* Return TRUE if two parts of two macro definitions are effectively different. - One of the parts starts at BEG1 and has LEN1 chars; - the other has LEN2 chars at BEG2. - Any sequence of whitespace matches any other sequence of whitespace. - FIRST means these parts are the first of a macro definition; - so ignore leading whitespace entirely. - LAST means these parts are the last of a macro definition; - so ignore trailing whitespace entirely. */ - /*@i2@*/ +/* +** Return TRUE if two parts of two macro definitions are effectively different. +** One of the parts starts at BEG1 and has LEN1 chars; +** the other has LEN2 chars at BEG2. +** Any sequence of whitespace matches any other sequence of whitespace. +** FIRST means these parts are the first of a macro definition; +** so ignore leading whitespace entirely. +** LAST means these parts are the last of a macro definition; +** so ignore trailing whitespace entirely. +*/ + static bool comp_def_part (bool first, char *beg1, int len1, char *beg2, int len2, bool last) { @@ -2782,12 +2807,14 @@ comp_def_part (bool first, char *beg1, int len1, char *beg2, int len2, bool last return (beg1 != end1) || (beg2 != end2); } -/* Process a #define command. - BUF points to the contents of the #define command, as a contiguous string. - LIMIT points to the first character past the end of the definition. - KEYWORD is the keyword-table entry for #define, - or NULL for a "predefined" macro. */ - /*@i2@*/ +/* +** Process a #define command. +** BUF points to the contents of the #define command, as a contiguous string. +** LIMIT points to the first character past the end of the definition. +** KEYWORD is the keyword-table entry for #define, +** or NULL for a "predefined" macro. +*/ + static int do_defineAux (cppReader *pfile, struct directive *keyword, /*@exposed@*/ char *buf, char *limit, bool noExpand) @@ -2795,20 +2822,14 @@ do_defineAux (cppReader *pfile, struct directive *keyword, int hashcode; macroDef mdef; hashNode hp; - /*@i2@*/ - DPRINTF (("Define aux: %d", noExpand)); - /*@i2@*/ + mdef = create_definition (buf, limit, pfile, keyword == NULL, noExpand); if (mdef.defn == 0) goto nope; - /*@i2@*/ + hashcode = cpphash_hashCode (mdef.symnam, mdef.symlen, CPP_HASHSIZE); - /*@i2@*/ - DPRINTF (("Macro: %s / %s", - cstring_copyLength (mdef.symnam, mdef.symlen), - bool_unparse (noExpand))); - /*@i2@*/ + if ((hp = cpphash_lookup (mdef.symnam, size_toInt (mdef.symlen), hashcode)) != NULL) { bool ok = FALSE; @@ -2823,9 +2844,9 @@ do_defineAux (cppReader *pfile, struct directive *keyword, else if (hp->type == T_CONST) ok = !CPPOPTIONS (pfile)->done_initializing; else { - BADBRANCH; + ok = FALSE; /* Redefining anything else is bad. */ } - /*@i2@*/ + /* Print the warning if it's not ok. */ if (!ok) { @@ -2841,7 +2862,7 @@ do_defineAux (cppReader *pfile, struct directive *keyword, } cpp_setLocation (pfile); - /*@i2@*/ + if (hp->type == T_MACRO) { if (hp->value.defn->noExpand) @@ -2866,7 +2887,6 @@ do_defineAux (cppReader *pfile, struct directive *keyword, message ("Macro %q already defined", cstring_copyLength (mdef.symnam, mdef.symlen))); - /*@i2@*/ } } @@ -2882,7 +2902,7 @@ do_defineAux (cppReader *pfile, struct directive *keyword, */ hashNode hn; - /*@i2@*/ + if (CPPOPTIONS (pfile)->debug_output && (keyword != NULL)) { pass_thru_directive (buf, limit, pfile, keyword); @@ -2896,9 +2916,8 @@ do_defineAux (cppReader *pfile, struct directive *keyword, } /*@=branchstate@*/ return 0; - /*@i2@*/ + nope: - /*@i2@*/ return 1; } @@ -2909,21 +2928,23 @@ do_define (cppReader *pfile, struct directive *keyword, DPRINTF (("Regular do define")); return do_defineAux (pfile, keyword, buf, limit, FALSE); } - /*@i2@*/ -/* This structure represents one parsed argument in a macro call. - `raw' points to the argument text as written (`raw_length' is its length). - `expanded' points to the argument's macro-expansion - (its length is `expand_length'). - `stringified_length' is the length the argument would have - if stringified. - `use_count' is the number of times this macro arg is substituted - into the macro. If the actual use count exceeds 10, - the value stored is 10. */ - /*@i2@*/ + +/* +** This structure represents one parsed argument in a macro call. +** `raw' points to the argument text as written (`raw_length' is its length). +** `expanded' points to the argument's macro-expansion +** (its length is `expand_length'). +** `stringified_length' is the length the argument would have +** if stringified. +** `use_count' is the number of times this macro arg is substituted +** into the macro. If the actual use count exceeds 10, +** the value stored is 10. +*/ + /* raw and expanded are relative to ARG_BASE */ /*@notfunction@*/ #define ARG_BASE ((pfile)->token_buffer) - /*@i2@*/ + struct argdata { /* Strings relative to pfile->token_buffer */ long raw; @@ -2936,11 +2957,13 @@ struct argdata { int use_count; }; -/* Allocate a new cppBuffer for PFILE, and push it on the input buffer stack. - If BUFFER != NULL, then use the LENGTH characters in BUFFER - as the new input buffer. - Return the new buffer, or NULL on failure. */ - /*@i2@*/ +/* +** Allocate a new cppBuffer for PFILE, and push it on the input buffer stack. +** If BUFFER != NULL, then use the LENGTH characters in BUFFER +** as the new input buffer. +** Return the new buffer, or NULL on failure. +*/ + /*@null@*/ /*@exposed@*/ cppBuffer * cppReader_pushBuffer (cppReader *pfile, char *buffer, size_t length) { @@ -2982,7 +3005,7 @@ cppReader_pushBuffer (cppReader *pfile, char *buffer, size_t length) return buf; } - /*@i2@*/ + cppBuffer * cppReader_popBuffer (cppReader *pfile) { @@ -2994,9 +3017,11 @@ cppReader_popBuffer (cppReader *pfile) return ++CPPBUFFER (pfile); } -/* Scan until CPPBUFFER (PFILE) is exhausted into PFILE->token_buffer. - Pop the buffer when done. */ - /*@i2@*/ +/* +** Scan until CPPBUFFER (PFILE) is exhausted into PFILE->token_buffer. +** Pop the buffer when done. +*/ + void cppReader_scanBuffer (cppReader *pfile) { @@ -3019,7 +3044,6 @@ cppReader_scanBuffer (cppReader *pfile) } } } - /*@i2@*/ /* * Rescan a string (which may have escape marks) into pfile's buffer. @@ -3234,8 +3258,7 @@ output_line_command (cppReader *pfile, bool conditional, } } - cpplib_reserve (pfile, - size_fromInt (4 * cstring_length (ip->nominal_fname) + 50)); + cpplib_reserve (pfile, 4 * cstring_length (ip->nominal_fname) + 50); { #ifdef OUTPUT_LINE_COMMANDS @@ -3453,6 +3476,14 @@ special_symbol (hashNode hp, cppReader *pfile) quote_string (pfile, string); return; } + case T_FUNC: /* added in ISO C99 */ + { + /* We don't know the actual name of the function, but it doesn't matter */ + char *string = "** function-name **"; + cpplib_reserve (pfile, 3 + 4 * strlen (string)); + quote_string (pfile, string); + return; + } case T_INCLUDE_LEVEL: true_indepth = 0; @@ -3674,7 +3705,7 @@ cpplib_installBuiltinType (/*@observer@*/ char *name, ctype ctyp, if (!usymtab_existsTypeEither (sname)) { uentry ue = uentry_makeDatatype (sname, ctyp, - NO, NO, + NO, qual_createConcrete (), fileloc_createBuiltin ()); llassert (!usymtab_existsEither (sname)); usymtab_addGlobalEntry (ue); @@ -3690,6 +3721,7 @@ initialize_builtins (cppReader *pfile) cpplib_installBuiltin ("__DATE__", ctype_string, -1, T_DATE, 0, NULL, -1); cpplib_installBuiltin ("__FILE__", ctype_string, -1, T_FILE, 0, NULL, -1); cpplib_installBuiltin ("__BASE_FILE__", ctype_string, -1, T_BASE_FILE, 0, NULL, -1); + cpplib_installBuiltin ("__func__", ctype_string, -1, T_FUNC, 0, NULL, -1); cpplib_installBuiltin ("__INCLUDE_LEVEL__", ctype_int, -1, T_INCLUDE_LEVEL, 0, NULL, -1); cpplib_installBuiltin ("__VERSION__", ctype_string, -1, T_VERSION, 0, NULL, -1); #ifndef NO_BUILTIN_SIZE_TYPE @@ -3703,18 +3735,11 @@ initialize_builtins (cppReader *pfile) cpplib_installBuiltin ("__REGISTER_PREFIX__", ctype_string, -1, T_REGISTER_PREFIX_TYPE, 0, NULL, -1); cpplib_installBuiltin ("__TIME__", ctype_string, -1, T_TIME, 0, NULL, -1); - /* - ** No, don't define __STDC__ - ** - if (!cppReader_isTraditional (pfile)) { cpplib_installBuiltin ("__STDC__", ctype_int, -1, T_CONST, STDC_VALUE, NULL, -1); } - ** - */ - # ifdef WIN32 cpplib_installBuiltin ("_WIN32", ctype_int, -1, T_CONST, STDC_VALUE, NULL, -1); # endif @@ -3979,7 +4004,7 @@ cpplib_macroExpand (cppReader *pfile, /*@dependent@*/ hashNode hp) args[i].raw = size_toLong (cpplib_getWritten (pfile)); token = macarg (pfile, rest_args); - args[i].raw_length = cpplib_getWritten (pfile) - args[i].raw; + args[i].raw_length = size_toInt (cpplib_getWritten (pfile) - args[i].raw); args[i].newlines = FALSE; /* FIXME */ } else @@ -4202,9 +4227,8 @@ cpplib_macroExpand (cppReader *pfile, /*@dependent@*/ hashNode hp) } else if (ap->raw_before || ap->raw_after || cppReader_isTraditional (pfile)) { - /* Add 4 for two newline-space markers to prevent - token concatenation. */ - assertSet (args); /*@i534 shouldn't need this */ + /* Add 4 for two newline-space markers to prevent token concatenation. */ + assertSet (args); /* Splint shouldn't need this */ xbuf_len += args[ap->argno].raw_length + 4; } else @@ -4212,7 +4236,7 @@ cpplib_macroExpand (cppReader *pfile, /*@dependent@*/ hashNode hp) /* We have an ordinary (expanded) occurrence of the arg. So compute its expansion, if we have not already. */ - assertSet (args); /*@i534 shouldn't need this */ + assertSet (args); /* shouldn't need this */ if (args[ap->argno].expand_length < 0) { @@ -4647,8 +4671,8 @@ do_include (cppReader *pfile, struct directive *keyword, /*@=onlytrans@*/ nam[n] = save; - if (n + INCLUDE_LEN_FUDGE > pfile->max_include_len) - pfile->max_include_len = n + INCLUDE_LEN_FUDGE; + if (n + INCLUDE_LEN_FUDGE > size_toInt (pfile->max_include_len)) + pfile->max_include_len = size_fromInt (n + INCLUDE_LEN_FUDGE); } else { @@ -4859,7 +4883,7 @@ do_include (cppReader *pfile, struct directive *keyword, if (f == IMPORT_FOUND) { - return 0; /* Already included this file */ + return 0; /* Already included this file */ } #ifdef EACCES else if (f == IMPORT_NOT_FOUND && errno == EACCES) @@ -5541,8 +5565,8 @@ do_xifdef (cppReader *pfile, struct directive *keyword, if (start_of_file && !skip) { DPRINTF (("Not skipping!")); - control_macro = (char *) dmalloc (size_fromInt (ident_length + 1)); - memcpy (control_macro, ident, size_fromInt (ident_length + 1)); + control_macro = (char *) dmalloc (ident_length + 1); + memcpy (control_macro, ident, ident_length + 1); } } else @@ -6095,14 +6119,18 @@ get_next: &start_line, &start_column); old_written = cpplib_getWritten (pfile); string: - DPRINTF (("Put char: %c", c)); + DPRINTF (("Reading string: %c", c)); cppReader_putChar (pfile, c); while (TRUE) { - int cc = cppReader_getC (pfile); - DPRINTF (("cc: %c", c)); - if (cc == EOF) + /* evans-2003-06-07 + ** Because of ISO8859-1 characters in string literals, we need a special test here. + */ + + if (cppReader_reachedEOF (pfile)) { + + DPRINTF (("Matches EOF!")); if (cppBuffer_isMacro (CPPBUFFER (pfile))) { /* try harder: this string crosses a macro expansion @@ -6116,13 +6144,14 @@ get_next: CPPBUFFER (pfile) = next_buf; continue; } + if (!cppReader_isTraditional (pfile)) { cpp_setLocation (pfile); setLine (long_toInt (start_line)); setColumn (long_toInt (start_column)); - + if (pfile->multiline_string_line != long_toInt (start_line) && pfile->multiline_string_line != 0) { @@ -6142,59 +6171,64 @@ get_next: message ("Unterminated string or character constant")); } } - /*@loopbreak@*/ break; - } - DPRINTF (("putting char: %c", cc)); - cppReader_putChar (pfile, cc); - switch (cc) + /*@loopbreak@*/ break; + } + else { - case '\n': - /* Traditionally, end of line ends a string constant with - no error. So exit the loop and record the new line. */ - if (cppReader_isTraditional (pfile)) - goto while2end; - if (c == '\'') - { - goto while2end; - } - if (cppReader_isPedantic (pfile) - && pfile->multiline_string_line == 0) - { - cppReader_pedwarnWithLine - (pfile, long_toInt (start_line), - long_toInt (start_column), - cstring_makeLiteral ("String constant runs past end of line")); - } - if (pfile->multiline_string_line == 0) - { - pfile->multiline_string_line = start_line; - } - - /*@switchbreak@*/ break; - - case '\\': - cc = cppReader_getC (pfile); - if (cc == '\n') - { - /* Backslash newline is replaced by nothing at all. */ - cppReader_adjustWritten (pfile, -1); - pfile->lineno++; - } - else + int cc = cppReader_getC (pfile); + DPRINTF (("cc: %c [%d] [%d]", cc, cc, EOF)); + DPRINTF (("putting char: %c", cc)); + cppReader_putChar (pfile, cc); + switch (cc) { - /* ANSI stupidly requires that in \\ the second \ - is *not* prevented from combining with a newline. */ - NEWLINE_FIX1(cc); - if (cc != EOF) - cppReader_putChar (pfile, cc); + case '\n': + /* Traditionally, end of line ends a string constant with + no error. So exit the loop and record the new line. */ + if (cppReader_isTraditional (pfile)) + goto while2end; + if (c == '\'') + { + goto while2end; + } + if (cppReader_isPedantic (pfile) + && pfile->multiline_string_line == 0) + { + cppReader_pedwarnWithLine + (pfile, long_toInt (start_line), + long_toInt (start_column), + cstring_makeLiteral ("String constant runs past end of line")); + } + if (pfile->multiline_string_line == 0) + { + pfile->multiline_string_line = start_line; + } + + /*@switchbreak@*/ break; + + case '\\': + cc = cppReader_getC (pfile); + if (cc == '\n') + { + /* Backslash newline is replaced by nothing at all. */ + cppReader_adjustWritten (pfile, -1); + pfile->lineno++; + } + else + { + /* ANSI stupidly requires that in \\ the second \ + is *not* prevented from combining with a newline. */ + NEWLINE_FIX1(cc); + if (cc != EOF) + cppReader_putChar (pfile, cc); + } + /*@switchbreak@*/ break; + + case '\"': + case '\'': + if (cc == c) + goto while2end; + /*@switchbreak@*/ break; } - /*@switchbreak@*/ break; - - case '\"': - case '\'': - if (cc == c) - goto while2end; - /*@switchbreak@*/ break; } } while2end: @@ -6362,10 +6396,20 @@ get_next: op2: token = CPP_OTHER; pfile->only_seen_white = 0; - op2any: + op2any: /* jumped to for \ continuations */ cpplib_reserve(pfile, 3); cppReader_putCharQ (pfile, c); - cppReader_putCharQ (pfile, cppReader_getC (pfile)); + + /* evans 2003-08-24: This is a hack to fix line output for \ + continuations. Someday I really should get a decent pre-processor! + */ + + if (c == '\\') { + (void) cppReader_getC (pfile); /* skip the newline to avoid extra lines */ + } else { + cppReader_putCharQ (pfile, cppReader_getC (pfile)); + } + cppReader_nullTerminateQ (pfile); return token; @@ -6631,6 +6675,8 @@ get_next: case '\\': c2 = cppReader_peekC (pfile); + /* allow other stuff here if a flag is set? */ + DPRINTF (("Got continuation!")); if (c2 != '\n') goto randomchar; token = CPP_HSPACE; @@ -7546,7 +7592,7 @@ void cpplib_initializeReader (cppReader *pfile) /* Must be done after library is struct default_include *p = include_defaults; char *specd_prefix = opts->include_prefix; char *default_prefix = mstring_copy (GCC_INCLUDE_DIR); - int default_len = 0; + size_t default_len = 0; /* Remove the `include' from /usr/local/lib/gcc.../include. */ if (default_prefix != NULL) { @@ -7566,8 +7612,7 @@ void cpplib_initializeReader (cppReader *pfile) /* Must be done after library is /* Does this dir start with the prefix? */ llassert (default_prefix != NULL); - if (!strncmp (cstring_toCharsSafe (p->fname), default_prefix, - size_fromInt (default_len))) + if (!strncmp (cstring_toCharsSafe (p->fname), default_prefix, default_len)) { /* Yes; change prefix and add to search list. */ struct file_name_list *nlist @@ -7609,11 +7654,13 @@ void cpplib_initializeReader (cppReader *pfile) /* Must be done after library is nlist->got_name_map = 0; nlist->next = NULL; - if (opts->first_system_include == NULL) + /* Spurious warning reported for opts->first_system_include */ + /*@-usereleased@*/ if (opts->first_system_include == NULL) { opts->first_system_include = nlist; } - + /*@=usereleased@*/ + cppReader_addIncludeChain (pfile, nlist); } } @@ -7624,11 +7671,14 @@ void cpplib_initializeReader (cppReader *pfile) /* Must be done after library is cppReader_appendIncludeChain (pfile, opts->after_include, opts->last_after_include); + /* Spurious warnings for opts->first_system_include */ + /*@-usereleased@*/ if (opts->first_system_include == NULL) { opts->first_system_include = opts->after_include; } - + /*@=usereleased@*/ + /* With -v, print the list of dirs to search. */ if (opts->verbose) { struct file_name_list *p; @@ -8440,8 +8490,27 @@ static bool cpp_skipIncludeFile (cstring fname) if (context_getFlag (FLG_SKIPSYSHEADERS)) { - DPRINTF (("Skip include TRUE: %s", fname)); - return TRUE; + /* + ** 2003-04-18: Patch from Randal Parsons + */ + + /* + ** Don't skip include file unless the file actually exists. + ** It may be in a different directory. + */ + + int f = open (cstring_toCharsSafe (fname), O_RDONLY, 0666); + + if (f >= 0) + { + check (close (f) == 0); + DPRINTF (("Skip include TRUE: %s", fname)); + return TRUE; + } + else + { + /* Keep looking... */ + } } } @@ -8487,3 +8556,4 @@ void cppBuffer_forward (cppBuffer *buf, int n) } /*@=bufferoverflowhigh@*/ +/*@=bounds@*/