# include "lclintMacros.nf"
# include "llbasic.h"
# include "lcllib.h"
-# include "cpp.h"
# include "cpplib.h"
# include "cpperror.h"
# include "cpphash.h"
static enum cpp_token cpp_handleComment (cppReader *p_pfile,
struct parse_marker *p_smark)
- /*@modifies *p_pfile, *p_smark@*/;
+ /*@modifies p_pfile, p_smark@*/;
static bool cpp_shouldCheckMacro (cppReader *p_pfile, char *p_p) /*@*/ ;
static void push_macro_expansion (cppReader *,
/*@owned@*/ char *, size_t,
- /*@dependent@*/ HASHNODE *);
+ /*@dependent@*/ hashNode);
/* Last arg to output_line_command. */
enum file_change_code {
}
}
+cstring
+cppReader_getIncludePath ()
+{
+ cppReader *pfile = &g_cppState;
+ struct file_name_list *dirs = CPPOPTIONS (pfile)->include;
+ cstring res = cstring_undefined;
+
+ if (dirs != NULL)
+ {
+ while (dirs != NULL)
+ {
+ res = message ("%q%c%s", res, PATH_SEPARATOR, dirs->fname);
+ dirs = dirs->next;
+ }
+ }
+ else
+ {
+ res = cstring_makeLiteral ("<no include path>");
+ }
+
+ return res;
+}
+
void
cppReader_addIncludeChain (cppReader *pfile, struct file_name_list *dir)
{
opts->for_lint = 0;
opts->chill = 0;
opts->pedantic_errors = 0;
- opts->inhibit_warnings = 0;
opts->warn_comments = 0;
opts->warnings_are_errors = 0;
void
cppReader_macroCleanup (cppBuffer *pbuf, /*@unused@*/ cppReader *pfile)
{
- HASHNODE *macro = pbuf->hnode;
+ hashNode macro = pbuf->hnode;
if (macro->type == T_DISABLED)
{
if (limit - p >= 2 && p[0] == '#' && p[1] == '#') {
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("`##' at start of macro definition"));
+ cstring_makeLiteralTemp ("`##' at start of macro definition"));
p += 2;
}
{
int hashcode;
MACRODEF mdef;
- HASHNODE *hp;
+ hashNode hp;
DPRINTF (("Define aux: %d", noExpand));
** that for this new definition now.
*/
- HASHNODE *hn;
+ hashNode hn;
if (CPPOPTIONS (pfile)->debug_output && (keyword != NULL))
{
*/
static void
-special_symbol (HASHNODE *hp, cppReader *pfile)
+special_symbol (hashNode hp, cppReader *pfile)
{
cstring buf = cstring_undefined;
size_t len;
an argument list follows; arguments come from the input stack. */
static void
-macroexpand (cppReader *pfile, /*@dependent@*/ HASHNODE *hp)
+macroexpand (cppReader *pfile, /*@dependent@*/ hashNode hp)
{
int nargs;
DEFINITION *defn = hp->value.defn;
size_t totlen; /* total amount of exp buffer filled so far */
register struct reflist *ap, *last_ap;
+
+ assertSet (args); /* args is defined since the nargs > 0 path was taken */
/* Macro really takes args. Compute the expansion of this call. */
{
/* Add 4 for two newline-space markers to prevent
token concatenation. */
+ assertSet (args); /*@i534 shouldn't need this */
xbuf_len += args[ap->argno].raw_length + 4;
}
else
/* 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 */
+
if (args[ap->argno].expand_length < 0)
{
args[ap->argno].expanded = cppReader_getWritten (pfile);
static void
push_macro_expansion (cppReader *pfile, char *xbuf, size_t xbuf_len,
- /*@dependent@*/ HASHNODE *hp)
+ /*@dependent@*/ hashNode hp)
{
cppBuffer *mbuf = cppReader_pushBuffer (pfile, xbuf, xbuf_len);
if (token == CPP_STRING) {
char *fname = pfile->token_buffer + old_written;
char *end_name;
- static HASHNODE *fname_table[FNAME_HASHSIZE];
- HASHNODE *hp, **hash_bucket;
+ static hashNode fname_table[FNAME_HASHSIZE];
+ hashNode hp;
+ hashNode *hash_bucket;
char *p;
size_t num_start;
int fname_length;
if (hp == 0) {
/* Didn't find it; cons up a new one. */
- hp = (HASHNODE *) dmalloc (sizeof (*hp) + fname_length + 1);
+ hp = (hashNode) dmalloc (sizeof (*hp));
hp->prev = NULL;
hp->bucket_hdr = NULL;
{
int sym_length;
- HASHNODE *hp;
+ hashNode hp;
char *orig_buf = buf;
SKIP_WHITE_SPACE (buf);
/*@unused@*/ char *buf,
/*@unused@*/ int length)
{
- HASHNODE *save_defined;
+ hashNode save_defined;
HOST_WIDE_INT value;
size_t old_written = cppReader_getWritten (pfile);
}
else if (token == CPP_NAME)
{
- HASHNODE *hp = cppReader_lookup (ident, ident_length, -1);
+ hashNode hp = cppReader_lookup (ident, ident_length, -1);
skip = (keyword->type == T_IFDEF)
? (hp == NULL) : (hp != NULL);
case 'Y': case 'Z':
letter:
{
- HASHNODE *hp;
+ hashNode hp;
char *ident;
size_t before_name_written = cppReader_getWritten (pfile);
int ident_len;
void cppReader_initializeReader (cppReader *pfile) /* Must be done after library is loaded. */
{
struct cppOptions *opts = CPPOPTIONS (pfile);
- char *xp;
+ cstring xp;
/* The code looks at the defaults through this pointer, rather than through
the constant structure above. This pointer gets changed if an environment
but that seems pointless: it comes before them, so it overrides them
anyway. */
- xp = (char *) getenv ("CPATH");
+ xp = osd_getEnvironmentVariable (INCLUDEPATH_VAR);
- if (xp != 0 && ! opts->no_standard_includes)
+ if (cstring_isDefined (xp) && !opts->no_standard_includes)
{
- path_include (pfile, xp);
+ path_include (pfile, cstring_toCharsSafe (xp));
}
/* Now that dollars_in_ident is known, initialize is_idchar. */
line = cppReader_getBuffer (pfile)->lineno;
fileloc_free (g_currentloc);
- g_currentloc = fileloc_create (fid, line, 1);
+
+ if (fileId_isValid (fid))
+ {
+ g_currentloc = fileloc_create (fid, line, 1);
+ }
+ else
+ {
+ g_currentloc = fileloc_createBuiltin ();
+ }
}
else
{
if (start[i] == '/'
&& i < len - 1
&& start[i + 1] == '*') {
- /*@i32 make vgenopterror work in cpp... @*/
- if (context_getFlag (FLG_NESTCOMMENT))
- {
- cppReader_warning
- (pfile,
- message ("Comment starts inside comment"));
- }
+ (void) cppoptgenerror (FLG_NESTCOMMENT,
+ message ("Comment starts inside comment"),
+ pfile);
}
if (start[i] != '\n')