X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/1b8ae6904556859bbe91aadf35b8adcc1a0611ce..35b9a1d988c06908076e3a6eeae55b1147879607:/src/cppmain.c diff --git a/src/cppmain.c b/src/cppmain.c index 1ebcc1b..7cd4a0a 100644 --- a/src/cppmain.c +++ b/src/cppmain.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 @@ -17,8 +17,8 @@ ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, ** MA 02111-1307, USA. ** -** For information on splint: splint@cs.virginia.edu -** To report a bug: splint-bug@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 */ /* @@ -52,6 +52,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # include "cpphash.h" # include "cpperror.h" # include "llmain.h" +# include "osd.h" # include @@ -88,6 +89,12 @@ void cppReader_initMod () /*@-compdef@*/ /* g_cppState is not yet innitialized */ } /*@=compdef@*/ +void cppReader_destroyMod () + /*@globals killed g_cppState@*/ +{ + cppCleanup (&g_cppState); +} + void cppReader_initialize () { cpplib_initializeReader (&g_cppState); @@ -115,11 +122,12 @@ int cppProcess (/*@dependent@*/ cstring infile, llexit (LLFAILURE); } - ofile = fileTable_openFile (context_fileTable (), outfile, "w"); + ofile = fileTable_createFile (context_fileTable (), outfile); if (ofile == NULL) { fileTable_noDelete (context_fileTable (), outfile); + osd_setTempError (); llfatalerror (message ("Cannot create temporary file for " "pre-processor output. Trying to " "open: %s. Use -tmpdir to change " @@ -135,6 +143,8 @@ int cppProcess (/*@dependent@*/ cstring infile, if (!opts->no_output) { + DPRINTF (("Writing: %s", cstring_copyLength (g_cppState.token_buffer, cpplib_getWritten (&g_cppState)))); + (void) fwrite (g_cppState.token_buffer, (size_t) 1, cpplib_getWritten (&g_cppState), ofile); } @@ -172,6 +182,8 @@ void cppAddIncludeDir (cstring dir) ** Add the -I- code. This code provided by Robin Watts */ + DPRINTF (("Adding include: %s", dir)); + if (cstring_equalLit (dir, "-I-")) { struct cppOptions *opts = CPPOPTIONS (&g_cppState); @@ -179,11 +191,10 @@ void cppAddIncludeDir (cstring dir) } else { - /* -I option (Add directory to include path) */ struct file_name_list *dirtmp = (struct file_name_list *) dmalloc (sizeof (*dirtmp)); DPRINTF (("Add include: %s", dir)); - + dirtmp->next = 0; /* New one goes on the end */ dirtmp->control_macro = 0; dirtmp->c_system_include_path = FALSE; @@ -209,14 +220,14 @@ void cppDoDefine (cstring str) void cppDoUndefine (cstring str) { - int sym_length; + size_t sym_length; hashNode hp; char *buf = cstring_toCharsSafe (str); sym_length = cppReader_checkMacroName (&g_cppState, buf, - cstring_makeLiteralTemp ("macro")); + cstring_makeLiteralTemp ("macro")); - while ((hp = cpphash_lookup (buf, sym_length, -1)) != NULL) + while ((hp = cpphash_lookup (buf, size_toInt (sym_length), -1)) != NULL) { /*@-exposetrans@*/ /*@-dependenttrans@*/ cppReader_deleteMacro (hp);