]> andersk Git - splint.git/blobdiff - src/llmain.c
Added code to support CSV output (-csv flag).
[splint.git] / src / llmain.c
index 8b177b16577e755f3407b335d58b31528914c77f..fa9b8fe1ba8f8b574b66069b747715d4354ca483 100644 (file)
@@ -673,7 +673,29 @@ int main (int argc, char *argv[])
                      argc - 1, argv + 1);
 
   showHerald (); 
-  
+
+  if (context_getFlag (FLG_CSV)) {
+    cstring fname = context_getString (FLG_CSV);
+
+    if (cstring_isDefined (fname)) {
+      if (osd_fileExists (fname) && !context_getFlag (FLG_CSVOVERWRITE)) {
+       lldiagmsg (message ("Specified CSV output file already exists (use +csvoverwrite to automatically overwrite): %s",
+                           fname));
+      } else {
+       g_csvstream = fopen (cstring_toCharsSafe (fname), "w");
+       
+       DPRINTF (("Creating: %s", fname));
+       if (g_csvstream == NULL) {
+         lldiagmsg (message ("Cannot open file for CSV output: %s", fname));
+       } else {
+         displayScan (message ("Starting CSV output file: %s", context_getString (FLG_CSV)));
+         fprintf (g_csvstream, 
+                  "Warning, Flag Code, Flag Name, Priority, File, Line, Column, Warning Text, Additional Text\n");
+       }
+      }
+    }
+  }
+
 # ifdef DOANNOTS
   initAnnots ();
 # endif
@@ -928,12 +950,16 @@ int main (int argc, char *argv[])
 # endif
 
   cleanupFiles ();
-
+  
+  if (g_csvstream != NULL) {
+    displayScan (message ("Closing CSV file: %s", context_getString (FLG_CSV)));
+    check (fclose (g_csvstream) == 0);
+  }
+  
   if (context_getFlag (FLG_SHOWSUMMARY))
     {
       summarizeErrors (); 
     }
-
   
   {
     bool isQuiet = context_getFlag (FLG_QUIET);
This page took 0.03516 seconds and 4 git commands to generate.