]> andersk Git - splint.git/blobdiff - src/llmain.c
*** empty log message ***
[splint.git] / src / llmain.c
index 82073c9955005d05b776df9d169cd7d6a17b0104..82922fa8b53fc2130cdee1e76dedcc7b9632a575 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
 ** LCLint - annotation-assisted static program checker
 ** Copyright (C) 1994-2001 University of Virginia,
@@ -28,7 +29,7 @@
 */
 
 # include <signal.h>
-
+# include <time.h>
 /*
 ** Ensure that WIN32 and _WIN32 are both defined or both undefined.
 */
@@ -76,9 +77,7 @@
 # include "cgrammar.h"
 # include "llmain.h"
 # include "portab.h"
-# include "cpp.h"
-# include "mtreader.h"
-# include <time.h>
+
 
 extern /*@external@*/ int yydebug;
 
@@ -95,7 +94,7 @@ static void showHelp (void);
 static void interrupt (int p_i);
 
 static void loadrc (/*@open@*/ FILE *p_rcfile, cstringSList *p_passThroughArgs)
-   /*@ensures closed p_rcfile@*/ ;
+     /*@ensures closed p_rcfile@*/ ;
 
 static void describeVars (void);
 static bool specialFlagsHelp (char *p_next);
@@ -435,6 +434,7 @@ static void handlePassThroughFlag (char *arg)
   char *quotechar = strchr (curarg, '\"');
   int offset = 0;
   bool open = FALSE;
+  char *freearg = NULL;
 
   while (quotechar != NULL)
     {
@@ -457,6 +457,7 @@ static void handlePassThroughFlag (char *arg)
            }
        }
       
+      llassert (quotechar != NULL);
       *quotechar = '\0';
       offset = (quotechar - arg) + 2;
       
@@ -466,6 +467,7 @@ static void handlePassThroughFlag (char *arg)
            (message ("%s\"\'%s", 
                      cstring_fromChars (arg), 
                      cstring_fromChars (quotechar + 1))); 
+         freearg = arg;
          open = FALSE;
        }
       else
@@ -474,6 +476,7 @@ static void handlePassThroughFlag (char *arg)
            (message ("%s\'\"%s", 
                      cstring_fromChars (arg), 
                      cstring_fromChars (quotechar + 1)));
+         freearg = arg;
          open = TRUE;
        }
       
@@ -484,9 +487,10 @@ static void handlePassThroughFlag (char *arg)
   if (open)
     {
       showHerald ();
-      llerror (FLG_BADFLAG,
-              message ("Unclosed quote in flag: %s",
-                       cstring_fromChars (arg)));
+      voptgenerror (FLG_BADFLAG,
+                   message ("Unclosed quote in flag: %s",
+                            cstring_fromChars (arg)),
+                   g_currentloc);
     }
   else
     {
@@ -509,6 +513,8 @@ static void handlePassThroughFlag (char *arg)
        BADBRANCH;
       }
     }
+  
+  sfree (freearg);
 }
 
 void showHerald (void)
@@ -635,8 +641,8 @@ int main (int argc, char *argv[])
   */
 
   {
-    cstring incval = cstring_copy 
-      (osd_getEnvironmentVariable (cstring_makeLiteralTemp (INCLUDE_VAR)));
+    cstring incval = cstring_copy (osd_getEnvironmentVariable (INCLUDEPATH_VAR));
+    cstring oincval = incval;
 
     if (cstring_isDefined (incval))
       {
@@ -650,7 +656,7 @@ int main (int argc, char *argv[])
        while (cstring_isDefined (incval))
          {
            /*@access cstring@*/
-           char *nextsep = strchr (incval, SEPCHAR);
+           char *nextsep = strchr (incval, PATH_SEPARATOR);
 
            if (nextsep != NULL)
              {
@@ -671,7 +677,7 @@ int main (int argc, char *argv[])
                    cppAddIncludeDir (dir);
                  }
 
-               *nextsep = SEPCHAR;
+               *nextsep = PATH_SEPARATOR;
                incval = cstring_fromChars (nextsep + 1);
                cstring_free (dir);
              }
@@ -684,7 +690,7 @@ int main (int argc, char *argv[])
          }
       }
 
-    cstring_free (incval);
+    cstring_free (oincval);
   }
 
   /*
@@ -924,8 +930,10 @@ int main (int argc, char *argv[])
                  else
                    {
                      DPRINTF (("Error!"));
-                     llgloberror (message ("Unrecognized option: %s", 
-                                           cstring_fromChars (thisarg)));
+                     voptgenerror (FLG_BADFLAG,
+                                   message ("Unrecognized option: %s", 
+                                            cstring_fromChars (thisarg)),
+                                   g_currentloc);
                    }
                }
              else
@@ -971,7 +979,7 @@ int main (int argc, char *argv[])
                              g_localSpecPath = cstring_toCharsSafe
                                (message ("%s%h%s", 
                                          cstring_fromChars (g_localSpecPath), 
-                                         SEPCHAR,
+                                         PATH_SEPARATOR,
                                          dir));
                              /*@=mustfree@*/
                              /*@switchbreak@*/ break;
@@ -2013,13 +2021,18 @@ describeVars (void)
   llmsglit ("   --- directory containing lcl standard library files "
            "(import with < ... >)");;
 
-  {
-    cstring dirs = context_getString (FLG_SYSTEMDIRS);
-    llmsg (message 
-          ("systemdirs = %s (set by include envirnoment variable or -systemdirs)",
-           dirs));
+  llmsg (message 
+        ("include path = %q (set by environment variable %s and -I flags)",
+         cppReader_getIncludePath (), INCLUDEPATH_VAR));
 
-  }
+  llmsglit ("   --- path used to find #include'd files");
+
+  llmsg (message 
+        ("systemdirs = %s (set by -systemdirs or envirnoment variable %s)", /*@i413223@*/
+         context_getString (FLG_SYSTEMDIRS),
+         INCLUDEPATH_VAR));
+
+  llmsglit ("   --- if file is found on this path, it is treated as a system file for error reporting");
 }
 
 void
@@ -2133,7 +2146,7 @@ llexit (int status)
 
 void
 loadrc (/*@open@*/ FILE *rcfile, cstringSList *passThroughArgs)
-    /*@ensures closed rcfile@*/
+   /*@ensures closed rcfile@*/
 {
   char *s = mstring_create (MAX_LINE_LENGTH);
   char *os = s;
@@ -2180,10 +2193,11 @@ loadrc (/*@open@*/ FILE *rcfile, cstringSList *passThroughArgs)
          else
            {
              showHerald ();
-             llerror (FLG_SYNTAX, 
-                      message ("Bad flag syntax (+ or - expected, "
-                               "+ is assumed): %s", 
-                               cstring_fromChars (s)));
+             voptgenerror (FLG_BADFLAG, 
+                           message ("Bad flag syntax (+ or - expected, "
+                                    "+ is assumed): %s", 
+                                    cstring_fromChars (s)),
+                           g_currentloc);
              s--;
              set = TRUE;
            }
@@ -2257,9 +2271,10 @@ loadrc (/*@open@*/ FILE *rcfile, cstringSList *passThroughArgs)
                }
              else
                {
-                 llerror (FLG_BADFLAG,
-                          message ("Unrecognized option: %s", 
-                                   cstring_fromChars (thisflag)));
+                 voptgenerror (FLG_BADFLAG,
+                               message ("Unrecognized option: %s", 
+                                        cstring_fromChars (thisflag)),
+                               g_currentloc);
                }
            }
          else
@@ -2271,8 +2286,9 @@ loadrc (/*@open@*/ FILE *rcfile, cstringSList *passThroughArgs)
                  if (opt == FLG_HELP)
                    {
                      showHerald ();
-                     llerror (FLG_BADFLAG,
-                              message ("Cannot use help in rc files"));
+                     voptgenerror (FLG_BADFLAG,
+                                   message ("Cannot use help in rc files"),
+                                   g_currentloc);
                    }
                  else if (flagcode_isPassThrough (opt)) /* -D or -U */
                    {
@@ -2338,11 +2354,12 @@ loadrc (/*@open@*/ FILE *rcfile, cstringSList *passThroughArgs)
                      if (cstring_isUndefined (extra))
                        {
                          showHerald ();
-                         llerror 
+                         voptgenerror 
                            (FLG_BADFLAG,
                             message
                             ("Flag %s must be followed by an argument",
-                             flagcode_unparse (opt)));
+                             flagcode_unparse (opt)),
+                            g_currentloc);
                        }
                      else
                        {
@@ -2372,10 +2389,11 @@ loadrc (/*@open@*/ FILE *rcfile, cstringSList *passThroughArgs)
                              else 
                                {
                                  showHerald ();
-                                 llerror
-                                   (FLG_SYNTAX
+                                 voptgenerror
+                                   (FLG_BADFLAG
                                     message ("Options file not found: %s", 
-                                             extra));
+                                             extra),
+                                    g_currentloc);
                                }
                            }
                          else if (opt == FLG_INIT)
@@ -2406,10 +2424,11 @@ loadrc (/*@open@*/ FILE *rcfile, cstringSList *passThroughArgs)
                                    }
                                  else
                                    {
-                                     llerror
-                                       (FLG_SYNTAX
+                                     voptgenerror
+                                       (FLG_BADFLAG
                                         message ("Unmatched \" in option string: %s", 
-                                                 extra));
+                                                 extra),
+                                        g_currentloc);
                                    }
                                }
                              
This page took 0.056981 seconds and 4 git commands to generate.