]> andersk Git - splint.git/blobdiff - src/lcllib.c
Removed /bin/csh from tainted/Makefile
[splint.git] / src / lcllib.c
index 6ff82e484a304edd529d4ccc75649ffa9b13cb2c..f9019210f33accb6832c43042a453697565ec925 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2002 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -17,9 +17,9 @@
 ** 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 more information: http://lclint.cs.virginia.edu
+** For information on splint: splint@cs.virginia.edu
+** To report a bug: splint-bug@cs.virginia.edu
+** For more information: http://www.splint.org
 */
 /*
 ** lcllib.c
@@ -31,9 +31,8 @@
 **
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "llbasic.h"
-
 # include "osd.h"
 
 # ifndef NOLCL
 # include "lclscan.h"
 # endif
 
-
-# include "herald.h"
 # include "lcllib.h"
 # include "llmain.h"
 # include "portab.h"
 
 /*@-incondefs@*/ /*@-redecl@*/
-extern /*@open@*/ /*@dependent@*/ FILE *yyin;
+extern /*:open:*/ /*@dependent@*/ FILE *yyin;
 /*@=incondefs@*/ /*@=redecl@*/
 
 /*@constant int NUMLIBS; @*/
-# define NUMLIBS 17
+# define NUMLIBS 25
 
 /*@constant int NUMPOSIXLIBS; @*/
-# define NUMPOSIXLIBS 12
+# define NUMPOSIXLIBS 18
 
 static ob_mstring posixlibs[NUMPOSIXLIBS] = 
 {
-  "sys/stat",
-  "sys/types",
   "dirent",
   "fcntl",
   "grp",
   "pwd",
+  "regex",
+  "sys/stat",
   "sys/times",
+  "sys/types", 
+  "netdb", /* unix */
+  "netinet/in", /* unix */
+  "sys/resource", /* unix */
+  "sys/socket", /* not posix */
+  "sys/syslog", /* not posix */
   "sys/utsname",
   "sys/wait",
   "termios",
@@ -77,22 +80,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);
@@ -109,6 +120,8 @@ lcllib_isSkipHeader (cstring sname)
   llassert (cstring_isDefined (sname));
   xname = fileLib_withoutExtension (sname, cstring_makeLiteralTemp (".h"));
 
+  DPRINTF (("Include? %s", sname));
+
   /*@access cstring@*/
   llassert (cstring_isDefined (xname));
   libname = strrchr (xname, CONNECTCHAR);
@@ -131,13 +144,13 @@ lcllib_isSkipHeader (cstring sname)
       
       voptgenerror 
        (FLG_USEVARARGS,
-        message ("Include file <%s> is inconsistent with "
+        message ("Include file <%s.h> is inconsistent with "
                  "ANSI library (should use <stdarg.h>)",
                  cstring_fromChars (libname)),
         tmp);
       
       fileloc_free (tmp);
-      sfree (xname);
+      cstring_free (xname);
       return TRUE;
     }
 
@@ -193,7 +206,7 @@ lcllib_isSkipHeader (cstring sname)
        {
          if (context_getFlag (FLG_SKIPPOSIXHEADERS))
            {
-             sfree (xname);
+             cstring_free (xname);
              return TRUE;
            }
        }
@@ -203,7 +216,7 @@ lcllib_isSkipHeader (cstring sname)
          
          voptgenerror 
            (FLG_WARNPOSIX,
-            message ("Include file <%s> matches the name of a "
+            message ("Include file <%s.h> matches the name of a "
                      "POSIX library, but the POSIX library is "
                      "not being used.  Consider using +posixlib "
                      "or +posixstrictlib to select the POSIX "
@@ -237,7 +250,7 @@ dumpState (cstring cfname)
   FILE *f;
   cstring fname = fileLib_addExtension (cfname, cstring_makeLiteralTemp (DUMP_SUFFIX));
   
-  f = fopen (cstring_toCharsSafe (fname), "w");
+  f = fileTable_openFile (context_fileTable (), fname, "w");
 
   if (context_getFlag (FLG_SHOWSCAN))
     {
@@ -246,7 +259,7 @@ dumpState (cstring cfname)
   
   if (f == NULL)
     {
-      llgloberror (message ("Cannot open dump file for writing: %s", fname));
+      lldiagmsg (message ("Cannot open dump file for writing: %s", fname));
     }
   else
     {
@@ -269,8 +282,8 @@ dumpState (cstring cfname)
       ** Be careful, these lines must match loadLCDFile checking.
       */
 
-      fprintf (f, ";;LCLint Dump: %s\n", cstring_toCharsSafe (fname));
-      fprintf (f, ";;%s\n", LCL_VERSION);
+      fprintf (f, "%s %s\n", LIBRARY_MARKER, cstring_toCharsSafe (fname));
+      fprintf (f, ";;%s\n", SPLINT_VERSION);
       fprintf (f, ";;lib:%d\n", (int) context_getLibrary ());
       fprintf (f, ";;ctTable\n");
       
@@ -293,7 +306,7 @@ dumpState (cstring cfname)
       fprintf (f, ";; Modules access\n");
       context_dumpModuleAccess (f);
       fprintf (f, ";;End\n");
-      check (fclose (f) == 0);
+      check (fileTable_closeFile (context_fileTable (), f));
     }
 
   if (context_getFlag (FLG_SHOWSCAN))
@@ -325,7 +338,7 @@ loadStandardState ()
     }
   else
     {
-      stdlib = fopen (cstring_toCharsSafe (fpath), "r");
+      stdlib = fileTable_openFile (context_fileTable (), fpath, "r");
 
       if (stdlib == NULL)
        {
@@ -374,8 +387,8 @@ loadStandardState ()
 
              sfree (ot);
              
-             check (fclose (stdlib) == 0);
-             stdlib = fopen (cstring_toCharsSafe (fpath), "r");
+             check (fileTable_closeFile (context_fileTable (), stdlib));
+             stdlib = fileTable_openFile (context_fileTable (), fpath, "r");
            }
 
          llassert (stdlib != NULL);
@@ -397,7 +410,7 @@ loadStandardState ()
              result = loadLCDFile (stdlib, fpath);
            }
 
-         check (fclose (stdlib) == 0);
+         check (fileTable_closeFile (context_fileTable (), stdlib));
        }
     }
 
@@ -414,13 +427,13 @@ 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
-      || !mstring_equalPrefix (buf, ";;LCLint Dump:"))
+      || !mstring_equalPrefix (buf, LIBRARY_MARKER))
     {
-      loadllmsg (message ("Load library %s is not in LCLint library format.  Attempting "
+      loadllmsg (message ("Load library %s is not in Splint library format.  Attempting "
                          "to continue without library.", name));
       return FALSE;
     }
@@ -429,31 +442,32 @@ loadLCDFile (FILE *f, cstring name)
     {
       if (!mstring_equalPrefix (buf, ";;"))
        {
-         loadllmsg (message ("Load library %s is not in LCLint library format.  Attempting "
+         loadllmsg (message ("Load library %s is not in Splint library format.  Attempting "
                              "to continue without library.", name));
          return FALSE;
        }
       else if (mstring_equalPrefix (buf, ";;ctTable"))
        {
-         loadllmsg (message ("Load library %s is in obsolete LCLint library format.  Attempting "
+         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 
        {
          float version = 0.0;
 
-         if (sscanf (buf, ";;LCLint %f", &version) != 1)
+         if (sscanf (buf, ";;Splint %f", &version) != 1
+             && (sscanf (buf, ";;LCLint %f", &version) != 1))
            {
-             loadllmsg (message ("Load library %s is not in LCLint library format (missing version "
+             loadllmsg (message ("Load library %s is not in Splint library format (missing version "
                                  "number).  Attempting "
                                  "to continue without library.", name));
              return FALSE;
            }
          else
            {
-             if ((LCLINT_LIBVERSION - version) >= FLT_EPSILON)
+             if ((SPLINT_LIBVERSION - version) >= FLT_EPSILON)
                {
                  cstring vname;
                  char *nl = strchr (buf, '\n');
@@ -462,17 +476,17 @@ 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
                {
                  if (reader_readLine (f, buf, BUFLEN) == NULL)
                    {
-                     loadllmsg (message ("Load library %s is not in LCLint library "
+                     loadllmsg (message ("Load library %s is not in Splint library "
                                          "format (missing library code). Attempting "
                                          "to continue without library.", name));
                      return FALSE;
@@ -483,7 +497,7 @@ loadLCDFile (FILE *f, cstring name)
                      
                      if (sscanf (buf, ";;lib:%d", &lib) != 1)
                        {
-                         loadllmsg (message ("Load library %s is not in LCLint library "
+                         loadllmsg (message ("Load library %s is not in Splint library "
                                              "format (missing library code). Attempting "
                                              "to continue without library.", name));
                          return FALSE;
@@ -516,7 +530,7 @@ loadLCDFile (FILE *f, cstring name)
     }
   else
     {
-      loadllmsg (message ("Load library %s is not in LCLint library format (missing lines).  "
+      loadllmsg (message ("Load library %s is not in Splint library format (missing lines).  "
                          "Attempting to continue without library.", name));
       return FALSE;
     }
@@ -546,7 +560,7 @@ loadState (cstring cfname)
   FILE *f;
   cstring fname = fileLib_addExtension (cfname, cstring_makeLiteralTemp (DUMP_SUFFIX));
 
-  f = fopen (cstring_toCharsSafe (fname), "r");
+  f = fileTable_openFile (context_fileTable (), fname, "r");
 
   if (f == NULL)
     {
@@ -569,7 +583,7 @@ loadState (cstring cfname)
            }
        }
       
-      check (fclose (f) == 0);
+      check (fileTable_closeFile (context_fileTable (), f));
     }
 
   /* usymtab_printAll (); */
This page took 0.050888 seconds and 4 git commands to generate.