]> andersk Git - splint.git/blobdiff - src/lcllib.c
Apparently splint does not correctly handle the case in which a #defined constant...
[splint.git] / src / lcllib.c
index 9382000b988283a8be5835cccf69622b591eb95d..ac388a67d1edf5de4b45ecec8cd79ba9eadcbc7c 100644 (file)
@@ -17,8 +17,8 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-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
 */
 /*
 **
 */
 
-# include "lclintMacros.nf"
+/*
+ * Herbert 02/17/2002:
+ * - fixed the recognition of Posix headers for OS/2
+ */
+
+# include "splintMacros.nf"
 # include "llbasic.h"
 # include "osd.h"
 
@@ -50,7 +55,7 @@ extern /*:open:*/ /*@dependent@*/ FILE *yyin;
 /*@=incondefs@*/ /*@=redecl@*/
 
 /*@constant int NUMLIBS; @*/
-# define NUMLIBS 17
+# define NUMLIBS 25
 
 /*@constant int NUMPOSIXLIBS; @*/
 # define NUMPOSIXLIBS 18
@@ -80,22 +85,30 @@ static ob_mstring posixlibs[NUMPOSIXLIBS] =
 static ob_mstring stdlibs[NUMLIBS] =
 {
   "assert", 
+  "complex"
   "ctype",
   "errno",
-  "float", 
+  "fenv",
+  "float",
+  "inttypes",
+  "iso646",
   "limits",
   "locale",
   "math", 
   "setjmp",
   "signal",
   "stdarg",
+  "stdbool",
   "stddef",
+  "stdint",
   "stdio",
   "stdlib",
-  "strings", 
   "string",
+  "strings", /* some systems use this...they shouldn't */
+  "tgmath",
   "time",
-  "wchar"
+  "wchar",
+  "wctype"
 } ;
 
 static bool loadLCDFile (FILE * p_f, cstring p_name);
@@ -116,7 +129,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) 
@@ -146,7 +168,7 @@ lcllib_isSkipHeader (cstring sname)
       return TRUE;
     }
 
-  if (context_getFlag (FLG_SKIPANSIHEADERS)
+  if (context_getFlag (FLG_SKIPISOHEADERS)
       && context_usingAnsiLibrary ())
     {
       
@@ -162,10 +184,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')
@@ -199,7 +226,15 @@ lcllib_isSkipHeader (cstring sname)
          if (context_getFlag (FLG_SKIPPOSIXHEADERS))
            {
              cstring_free (xname);
-             return TRUE;
+             /*@-nullstate@*/ 
+             return TRUE; 
+             /*@=nullstate@*/
+             /*@i233@*/
+             /* evans 2002-03-02: 
+                the returned reference is possibly null,
+                but this should not change the null state of the parameter
+                investigate this warning 
+             */
            }
        }
       else
@@ -223,17 +258,14 @@ lcllib_isSkipHeader (cstring sname)
 
   cstring_free (xname);
   /*@noaccess cstring@*/
+  /*@-nullstate@*/ /*@i233@*/ /* 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
@@ -242,12 +274,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)
     {
@@ -301,11 +330,7 @@ dumpState (cstring cfname)
       check (fileTable_closeFile (context_fileTable (), f));
     }
 
-  if (context_getFlag (FLG_SHOWSCAN))
-    {
-      fprintf (g_msgstream, " >\n");
-    }
-
+  displayScanClose ();
   cstring_free (fname);
 }
 
@@ -330,7 +355,7 @@ loadStandardState ()
     }
   else
     {
-      stdlib = fileTable_openFile (context_fileTable (), fpath, "r");
+      stdlib = fileTable_openReadFile (context_fileTable (), fpath);
 
       if (stdlib == NULL)
        {
@@ -380,7 +405,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);
@@ -390,17 +415,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));
        }
@@ -419,7 +436,7 @@ loadLCDFile (FILE *f, cstring name)
   char buf[BUFLEN];
   
   /*
-  ** Check version.  Should be >= LCLINT_LIBVERSION
+  ** Check version.  Should be >= SPLINT_LIBVERSION
   */
 
   if (reader_readLine (f, buf, BUFLEN) == NULL
@@ -442,7 +459,7 @@ loadLCDFile (FILE *f, cstring name)
        {
          loadllmsg (message ("Load library %s is in obsolete Splint library format.  Attempting "
                              "to continue anyway, but results may be incorrect.  Rebuild "
-                             "the library with this version of lclint.", 
+                             "the library with this version of splint.", 
                              name));
        }
       else 
@@ -459,7 +476,7 @@ loadLCDFile (FILE *f, cstring name)
            }
          else
            {
-             if ((LCLINT_LIBVERSION - version) >= FLT_EPSILON)
+             if ((SPLINT_LIBVERSION - version) >= FLT_EPSILON)
                {
                  cstring vname;
                  char *nl = strchr (buf, '\n');
@@ -468,10 +485,10 @@ loadLCDFile (FILE *f, cstring name)
 
                  vname = cstring_fromChars (buf + 9);
 
-                 loadllmsg (message ("Load library %s is in obsolete LCLint library "
+                 loadllmsg (message ("Load library %s is in obsolete Splint library "
                                      "format (version %s).  Attempting "
                                      "to continue anyway, but results may be incorrect.  Rebuild "
-                                     "the library with this version of lclint.", 
+                                     "the library with this version of splint.", 
                                      name, vname));
                }
              else
@@ -552,13 +569,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.155466 seconds and 4 git commands to generate.