X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/616915ddfdcba888735f45cbd9c26c9b5383ee2c..a9ec328054b628447830161535f4915f715f49cd:/src/macrocache.c diff --git a/src/macrocache.c b/src/macrocache.c index 2db8944..0db6792 100644 --- a/src/macrocache.c +++ b/src/macrocache.c @@ -1,6 +1,6 @@ /* -** LCLint - annotation-assisted static program checker -** Copyright (C) 1994-2000 University of Virginia, +** Splint - annotation-assisted static program checker +** Copyright (C) 1994-2003 University of Virginia, ** Massachusetts Institute of Technology ** ** This program is free software; you can redistribute it and/or modify it @@ -17,9 +17,9 @@ ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, ** MA 02111-1307, USA. ** -** For information on lclint: lclint-request@cs.virginia.edu -** To report a bug: lclint-bug@cs.virginia.edu -** For more information: http://lclint.cs.virginia.edu +** For information on splint: info@splint.org +** To report a bug: splint-bug@splint.org +** For more information: http://www.splint.org */ /* ** macrocache.c @@ -29,8 +29,8 @@ ** */ -# include "lclintMacros.nf" -# include "llbasic.h" +# include "splintMacros.nf" +# include "basic.h" # include "llmain.h" /*@constant int MCEBASESIZE;@*/ @@ -43,7 +43,7 @@ ** Temporary file used for processing macros. */ -static /*@null@*/ FILE *s_macFile = NULL; +static /*:open:*/ /*@null@*/ FILE *s_macFile = NULL; /* ** mcDisable is set to TRUE when a macro is being processed, so @@ -97,7 +97,7 @@ macrocache_free (macrocache s) for (i = 0; i < s->entries; i++) { - mce_free (s->contents[i]); + mce_free (s->contents[i]); } sfree (s->contents); @@ -115,7 +115,7 @@ macrocache_grow (macrocache s) for (i = 0; i < s->entries; i++) { - s->contents[i] = oldcontents[i]; + s->contents[i] = oldcontents[i]; } sfree (oldcontents); @@ -136,7 +136,7 @@ macrocache_addGenEntry (macrocache s, /*@only@*/ fileloc fl, if ((i = macrocache_exists (s, fl)) != DNE) { - if (cstring_equal (def, s->contents[i]->def)) + if (cstring_equal (def, s->contents[i]->def)) { fileloc_free (fl); cstring_free (def); @@ -153,7 +153,7 @@ macrocache_addGenEntry (macrocache s, /*@only@*/ fileloc fl, */ cstring_free (s->contents[i]->def); - s->contents[i]->def = def; + s->contents[i]->def = def; fileloc_free (fl); return; @@ -165,7 +165,7 @@ macrocache_addGenEntry (macrocache s, /*@only@*/ fileloc fl, } s->nspace--; - s->contents[s->entries] = mce_create (fl, def, sup); + s->contents[s->entries] = mce_create (fl, def, sup); s->entries++; } @@ -179,6 +179,7 @@ macrocache_addEntry (macrocache s, /*@only@*/ fileloc fl, /*@only@*/ cstring def void macrocache_addComment (macrocache s, /*@only@*/ fileloc fl, /*@only@*/ cstring def) { + DPRINTF (("Macrocache add comment: %s / %s", fileloc_unparse (fl), def)); macrocache_addGenEntry (s, fl, def, TRUE); } @@ -189,7 +190,7 @@ macrocache_exists (macrocache s, fileloc fl) for (i = 0; i < s->entries; i++) { - if (fileloc_equal (s->contents[i]->fl, fl)) + if (fileloc_equal (s->contents[i]->fl, fl)) return (i); } @@ -204,7 +205,7 @@ macrocache_unparse (macrocache m) for (i = 0; i < m->entries; i++) { - fileloc fl = m->contents[i]->fl; + fileloc fl = m->contents[i]->fl; cstring def = m->contents[i]->def; bool defined = m->contents[i]->defined; @@ -235,8 +236,8 @@ static void pushString (/*@only@*/ cstring s) cstring fname; mtid = fileTable_addMacrosFile (context_fileTable ()); - fname = fileName (mtid); - s_macFile = fopen (cstring_toCharsSafe (fname), "wb+"); + fname = fileTable_fileName (mtid); + s_macFile = fileTable_createMacrosFile (context_fileTable (), fname); /* , "wb+"); ? **/ if (s_macFile == NULL) { @@ -276,9 +277,9 @@ static void pushString (/*@only@*/ cstring s) static void macrocache_processMacro (macrocache m, int i) { - fileloc fl = m->contents[i]->fl; + fileloc fl = m->contents[i]->fl; - m->contents[i]->defined = TRUE; + m->contents[i]->defined = TRUE; if (!fileId_equal (currentFile (), fileloc_fileId (fl))) { @@ -313,11 +314,15 @@ macrocache_processMacro (macrocache m, int i) if (context_inSuppressRegion () && !insup) { - llerrorlit (FLG_SYNTAX, "Macro ends in ignore region"); + voptgenerror + (FLG_SYNTAX, + message ("Macro ends in ignore region: %s", m->contents[i]->def), + fl); } } incLine (); + context_exitAllClauses (); context_exitMacroCache (); } @@ -334,7 +339,7 @@ extern void macrocache_processUndefinedElements (macrocache m) { for (i = 0; i < m->entries; i++) { - if (m->contents[i]->defined) + if (m->contents[i]->defined) { ; } @@ -348,12 +353,10 @@ extern void macrocache_processUndefinedElements (macrocache m) } else { - if (context_getFlag (FLG_SHOWSCAN)) + if (!fileloc_isLib (fl)) { - if (!fileloc_isLib (fl)) - { - lldiagmsg (message ("< checking macros %s >", fileloc_filename (fl))); - } + displayScan (message ("checking macros %q", + fileloc_outputFilename (fl))); } lastfl = fl; @@ -377,7 +380,7 @@ extern /*@observer@*/ fileloc macrocache_processFileElements (macrocache m, cstr for (i = 0; i < m->entries; i++) { - if (m->contents[i]->defined) + if (m->contents[i]->defined) { ; } @@ -402,7 +405,7 @@ void macrocache_finalize (void) { if (s_macFile != NULL) { - check (fclose (s_macFile) == 0); + check (fileTable_closeFile (context_fileTable (), s_macFile)); s_macFile = NULL; } }