]> andersk Git - splint.git/blobdiff - src/cppmain.c
Fixed pre-processing bug reported by Adam Clarke. Moved marking point
[splint.git] / src / cppmain.c
index d10b2cc65daf0132d550ec0fb8c6ce818e5bc1f3..a01bf67424ac2fbdcb4b53ea33677908d0e393ee 100644 (file)
@@ -116,7 +116,7 @@ int cppProcess (/*@dependent@*/ cstring infile,
       llexit (LLFAILURE);
     }
 
-  ofile = fileTable_openFile (context_fileTable (), outfile, "w");
+  ofile = fileTable_createFile (context_fileTable (), outfile);
   
   if (ofile == NULL) 
     {
@@ -137,6 +137,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);
        }
@@ -174,6 +176,8 @@ void cppAddIncludeDir (cstring dir)
   ** Add the -I- code.  This code provided by Robin Watts <Robin.Watts@wss.co.uk>
   */
 
+  DPRINTF (("Adding include: %s", dir));
+
   if (cstring_equalLit (dir, "-I-"))
     {
       struct cppOptions *opts = CPPOPTIONS (&g_cppState);    
@@ -184,8 +188,11 @@ void cppAddIncludeDir (cstring dir)
       /* -I option (Add directory to include path) */
       struct file_name_list *dirtmp = (struct file_name_list *) dmalloc (sizeof (*dirtmp));
       
+      llassert (cstring_firstChar (dir) == 'I');
+      dir = cstring_suffix (dir, 1);
+
       DPRINTF (("Add include: %s", dir));
-      
+
       dirtmp->next = 0;                /* New one goes on the end */
       dirtmp->control_macro = 0;
       dirtmp->c_system_include_path = FALSE;
@@ -211,14 +218,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);
This page took 0.038893 seconds and 4 git commands to generate.