]> andersk Git - splint.git/blobdiff - src/lcllib.c
Making fixes for Microsoft Visual C++ compiler.
[splint.git] / src / lcllib.c
index bd157fcfff9840060126b85587ab72030d489427..205cbe44e233efd4ddbdf4599b1b028da5cdd61a 100644 (file)
@@ -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
 **
 */
 
+/*
+ * Herbert 02/17/2002:
+ * - fixed the recognition of Posix headers for OS/2
+ */
+
 # include "splintMacros.nf"
-# include "llbasic.h"
+# include "basic.h"
 # include "osd.h"
+# include "version.h"
 
-# ifndef NOLCL
 # include "gram.h"
-
 # include "lclscan.h"
-# endif
 
 # include "lcllib.h"
 # include "llmain.h"
-# include "portab.h"
 
 /*@-incondefs@*/ /*@-redecl@*/
 extern /*:open:*/ /*@dependent@*/ FILE *yyin;
@@ -124,7 +126,16 @@ lcllib_isSkipHeader (cstring sname)
 
   /*@access cstring@*/
   llassert (cstring_isDefined (xname));
+# if defined (OS2)
+  {
+    /* Posixlibs use forward slashes, so we use them here, too */
+    cstring_replaceAll (xname, '\\', '/');
+    libname = strrchr (xname, '/');
+    DPRINTF (("libname: %s", libname));
+  }
+# else
   libname = strrchr (xname, CONNECTCHAR);
+# endif
   matchname = libname;
 
   if (libname == NULL) 
@@ -154,10 +165,9 @@ lcllib_isSkipHeader (cstring sname)
       return TRUE;
     }
 
-  if (context_getFlag (FLG_SKIPANSIHEADERS)
+  if (context_getFlag (FLG_SKIPISOHEADERS)
       && context_usingAnsiLibrary ())
     {
-      
       for (i = 0; i < NUMLIBS; i++)
        {
          if (mstring_equal (libname, stdlibs[i]))
@@ -170,10 +180,15 @@ lcllib_isSkipHeader (cstring sname)
 
   for (i = 0; i < NUMPOSIXLIBS; i++)
     {
-      if (strchr (posixlibs[i], CONNECTCHAR) != NULL)
+      if (strchr (posixlibs[i], CONNECTCHAR) != NULL
+# if defined (OS2)
+         || strchr (posixlibs[i], ALTCONNECTCHAR) != NULL
+# endif
+         )
        {
          char *ptr;
          
+         DPRINTF (("xname: %s, posix: %s", xname, posixlibs[i]));
          if ((ptr = strstr (xname, posixlibs[i])) != NULL) 
            {
              if (ptr[strlen (posixlibs[i])] == '\0')
@@ -207,7 +222,14 @@ lcllib_isSkipHeader (cstring sname)
          if (context_getFlag (FLG_SKIPPOSIXHEADERS))
            {
              cstring_free (xname);
-             return TRUE;
+             /*@-nullstate@*/ 
+             return TRUE; 
+             /*@=nullstate@*/
+
+             /* evans 2002-03-02: 
+                  the returned reference is possibly null,
+                  but this should not change the null state of the parameter
+             */
            }
        }
       else
@@ -231,17 +253,14 @@ lcllib_isSkipHeader (cstring sname)
 
   cstring_free (xname);
   /*@noaccess cstring@*/
+  /*@-nullstate@*/ /* same problem as above */
   return FALSE;
+  /*@=nullstate@*/
 }
 
 static void printDot (void)
 {
-  if (context_getFlag (FLG_SHOWSCAN)) 
-    {
-      (void) fflush (g_msgstream);
-      fprintf (stderr, "."); 
-      (void) fflush (stderr);
-    }
+  displayScanContinue (cstring_makeLiteralTemp ("."));
 }
 
 void
@@ -250,12 +269,9 @@ dumpState (cstring cfname)
   FILE *f;
   cstring fname = fileLib_addExtension (cfname, cstring_makeLiteralTemp (DUMP_SUFFIX));
   
-  f = fileTable_openFile (context_fileTable (), fname, "w");
+  f = fileTable_openWriteFile (context_fileTable (), fname);
 
-  if (context_getFlag (FLG_SHOWSCAN))
-    {
-      fprintf (stderr, "< Dumping to %s ", cstring_toCharsSafe (fname)); 
-    }
+  displayScanOpen (message ("Dumping to %s ", fname)); 
   
   if (f == NULL)
     {
@@ -283,7 +299,7 @@ dumpState (cstring cfname)
       */
 
       fprintf (f, "%s %s\n", LIBRARY_MARKER, cstring_toCharsSafe (fname));
-      fprintf (f, ";;%s\n", SPLINT_VERSION);
+      fprintf (f, ";;Splint %f\n", SPLINT_LIBVERSION);
       fprintf (f, ";;lib:%d\n", (int) context_getLibrary ());
       fprintf (f, ";;ctTable\n");
       
@@ -309,11 +325,7 @@ dumpState (cstring cfname)
       check (fileTable_closeFile (context_fileTable (), f));
     }
 
-  if (context_getFlag (FLG_SHOWSCAN))
-    {
-      fprintf (g_msgstream, " >\n");
-    }
-
+  displayScanClose ();
   cstring_free (fname);
 }
 
@@ -338,7 +350,7 @@ loadStandardState ()
     }
   else
     {
-      stdlib = fileTable_openFile (context_fileTable (), fpath, "r");
+      stdlib = fileTable_openReadFile (context_fileTable (), fpath);
 
       if (stdlib == NULL)
        {
@@ -388,7 +400,7 @@ loadStandardState ()
              sfree (ot);
              
              check (fileTable_closeFile (context_fileTable (), stdlib));
-             stdlib = fileTable_openFile (context_fileTable (), fpath, "r");
+             stdlib = fileTable_openReadFile (context_fileTable (), fpath);
            }
 
          llassert (stdlib != NULL);
@@ -398,17 +410,9 @@ loadStandardState ()
 
          DPRINTF (("Loading: %s", fpath));
 
-         if (context_getDebug (FLG_SHOWSCAN))
-           {
-             fprintf (g_msgstream, "< loading standard library %s ", 
-                      cstring_toCharsSafe (fpath));
-             result = loadLCDFile (stdlib, fpath);
-             fprintf (g_msgstream, " >\n");
-           }
-         else
-           {
-             result = loadLCDFile (stdlib, fpath);
-           }
+         displayScanOpen (message ("loading standard library %s ", fpath));
+         result = loadLCDFile (stdlib, fpath);
+         displayScanClose ();
 
          check (fileTable_closeFile (context_fileTable (), stdlib));
        }
@@ -477,10 +481,13 @@ loadLCDFile (FILE *f, cstring name)
                  vname = cstring_fromChars (buf + 9);
 
                  loadllmsg (message ("Load library %s is in obsolete Splint library "
-                                     "format (version %s).  Attempting "
+                                     "format (version %f (%s), expecting version %f).  Attempting "
                                      "to continue anyway, but results may be incorrect.  Rebuild "
                                      "the library with this version of splint.", 
-                                     name, vname));
+                                     name, 
+                                     version,
+                                     vname, 
+                                     SPLINT_LIBVERSION));
                }
              else
                {
@@ -560,13 +567,11 @@ loadState (cstring cfname)
   FILE *f;
   cstring fname = fileLib_addExtension (cfname, cstring_makeLiteralTemp (DUMP_SUFFIX));
 
-  f = fileTable_openFile (context_fileTable (), fname, "r");
+  f = fileTable_openReadFile (context_fileTable (), fname);
 
   if (f == NULL)
     {
-      if (context_getDebug (FLG_SHOWSCAN))
-       fprintf (g_msgstream, " >\n");
-
+      displayScanClose ();
       llfatalerror (message ("Cannot open dump file for loading: %s", 
                             fname));
     }
This page took 0.04303 seconds and 4 git commands to generate.