]> andersk Git - splint.git/commitdiff
Fixed creation of temp files.
authorevans1629 <evans1629>
Mon, 25 Mar 2002 18:55:48 +0000 (18:55 +0000)
committerevans1629 <evans1629>
Mon, 25 Mar 2002 18:55:48 +0000 (18:55 +0000)
30 files changed:
lib/posix.h
lib/standard.h
lib/tainted.xh
lib/unix.h
src/Headers/fileLib.h
src/Headers/fileTable.h
src/Headers/lctype.h
src/Headers/lh.h
src/abstract.c
src/cgrammar.c.der
src/cgrammar.y
src/context.c
src/cpplib.c
src/cppmain.c
src/ctbase.i
src/ctype.c
src/fileTable.c
src/flags.def
src/imports.c
src/inputStream.c
src/lcllib.c
src/lh.c
src/llmain.c
src/lslparse.c
src/macrocache.c
src/osd.c
src/usymtab.c
test/db1.expect
test/repexpose.expect
test/utypes.expect

index 6716ce83515b925372c0af50619303ffe68d1828..afac9e471cbbfd1b8791ce471afb0210c304736f 100644 (file)
@@ -95,10 +95,10 @@ extern int closedir (DIR *dirp)
    /*drl 1/4/2001 added the dependent annotation as suggested by
      Ralf Wildenhues */
    
-   extern /*@null@*/ /*@dependent@*/ DIR *opendir (const char *dirname)
+extern /*@null@*/ /*@dependent@*/ DIR *opendir (const char *dirname)
    /*@modifies errno, fileSystem@*/;
 
-extern /*@null@*/ struct dirent *readdir (DIR *dirp)
+extern /*@dependent@*/ /*@null@*/ struct dirent *readdir (DIR *dirp)
    /*@modifies errno@*/;
 
 extern void rewinddir (DIR *dirp)
@@ -173,20 +173,32 @@ extern void rewinddir (DIR *dirp)
 /*@constant int SEEK_CUR@*/
 /*@constant int SEEK_END@*/
 /*@constant int SEEK_SET@*/
-/*@constant int S_IRGRP@*/
-/*@constant int S_IROTH@*/
-/*@constant int S_IUSR@*/
-/*@constant int S_IWXG@*/
-/*@constant int S_IWXO@*/
-/*@constant int S_IWXU@*/
-/*@constant int S_ISGID@*/
-/*@constant int S_ISUID@*/
-/*@constant int S_IWGRP@*/
-/*@constant int S_IWOTH@*/
-/*@constant int S_IWUSR@*/
-/*@constant int S_IXGRP@*/
-/*@constant int S_IXOTH@*/
-/*@constant int S_IXUSR@*/
+
+/*@constant mode_t S_IFMT@*/
+/*@constant mode_t S_IFBLK@*/
+/*@constant mode_t S_IFCHR@*/
+/*@constant mode_t S_IFIFO@*/
+/*@constant mode_t S_IFREG@*/
+/*@constant mode_t S_IFDIR@*/
+/*@constant mode_t S_IFLNK@*/
+
+/*@constant mode_t S_IRWXU@*/
+/*@constant mode_t S_IRUSR@*/
+
+/*@constant mode_t S_IRGRP@*/
+/*@constant mode_t S_IROTH@*/
+/*@constant mode_t S_IUSR@*/
+/*@constant mode_t S_IWXG@*/
+/*@constant mode_t S_IWXO@*/
+/*@constant mode_t S_IWXU@*/
+/*@constant mode_t S_ISGID@*/
+/*@constant mode_t S_ISUID@*/
+/*@constant mode_t S_IWGRP@*/
+/*@constant mode_t S_IWOTH@*/
+/*@constant mode_t S_IWUSR@*/
+/*@constant mode_t S_IXGRP@*/
+/*@constant mode_t S_IXOTH@*/
+/*@constant mode_t S_IXUSR@*/
 
 struct flock {
   short l_type;
@@ -204,7 +216,8 @@ extern int fcntl (int fd, int cmd, ...)
 
 extern int open (const char *path, int oflag, ...)
   /*:checkerror -1 - returns -1 on error */
-  /*@modifies errno@*/;
+     /* the ... is one mode_t param */
+  /*@modifies errno@*/ ;
 
 /*
 ** grp.h
@@ -397,21 +410,6 @@ extern int fileno (FILE *fp) /*@modifies errno@*/;
 ** sys/stat.h
 */
 
-/*@constant int S_IRGRP@*/
-/*@constant int S_IROTH@*/
-/*@constant int S_IUSR@*/
-/*@constant int S_IWXG@*/
-/*@constant int S_IWXO@*/
-/*@constant int S_IWXU@*/
-/*@constant int S_ISGID@*/
-/*@constant int S_ISUID@*/
-/*@constant int S_IWGRP@*/
-/*@constant int S_IWOTH@*/
-/*@constant int S_IWUSR@*/
-/*@constant int S_IXGRP@*/
-/*@constant int S_IXOTH@*/
-/*@constant int S_IXUSR@*/
-
 struct stat {
   mode_t st_mode;
   ino_t        st_ino;
@@ -511,6 +509,10 @@ extern int WTERMSIG (int status) /*@*/ ;
 
 /*@constant int WUNTRACED@*/
 
+/* These are in Unix spec, are they in POSIX? */
+/*@constant int WCONTINUED@*/
+/*@constant int WNOHANG@*/
+
 pid_t wait (/*@out@*/ /*@null@*/ int *st)
    /*@modifies *st, errno, systemState@*/;
 
index ec91cf680d5bdf02ec1ca7195ef4f63a435deb8b..caed5a73c0de897497c74ca3b5cec122269d1779 100644 (file)
@@ -375,27 +375,31 @@ typedef /*@abstract@*/ /*@mutable@*/ void *fpos_t;
 int remove (char *filename) /*@modifies fileSystem, errno@*/ ;
 int rename (char *old, char *new) /*@modifies fileSystem, errno@*/ ;
 
-/*@null@*/ FILE *tmpfile (void) /*@modifies fileSystem@*/ ;
+/*@dependent@*/ /*@null@*/ FILE *tmpfile (void)
+   /*@modifies fileSystem, errno@*/ ;
+
 /*@observer@*/ char *
   tmpnam (/*@out@*/ /*@null@*/ /*@returned@*/ char *s) 
   /*@modifies *s, internalState@*/ ;
 
-int fclose (FILE *stream) /*@modifies *stream, errno, fileSystem;@*/ ;
+int fclose (FILE *stream) 
+   /*@modifies *stream, errno, fileSystem;@*/ ;
+
 int fflush (/*@null@*/ FILE *stream) 
    /*@modifies *stream, errno, fileSystem;@*/ ;
 
 /*@null@*/ /*@dependent@*/ FILE *fopen (char *filename, char *mode) 
    /*@modifies fileSystem@*/ ;         
 
-/*@null@*/ FILE *freopen (char *filename, char *mode, FILE *stream) 
+/*@dependent@*/ /*@null@*/ FILE *freopen (char *filename, char *mode, FILE *stream) 
   /*@modifies *stream, fileSystem, errno@*/ ;
 
-  extern void setbuf (FILE *stream, /*@null@*/ /*@exposed@*/ /*@out@*/ char *buf) 
-   /*@modifies fileSystem, *stream, *buf@*/ ;
+extern void setbuf (FILE *stream, /*@null@*/ /*@exposed@*/ /*@out@*/ char *buf) 
+     /*@modifies fileSystem, *stream, *buf@*/ ;
 
-   extern int setvbuf (FILE *stream, /*@null@*/ /*@exposed@*/ /*@out@*/ char *buf, 
+extern int setvbuf (FILE *stream, /*@null@*/ /*@exposed@*/ /*@out@*/ char *buf, 
                    int mode, size_t size)
-   /*@modifies fileSystem, *stream, *buf@*/ ;
+     /*@modifies fileSystem, *stream, *buf@*/ ;
 
 # ifdef STRICT
 /*@printflike@*/ 
@@ -525,6 +529,7 @@ void rewind (FILE *stream) /*@modifies *stream@*/ ;
 void clearerr (FILE *stream) /*@modifies *stream@*/ ;
 
 int feof (FILE *stream) /*@modifies errno@*/ ;
+
 int ferror (FILE *stream) /*@modifies errno@*/ ;
 
 void perror (/*@null@*/ char *s) 
index 6c82bcb542fa11b8f55ec3166a54f1f87182b074..7e031f02fb3148bd57776c745c15374afbc18154 100644 (file)
@@ -9,6 +9,9 @@ extern int fprintf (FILE *stream, /*@untainted@*/ char *format, ...) ;
 extern int sprintf (/*@out@*/ char *s, /*@untainted@*/ char *format, ...) 
    /*@ensures s:taintedness = ...:taintedness@*/ ;
 
+extern int snprintf (/*@out@*/ char *s, size_t n, /*@untainted@*/ const char *format, ...)
+   /*@ensures s:taintedness = ...:taintedness@*/ ;
+
 extern int vprintf (/*@untainted@*/ const char *format, va_list ap);
 extern int vfprintf(FILE *stream, /*@untainted@*/ const char *format, va_list ap);
 extern int vsprintf (/*@out@*/ char *str, /*@untainted@*/ const char *format, va_list ap)
index 54ccec28804cc83d4a68b092428760f3105d9df8..00e01fc4e790c506fb38ae7e41c5d9289c965cc2 100644 (file)
@@ -1142,15 +1142,22 @@ extern int shmget (key_t key, int size, int flag)
 
 /*@constant observer char *P_tmpdir@*/
 
+void clearerr (FILE *s) 
+   /*@modifies s@*/ ;
+
 /*@dependent@*/ char *ctermid (/*@returned@*/ /*@null@*/ char *) /*@*/ ;
    /* Result may be static pointer if parameter is NULL, otherwise is fresh. */
 
 char *cuserid (/*@null@*/ /*@returned@*/ char *) 
   /*@warn legacy "cuserid is obsolete"@*/ /*@*/ ;
 
+/* fclose in standard.h */
+
 /*@null@*/ FILE *fdopen (int, const char *)
   /*@modifies errno, fileSystem@*/ ;
 
+/* feof, ferror fflush, fgetc, fgetpos, fgets - in standard.h */
+
 int fileno (/*@notnull@*/ FILE *)
   /*:errorcode -1:*/ 
   /*@modifies errno@*/ ;
@@ -1219,9 +1226,15 @@ int rename (const char *, const char *)
 void rewind (FILE *stream)
    /*@modifies *stream@*/ ;
 
-void setbuf (FILE *stream, /*@null@*/ char *buf);
-     int      setvbuf(FILE *, char *, int, size_t);
-     int      snprintf(char *, size_t, const char *, ...);
+void setbuf (FILE *stream, /*@null@*/ /*@dependent@*/ /*@exposed@*/ char *buf)
+     /*@modifies stream@*/
+
+int setvbuf (FILE *stream, /*@null@*/ /*@dependent@*/ /*@exposed@*/ char *buf, int type, size_t size)
+     /*@modifies stream@*/ 
+     /*:errorcode !0:*/ ;
+     
+int snprintf (char *s, size_t n, const char *format, ...);
+
      int      sprintf(char *, const char *, ...);
      int      sscanf(const char *, const char *, int ...);
      char    *tempnam(const char *, const char *);
@@ -1285,33 +1298,26 @@ void setbuf (FILE *stream, /*@null@*/ char *buf);
 /*@constant int LOG_NOWAIT@*/
 /*@constant int LOG_PERROR@*/
 
-       extern int
-LOG_MASK (int pri)
-       /*@*/;
-
-       extern int
-LOG_UPTO (int pri)
-       /*@*/;
-
-       extern void
-closelog (void)
-       /*@modifies fileSystem@*/;
-
-       extern void
-openlog (const char *ident, int logopt, int facility)
-       /*@modifies fileSystem@*/;
-
-       extern int
-setlogmask (int maskpri)
-       /*@modifies internalState@*/;
-
-       extern void /*@printflike@*/
-syslog (int priority, const char *message, ...)
-       /*@modifies fileSystem@*/;
-
-       extern void
-vsyslog (int priority, const char *message, va_list args)
-       /*@modifies fileSystem@*/;
+int LOG_MASK (int pri)
+     /*@*/;
+     
+int LOG_UPTO (int pri)
+     /*@*/;
+     
+void closelog (void)
+     /*@modifies fileSystem@*/;
+     
+void openlog (const char *ident, int logopt, int facility)
+     /*@modifies fileSystem@*/;
+     
+int setlogmask (int maskpri)
+     /*@modifies internalState@*/;
+     
+void /*@printflike@*/ syslog (int priority, const char *message, ...)
+     /*@modifies fileSystem@*/;
+     
+void vsyslog (int priority, const char *message, va_list args)
+     /*@modifies fileSystem@*/;
 
 /*________________________________________________________________________
  * pwd.h
@@ -1387,18 +1393,6 @@ struct stat {
 } ;
 /*@=redef@*/ /*@=matchfields@*/
 
-/*@constant mode_t S_IFMT@*/
-/*@constant mode_t S_IFBLK@*/
-/*@constant mode_t S_IFCHR@*/
-/*@constant mode_t S_IFIFO@*/
-/*@constant mode_t S_IFREG@*/
-/*@constant mode_t S_IFDIR@*/
-/*@constant mode_t S_IFLNK@*/
-
-/*@constant mode_t S_IRWXU@*/
-/*@constant mode_t S_IRUSR@*/
-
-/*@-incondefs@*/ /*: probably wrong in posix.h? */
 /*@constant mode_t S_IWUSR@*/
 /*@constant mode_t S_IXUSR@*/
 /*@constant mode_t S_IRWXG@*/
@@ -1413,8 +1407,6 @@ struct stat {
 /*@constant mode_t S_ISGID@*/
 /*@constant mode_t S_ISVTX@*/
 
-/*@=incondefs@*/
-
 # if 0
 /*These are the old definitions - they don't appear to be in the Single UNIX Specification */
 
@@ -2253,8 +2245,13 @@ typedef /*@abstract@*/ DIR;
 
 int closedir (DIR *) /*:errorcode -1*/ ; 
 /*@null@*/ /*@dependent@*/ DIR *opendir(const char *)  /*@modifies errno, fileSystem@*/ ;
-struct dirent *readdir(DIR *);
-int readdir_r(DIR *, struct dirent *, struct dirent **);
+
+/* in posix.h: struct dirent *readdir(DIR *); */
+
+int readdir_r (DIR *, struct dirent *, /*@out@*/ struct dirent **result)
+     /*@modifies *result@*/
+     /*:errorcode !0:*/ ;
+
 void rewinddir(DIR *);
 void seekdir(DIR *, long int);
 long int telldir(DIR *);
index e08dd54bdccde61443218a295dd56c9048e69672..d25aff397ec9ebc706cdf0996d6be3a7e1cdad67 100644 (file)
@@ -40,9 +40,6 @@ extern /*@observer@*/ cstring
 /*@constant observer cstring C_EXTENSION; @*/
 # define C_EXTENSION cstring_makeLiteralTemp (".c")
 
-/*@constant observer cstring LHTMP_EXTENSION; @*/
-# define LHTMP_EXTENSION cstring_makeLiteralTemp (".lh_tmp")
-
 /*@constant observer cstring XH_EXTENSION;@*/
 # define XH_EXTENSION cstring_makeLiteralTemp (".xh")
 
index 33c0d2ffe0eef7ee8f827965abeeb107d978131c..8083be9e84ec8a3586a03b2933974241e8c2bc57 100644 (file)
@@ -129,6 +129,12 @@ extern /*@observer@*/ cstring fileTable_fileName (fileId p_fid) /*@*/ ;
 extern /*@observer@*/ cstring fileTable_fileNameBase (fileId p_fid) /*@*/ ;
 extern /*@observer@*/ cstring fileTable_rootFileName (fileId p_fid) /*@*/ ;
 
+extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE *fileTable_createFile (fileTable p_ft, cstring p_fname) 
+     /*@modifies p_ft, fileSystem@*/ ;
+
+extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE *fileTable_createMacrosFile (fileTable p_ft, cstring p_fname) 
+     /*@modifies p_ft, fileSystem@*/ ;
+
 # define fileTable_fileName(fid)     (fileTable_getName(context_fileTable(), fid))
 # define fileTable_fileNameBase(fid) (fileTable_getNameBase(context_fileTable(), fid))
 # define fileTable_rootFileName(fid) (fileTable_getRootName(context_fileTable(), fid))
@@ -138,9 +144,16 @@ extern bool fileId_baseEqual (/*@sef@*/ fileId p_t1, /*@sef@*/ fileId p_t2) /*@*
 # define fileId_baseEqual(t1,t2) \
   (fileId_equal (t1, t2) || fileTable_sameBase (context_fileTable (), t1, t2))
 
+extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE *
+fileTable_openReadFile (fileTable p_ft, cstring p_fname) 
+     /*@modifies p_ft@*/ ;
+
+extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE *
+fileTable_openWriteFile (fileTable p_ft, cstring p_fname) 
+     /*@modifies p_ft@*/ ;
 
 extern /*@null@*/ /*@open@*/ /*@dependent@*/ FILE *
-fileTable_openFile (fileTable p_ft, cstring p_fname, /*@observer@*/ char *p_mode) 
+fileTable_openWriteUpdateFile (fileTable p_ft, cstring p_fname) 
      /*@modifies p_ft@*/ ;
 
 extern bool fileTable_closeFile (fileTable p_ft, FILE *p_f) 
index ecf61d0446eb0c1e7912bb49b2e55ea288a8ce76..4e2d0a83b55ac2b6c7a50d6259096530032649b5 100644 (file)
@@ -73,7 +73,6 @@ typedef enum
        
 typedef enum 
 { 
-  CTK_ANYTYPE = -4,
   CTK_UNKNOWN = -3,
   CTK_INVALID = -2, 
   CTK_DNE = -1,
@@ -98,9 +97,6 @@ extern int ctkind_toInt (ctkind p_x);
 /*@constant ctype ctype_dne; @*/
 # define ctype_dne        ((ctype) CTK_DNE)
 
-/*@constant ctype ctype_anytype; @*/
-# define ctype_anytype    ((ctype) CTK_ANYTYPE)
-
 /*@constant ctype ctype_unknown; @*/
 # define ctype_unknown    CTX_UNKNOWN
 
@@ -262,12 +258,14 @@ extern ctype ctype_fixArrayPtr (ctype p_c);
 
 extern ctype ctype_getBaseType (ctype p_c) /*@*/ ;
 
+extern ctype ctype_makeAnytype (void) /*@*/ ;
+extern bool ctype_isAnytype (ctype) /*@*/ ;
+
 extern ctype ctype_makeArray (ctype p_c);
 extern ctype ctype_makeFixedArray (ctype p_c, size_t p_size);
-extern ctype ctype_makeInnerArray (ctype p_c);
 extern ctype ctype_makeInnerFixedArray (ctype p_c, size_t p_size);
-
-extern ctype ctype_makeConj (ctype p_c1, ctype p_c2);
+extern ctype ctype_makeInnerArray (ctype p_c);
+extern ctype ctype_makeConj (ctype p_c1, ctype p_c2) /*@modifies internalState@*/ ;
 extern ctype ctype_makeParamsFunction (ctype p_base, /*@only@*/ uentryList p_p);
 extern ctype ctype_makeFunction (ctype p_base, /*@only@*/ uentryList p_p) /*@*/ ;
 extern ctype ctype_makeNFParamsFunction (ctype p_base, /*@only@*/ uentryList p_p) /*@*/ ;
@@ -347,9 +345,6 @@ extern bool ctype_isUndefined (ctype p_c) /*@*/ ;
 extern bool ctype_isUnknown (ctype p_c) /*@*/;
 # define ctype_isUnknown(c)       ((c) == CTX_UNKNOWN)
 
-extern bool ctype_isAnytype (ctype p_c) /*@*/;
-# define ctype_isAnytype(c)       ((c) == ctype_anytype)
-
 extern bool ctype_isBogus (/*@sef@*/ ctype p_c) /*@*/ ;
 # define ctype_isBogus(c)         (ctype_isUndefined(c) || ctype_isUnknown(c))
 
index d9211ddf47331e97bb0c8a72a40b7ac4bc660d03..b7445b06fd1674d9b075effaf57d52ea2b211b72 100644 (file)
@@ -9,7 +9,7 @@
 
 extern void lhCleanup (void) /*@modifies internalState, fileSystem@*/ ;
 extern void lhIncludeBool (void) /*@modifies internalState@*/ ;
-extern void lhInit (inputStream p_f) /*@modifies internalState, fileSystem@*/ ;
+extern void lhInit (inputStream p_f) /*@modifies internalState@*/ ;
 extern void lhOutLine (/*@only@*/ cstring p_s) /*@modifies internalState@*/ ;
 extern void lhExternals (interfaceNodeList p_x) /*@modifies internalState@*/ ;
 
index 978ab86f404e05497464d6e79802157e6e588ba6..e57c603bd7f93981d8d457d8ca37f166b51b8543 100644 (file)
@@ -3413,23 +3413,23 @@ lclTypeSpecNode_unparseAltComments (/*@null@*/ lclTypeSpecNode typespec) /*@*/
                    return (message ("%q%s", s, ltoken_unparse (n->opttagid)));
                  }
 
-               s = message ("%q%s {\n\2\1", s, ltoken_unparse (n->opttagid));
+               s = message ("%q%s {\n\t", s, ltoken_unparse (n->opttagid));
              }
            else
              {
-               s = message ("%q{\n\2\1", s);
+               s = message ("%q{\n\t", s);
              }
 
            decls = n->structdecls;
 
            stDeclNodeList_elements (decls, f)
            {
-             s = message ("%q%q\1%q;\n\1", s, 
+             s = message ("%q%q %q;\n\t", s, 
                           lclTypeSpecNode_unparseAltComments (f->lcltypespec),
                          declaratorNodeList_unparse (f->declarators));
            } end_stDeclNodeList_elements;
 
-           return (message ("%q\3}", s));
+           return (message ("%q }", s));
          }
        case LTS_CONJ:
          {
@@ -3520,23 +3520,23 @@ cstring lclTypeSpecNode_unparseComments (/*@null@*/ lclTypeSpecNode typespec)
                    return (message ("%q%s", s, ltoken_unparse (n->opttagid)));
                  }
 
-               s = message ("%q%s {\n\2\1", s, ltoken_unparse (n->opttagid));
+               s = message ("%q%s {\n\t", s, ltoken_unparse (n->opttagid));
              }
            else
              {
-               s = message ("%q{\n\2\1", s);
+               s = message ("%q{\n\t", s);
              }
 
            decls = n->structdecls;
 
            stDeclNodeList_elements (decls, f)
            {
-             s = message ("%q%q\1%q;\n\1", s, 
+             s = message ("%q%q %q;\n\t", s, 
                           lclTypeSpecNode_unparseComments (f->lcltypespec),
                          declaratorNodeList_unparse (f->declarators));
            } end_stDeclNodeList_elements;
 
-           return (message ("%q\3}", s));
+           return (message ("%q }", s));
          }
        case LTS_CONJ:
          {
index 2ec46b4718ae705115cf2640e75dbb7be1364d59..18641a1f721edae151485c794e96a0302ceffd40 100644 (file)
@@ -4368,7 +4368,7 @@ case 367:
 { yyval.typequal = yyvsp[-1].typequal; ;
     break;}
 case 374:
-{ yyval.ctyp = ctype_anytype; DPRINTF (("anytype: %s", ctype_unparse (yyval.ctyp))); ;
+{ yyval.ctyp = ctype_makeAnytype (); ;
     break;}
 case 375:
 { yyval.ctyp = ctype_anyintegral; ;
index 1b18b8bfe87b27e116b20da071fc0dca9c815985..9ac04c63153afcf9dc2e79b9be489cfb53b1c54e 100644 (file)
@@ -1232,7 +1232,7 @@ typeSpecifier
  | CGFLOAT NotType
  | CDOUBLE NotType
  | CVOID NotType 
- | QANYTYPE NotType              { $$ = ctype_anytype; DPRINTF (("anytype: %s", ctype_unparse ($$))); }
+ | QANYTYPE NotType              { $$ = ctype_makeAnytype (); }
  | QINTEGRALTYPE NotType         { $$ = ctype_anyintegral; }
  | QUNSIGNEDINTEGRALTYPE NotType { $$ = ctype_unsignedintegral; }
  | QSIGNEDINTEGRALTYPE NotType   { $$ = ctype_signedintegral; }
index 4d11f040d45ea2fb6f71c5d70b60a7b918574b20..d301d75deb688a36d74f8600e326aec9d2254447 100644 (file)
@@ -3009,7 +3009,7 @@ context_setString (flagcode flag, cstring val)
       {
        ; /* Okay not handle everything in this switch */
       }
-    }
+    } /* evans 2002-03-24: splintme reports a spurious (I think) warning here...need to look into it */
   
   if (cstring_length (val) >= 1
       && cstring_firstChar (val) == '\"')
index 25e1271a291c14e0a3df32cb6f45da2206248293..58dc81d139c79dce01cf017968863d6f34fa438a 100644 (file)
@@ -6737,7 +6737,7 @@ read_name_map (cppReader *pfile, cstring dirname)
 
   name = cstring_concatFree1 (name, cstring_makeLiteralTemp (FILE_NAME_MAP_FILE));
 
-  f = fileTable_openFile (context_fileTable (), name, "r");
+  f = fileTable_openReadFile (context_fileTable (), name);
   cstring_free (name);
 
   if (f == NULL)
index 74c68ba24658b90243418cd3c145003f1e4c0e4c..9c568d918708967a25f07ca1ad5c208b5b1ade76 100644 (file)
@@ -116,7 +116,7 @@ int cppProcess (/*@dependent@*/ cstring infile,
       llexit (LLFAILURE);
     }
 
-  ofile = fileTable_openFile (context_fileTable (), outfile, "w");
+  ofile = fileTable_createFile (context_fileTable (), outfile);
   
   if (ofile == NULL) 
     {
index 2d9c42f6661be2423bab4df0bfbab0d1c63fdef2..5e3d374b02999ce27059f533e00114b21462706c 100644 (file)
@@ -70,6 +70,7 @@ static ctype cttable_addDerived (ctkind p_ctk, /*@keep@*/ ctbase p_cnew, ctype p
 static ctype cttable_addFull (/*@keep@*/ ctentry p_cnew);
 static bool ctentry_isInteresting (ctentry p_c) /*@*/;
 static /*@notnull@*/ /*@only@*/ ctbase ctbase_makeFixedArray (ctype p_b, size_t p_size) /*@*/ ;
+static bool ctbase_isAnytype (/*@notnull@*/ ctbase p_b) /*@*/ ;
 
 /* 
 ** These are file-static macros (used in ctype.c).  No way to
@@ -538,7 +539,11 @@ ctbase_unparse (ctbase c)
                           enumNameList_unparseBrief (c->contents.cenum->members)));
        }
     case CT_CONJ:
-      if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS))
+      if (ctbase_isAnytype (c))
+       {
+         return (cstring_makeLiteral ("<any>"));
+       }
+      else if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS))
        {
          if (!ctype_isSimple (c->contents.conj->a) ||
              !ctype_isSimple (c->contents.conj->b))
@@ -609,7 +614,14 @@ static /*@only@*/ cstring
     case CT_UNION:
       return (message ("union %s { ... }", c->contents.su->name));
     case CT_CONJ:
-      return (message ("%t", c->contents.conj->a));
+      if (ctbase_isAnytype (c))
+       {
+         return (cstring_makeLiteral ("<any>"));
+       }
+      else
+       {
+         return (message ("%t", c->contents.conj->a));
+       }
     BADDEFAULT;
     }
   BADEXIT;
@@ -657,9 +669,16 @@ ctbase_unparseNotypes (ctbase c)
     case CT_ENUMLIST:
       return (message ("[enumlist]"));
     case CT_CONJ:
-      return (message ("%q/%q", 
-                      ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->a)),
-                      ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->b))));
+      if (ctbase_isAnytype (c))
+       {
+         return (cstring_makeLiteral ("<any>"));
+       }
+      else
+       {
+         return (message ("%q/%q", 
+                          ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->a)),
+                          ctbase_unparseNotypes (ctype_getCtbase (c->contents.conj->b))));
+       }
     BADDEFAULT;
     }
   BADEXIT;
@@ -754,8 +773,12 @@ ctbase_unparseDeclaration (ctbase c, /*@only@*/ cstring name) /*@*/
                           enumNameList_unparseBrief (c->contents.cenum->members),
                           name));
        }
-    case CT_CONJ:      
-      if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS))
+    case CT_CONJ:
+      if (ctbase_isAnytype (c))
+       {
+         return (message ("<any> %q", name));
+       }
+      else if (c->contents.conj->isExplicit || context_getFlag (FLG_SHOWALLCONJS))
        {
          if (!ctype_isSimple (c->contents.conj->a) ||
              !ctype_isSimple (c->contents.conj->b))
@@ -1839,6 +1862,23 @@ static /*@only@*/ ctbase
   return (c);
 }
 
+static bool ctbase_isAnytype (/*@notnull@*/ ctbase b)
+{
+  /*
+  ** A unknown|dne conj is a special representation for an anytype.
+  */
+
+  if (b->type == CT_CONJ)
+    {
+      /*@access ctype@*/
+      return (b->contents.conj->a == ctype_unknown
+             && b->contents.conj->b == ctype_dne);
+      /*@noaccess ctype@*/ 
+    }
+  
+  return FALSE;
+}
+
 static ctype
 ctbase_getConjA (/*@notnull@*/ ctbase c)
 {
index fd4daac1c79357e1ab8a38b2600d2d92500039b0..81cc6aacaff560a05acec9369a135fbe1051425a 100644 (file)
@@ -80,7 +80,7 @@ ctkind
 ctkind_fromInt (int i)
 {
   /*@+enumint@*/
-  if (i < CTK_ANYTYPE || i > CTK_COMPLEX)
+  if (i < CTK_UNKNOWN || i > CTK_COMPLEX)
     {
       llcontbug (message ("ctkind_fromInt: out of range: %d", i));
       return CTK_INVALID;
@@ -154,8 +154,9 @@ ctype_createUser (typeId u)
 ctype
 ctype_createAbstract (typeId u)
 {
- /* requires: ctype_createAbstract (u) is never called more than once for any u. */
- /*           [ tested by cttable_addFullSafe, not really required ]            */
+  /* requires: ctype_createAbstract (u) is never called more than once for any u. */
+  /*           [ tested by cttable_addFullSafe, not really required ]            */
+
   return (cttable_addFullSafe (ctentry_makeNew (CTK_PLAIN, ctbase_createAbstract (u))));
 }
 
@@ -232,30 +233,22 @@ ctype_realishType (ctype c)
   return c;
 }
 
-static bool 
-ctype_isSpecialType (ctype c)
-{
-  return (ctype_isUnknown (c) || ctype_isAnytype (c));
-}
-
 bool
 ctype_isUA (ctype c)
 {
-  return (!ctype_isSpecialType (c) 
-         && ctbase_isUA (ctype_getCtbase (c)));
+  return (!ctype_isUnknown (c) && ctbase_isUA (ctype_getCtbase (c)));
 }
 
 bool
 ctype_isUser (ctype c)
 {
-  return (!ctype_isSpecialType (c) 
-         && ctbase_isUser (ctype_getCtbase (c)));
+  return (!ctype_isUnknown (c) && ctbase_isUser (ctype_getCtbase (c)));
 }
 
 bool
 ctype_isAbstract (ctype c)
 {
-  return (!ctype_isSpecialType (c) 
+  return (!ctype_isUnknown (c) 
          && ((ctype_isPlain (c) && ctbase_isAbstract (ctype_getCtbaseSafe (c))) ||
              (ctype_isConj (c) &&
               (ctype_isAbstract (ctype_getConjA (c)) 
@@ -496,9 +489,9 @@ ctype_isWideString (ctype c)
 ctype
 ctype_getReturnType (ctype c)
 {
-  if (ctype_isSpecialType (c))
+  if (ctype_isUnknown (c))
     {
-      return c;
+      return ctype_unknown;
     }
 
   return (ctbase_baseFunction (ctype_getCtbaseSafe (c)));
@@ -511,7 +504,7 @@ ctype_getReturnType (ctype c)
 /*@observer@*/ uentryList
 ctype_argsFunction (ctype c)
 {
-  if (ctype_isSpecialType (c))
+  if (ctype_isUnknown (c))
     {
       return uentryList_undefined;
     }
@@ -597,9 +590,9 @@ ctype_compare (ctype c1, ctype c2)
   ctentry ce1;
   ctentry ce2;
 
-  if (ctype_isSpecialType (c1))
+  if (ctype_isUnknown (c1))
     {
-      if (ctype_isSpecialType (c2))
+      if (ctype_isUnknown (c2))
        {
          return 0;
        }
@@ -609,7 +602,7 @@ ctype_compare (ctype c1, ctype c2)
        }
     }
   
-  if (ctype_isSpecialType (c2))
+  if (ctype_isUnknown (c2))
     {
       return -1;
     }
@@ -1121,8 +1114,6 @@ ctype_isForceRealBool (ctype * c)
 static ctype
 ctype_makeConjAux (ctype c1, ctype c2, bool isExplicit)
 {
-  DPRINTF (("Make conj: %s / %s", ctype_unparse (c1), ctype_unparse (c2)));
-
   if (ctype_isBogus (c1) || ctype_isUndefined (c1))
     {
       return c2;
@@ -1147,9 +1138,11 @@ ctype_makeConjAux (ctype c1, ctype c2, bool isExplicit)
 ctype
 ctype_makeExplicitConj (ctype c1, ctype c2)
 {
-  DPRINTF (("Make conj: %s / %s", ctype_unparse (c1), ctype_unparse (c2)));
-
-  if (ctype_isFunction (c1) && !ctype_isFunction (c2))
+  if (ctype_isAnytype (c1) || ctype_isAnytype (c2))
+    {
+      return ctype_makeAnytype ();
+    }
+  else if (ctype_isFunction (c1) && !ctype_isFunction (c2))
     {
       ctype ret = ctype_makeExplicitConj (ctype_getReturnType (c1), c2);
 
@@ -1178,6 +1171,27 @@ static ctype ivb = ctype_unknown;  /* int | void * | bool */
 static ctype ivbf = ctype_unknown; /* int | void * | bool | float */
 static ctype cuc = ctype_unknown;  /* char | unsigned char */
 
+static ctype cany = ctype_unknown;
+
+ctype 
+ctype_makeAnytype ()
+{
+  if (cany == ctype_unknown)
+    {
+      cany = ctype_makeConj (ctype_unknown, ctype_dne);
+      llassert (ctype_isAnytype (cany));
+    }
+
+  DPRINTF (("make anytype: %s", ctype_unparse (cany)));
+  return cany;
+}
+
+bool 
+ctype_isAnytype (ctype c)
+{
+  return (c == cany);
+} 
+
 static void
 ctype_recordConj (ctype c)
 {
@@ -1298,7 +1312,15 @@ ctype_makeConj (ctype c1, ctype c2)
 
   DPRINTF (("Make conj: %s / %s", ctype_unparse (c1), ctype_unparse (c2)));
 
-  if (ctype_isUnknown (c1)) 
+  if (ctype_isAnytype (c1))
+    {
+      return c1;
+    }
+  else if (ctype_isAnytype (c2))
+    {
+      return c2;
+    }
+  else if (ctype_isUnknown (c1)) 
     {
       return c2;
     }
@@ -1489,7 +1511,6 @@ ctype_makeConj (ctype c1, ctype c2)
        {
          ;
        }
-
       
       return (cttable_addComplex (ctbase_makeConj (c1, c2, FALSE)));
     }
@@ -1641,11 +1662,11 @@ ctype_matchDef (ctype c1, ctype c2)
     return TRUE;
 
   if (ctype_isElips (c1))
-    return (ctype_isElips (c2) || ctype_isSpecialType (c2));
+    return (ctype_isElips (c2) || ctype_isUnknown (c2));
 
   if (ctype_isElips (c2))
     {
-      return (ctype_isSpecialType (c2));
+      return (ctype_isUnknown (c2));
     }
   else
     {
@@ -1665,14 +1686,10 @@ bool ctype_match (ctype c1, ctype c2)
     return TRUE;
 
   if (ctype_isElips (c1))
-    {
-      return (ctype_isElips (c2) || ctype_isSpecialType (c2));
-    }
-  
+    return (ctype_isElips (c2) || ctype_isUnknown (c2));
+
   if (ctype_isElips (c2))
-    {
-      return (ctype_isSpecialType (c2));
-    }
+    return (ctype_isUnknown (c2));
  
   return (ctbase_match (ctype_getCtbase (c1), ctype_getCtbase (c2)));
 }
@@ -1802,9 +1819,9 @@ ctype_typeId (ctype c)
 cstring
 ctype_unparseDeclaration (ctype c, /*@only@*/ cstring name)
 {
-  llassert (! (ctype_isElips (c) || ctype_isMissingParamsMarker (c)));
+  llassert (!(ctype_isElips (c) || ctype_isMissingParamsMarker (c)));
 
-  if (ctype_isSpecialType (c))
+  if (ctype_isUnknown (c))
     {
       return message ("? %q", name);
     }
@@ -1825,14 +1842,14 @@ ctype_unparse (ctype c)
     {
       return cstring_makeLiteralTemp ("-");
     }
-  else if (ctype_isUnknown (c))
-    {
-      return cstring_makeLiteralTemp ("?");
-    }
   else if (ctype_isAnytype (c))
     {
       return cstring_makeLiteralTemp ("<any>");
     }
+  else if (ctype_isUnknown (c))
+    {
+      return cstring_makeLiteralTemp ("?");
+    }
   else
     {
       /*@-modobserver@*/
@@ -1929,7 +1946,6 @@ ctype_getBaseType (ctype c)
 
   switch (ctentry_getKind (cte))
     {
-    case CTK_ANYTYPE:
     case CTK_UNKNOWN:
     case CTK_INVALID:
     case CTK_PLAIN:
@@ -2237,7 +2253,7 @@ bool ctype_isRefCounted (ctype t)
 
 bool ctype_isVisiblySharable (ctype t)
 {
-  if (ctype_isSpecialType (t)) return TRUE;
+  if (ctype_isUnknown (t)) return TRUE;
 
   if (ctype_isConj (t))
     {
@@ -2552,19 +2568,13 @@ ctype ctype_combine (ctype dominant, ctype modifier)
   
 ctype ctype_resolve (ctype c)
 {
-  if (ctype_isUnknown (c)
+  if (ctype_isUnknown (c) && !ctype_isAnytype (c))
     {
-      DPRINTF (("Resolving! %s", ctype_unparse (c)));
+      DPRINTF (("Resolving to int: %s", ctype_unparse (c)));
       return ctype_int;
     }
-  else if (c == ctype_anytype)
-    {
-      return ctype_unknown;
-    }
-  else
-    {
-      return c;
-    }
+
+  return c;
 }
 
 ctype ctype_fromQual (qual q)
@@ -2686,9 +2696,7 @@ static /*@observer@*/ ctbase ctype_getCtbase (ctype c)
        llbuglit ("ctype_getCtbase: ctype dne");
       if (c == ctype_elipsMarker)
        llbuglit ("ctype_getCtbase: elips marker");
-      if (c == ctype_anytype)
-       llbuglit ("ctype_getCtbase: ctype anytype");
-
+      
       llfatalbug (message ("ctype_getCtbase: ctype out of range: %d", c));
       BADEXIT;
     }
@@ -2731,8 +2739,6 @@ ctype_getCtentry (ctype c)
     }
   else if (c == CTK_UNKNOWN) 
     llcontbuglit ("ctype_getCtentry: ctype unknown");
-  else if (c == CTK_ANYTYPE) 
-    llcontbuglit ("ctype_getCtentry: ctype unknown");
   else if (c == CTK_INVALID)
     llcontbuglit ("ctype_getCtentry: ctype invalid (ctype_undefined)");
   else if (c == CTK_DNE)
index 98daa02fe6fc6e52f4b9123148e1007be5d9dc70..96c060dc5c0e426ba7be4880b258d93be77c6a22 100644 (file)
  * - Added conditional stuff (#define and #include) for IBM's compiler.
  */
 
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <fcntl.h>
 # include "splintMacros.nf"
 # include "llbasic.h"
 # include "osd.h"
 # include "llmain.h"
 # include "portab.h"
+
 # if defined(__IBMC__) && defined(OS2)
 # include <process.h>
 # define getpid _getpid
@@ -948,7 +952,6 @@ static /*@only@*/ cstring makeTempName (cstring dir, cstring pre, cstring suf)
       smsg = message ("%s%s%s%s%s", dir, pre, pidname, cstring_fromChars (msg), suf);
       nextMsg (msg);
     }
-  
 
   return smsg;
 }
@@ -984,9 +987,106 @@ fileTable_addOpen (fileTable ft, /*@observer@*/ FILE *f, /*@only@*/ cstring fnam
   ft->nopen++;
 }
 
-FILE *fileTable_openFile (fileTable ft, cstring fname, char *mode)
+FILE *fileTable_createFile (fileTable ft, cstring fname)
+{
+  int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR);
+
+  if (fdesc == -1)
+    {
+      osd_setTempError ();
+      llfatalerror (message ("Temporary file for "
+                            "pre-processor output already exists.  Trying to "
+                            "open: %s.",
+                            fname));
+
+      /*@notreached@*/ return NULL;
+    }
+  else
+    {
+      FILE *res = fdopen (fdesc, "w");
+  
+      if (res != NULL) 
+       {
+         fileTable_addOpen (ft, res, cstring_copy (fname));
+         DPRINTF (("Opening file: %s / %p", fname, res));
+       }
+      else
+       {
+         DPRINTF (("Error opening: %s", fname));
+       }
+
+      return res;
+    }
+}
+
+FILE *fileTable_createMacrosFile (fileTable ft, cstring fname)
+{
+  int fdesc = open (cstring_toCharsSafe (fname), O_RDWR | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR);
+
+  if (fdesc == -1)
+    {
+      osd_setTempError ();
+      llfatalerror (message ("Temporary file for "
+                            "pre-processor output already exists.  Trying to "
+                            "open: %s.",
+                            fname));
+
+      /*@notreached@*/ return NULL;
+    }
+  else
+    {
+      FILE *res = fdopen (fdesc, "w+");
+  
+      if (res != NULL) 
+       {
+         fileTable_addOpen (ft, res, cstring_copy (fname));
+         DPRINTF (("Opening file: %s / %p", fname, res));
+       }
+      else
+       {
+         DPRINTF (("Error opening: %s", fname));
+       }
+
+      return res;
+    }
+}
+
+FILE *fileTable_openReadFile (fileTable ft, cstring fname)
 {
-  FILE *res = fopen (cstring_toCharsSafe (fname), mode);
+  FILE *res = fopen (cstring_toCharsSafe (fname), "r");
+
+  if (res != NULL) 
+    {
+      fileTable_addOpen (ft, res, cstring_copy (fname));
+      DPRINTF (("Opening read file: %s / %p", fname, res));
+    }
+  else
+    {
+      DPRINTF (("Cannot open read file: %s", fname));
+    }
+
+  return res;
+}
+
+/*
+** Allows overwriting
+*/
+
+FILE *fileTable_openWriteFile (fileTable ft, cstring fname)
+{
+  FILE *res = fopen (cstring_toCharsSafe (fname), "w");
+
+  if (res != NULL) {
+    fileTable_addOpen (ft, res, cstring_copy (fname));
+    DPRINTF (("Opening file: %s / %p", fname, res));
+  }
+
+  return res;
+}
+
+FILE *fileTable_openWriteUpdateFile (fileTable ft, cstring fname)
+{
+  FILE *res = fopen (cstring_toCharsSafe (fname), "w+");
 
   if (res != NULL) {
     fileTable_addOpen (ft, res, cstring_copy (fname));
@@ -1010,7 +1110,7 @@ bool fileTable_closeFile (fileTable ft, FILE *f)
       if (ft->openelements[i]->f == f)
        {
          DPRINTF (("Closing file: %p = %s", f, ft->openelements[i]->fname));
-
+         
          if (i == ft->nopen - 1)
            {
              foentry_free (ft->openelements[i]);
index f3167fc76db458f4c01b422bccba591de37f167c..588cfb10a268ffafc19da191e47a733661deb7b8 100644 (file)
@@ -2855,7 +2855,7 @@ static flaglist flags =
     NULL, 0, 0
   },
   {
-    FK_LIBS, FK_INIT, globalFlag,
+    FK_LIBS, FK_INIT, idemGlobalFlag,
     "isolib",
     FLG_ANSILIB,
     "use normal standard library",
@@ -2863,7 +2863,7 @@ static flaglist flags =
     0, 0
   },
   {
-    FK_LIBS, FK_INIT, globalFlag,
+    FK_LIBS, FK_INIT, idemGlobalFlag,
     "strictlib",
     FLG_STRICTLIB,
     "interpret standard library strictly",
@@ -2872,7 +2872,7 @@ static flaglist flags =
     0, 0
   },
   {
-    FK_LIBS, FK_INIT, globalFlag,
+    FK_LIBS, FK_INIT, idemGlobalFlag,
     "unixlib",
     FLG_UNIXLIB,
     "use UNIX (sort-of) standard library",
@@ -2880,7 +2880,7 @@ static flaglist flags =
     0, 0
   },
   {
-    FK_LIBS, FK_INIT, globalFlag,
+    FK_LIBS, FK_INIT, idemGlobalFlag,
     "unixstrictlib",
     FLG_UNIXSTRICTLIB,
     "use strict version of UNIX (sort-of) library",
@@ -2888,7 +2888,7 @@ static flaglist flags =
     0, 0
   },
   {
-    FK_LIBS, FK_INIT, globalFlag,
+    FK_LIBS, FK_INIT, idemGlobalFlag,
     "posixlib",
     FLG_POSIXLIB,
     "use POSIX standard library",
@@ -2896,7 +2896,7 @@ static flaglist flags =
     0, 0
   },
   {
-    FK_LIBS, FK_INIT, globalFlag,
+    FK_LIBS, FK_INIT, idemGlobalFlag,
     "posixstrictlib",
     FLG_POSIXSTRICTLIB,
     "use strict POSIX standard library",
@@ -2904,7 +2904,7 @@ static flaglist flags =
     0, 0
   },
   {
-    FK_LIBS, FK_INIT, globalFlag,
+    FK_LIBS, FK_INIT, idemGlobalFlag,
     "whichlib",
     FLG_WHICHLIB,
     "show standard library filename",
index 78c91ebe7ba8c51ebaedfa1eaaf70ee055cda720..2b609f3e3b0b5f0b8838cbf3a0fd54ce5983c9aa 100644 (file)
@@ -50,7 +50,7 @@ outputLCSFile (char *path, char *msg, char *specname)
   char *sfile = mstring_concat (specname, ".lcs");
   char *outfile = mstring_concat (path, sfile);
   char *s;
-  FILE *outfptr = fileTable_openFile (context_fileTable (), cstring_fromChars (outfile), "w");
+  FILE *outfptr = fileTable_openWriteFile (context_fileTable (), cstring_fromChars (outfile));
   sfree (sfile);
 
   DPRINTF (("Output lcl file: %s / %s / %s", path, specname, outfile));
index c38bb077d0ae91a2e0161284c4ca4767e26c4050..743b26424a64b2199a175f13aa09140353944f0e 100644 (file)
@@ -279,8 +279,8 @@ inputStream_open (inputStream s)
       return TRUE;
     }
 
-  DPRINTF (("Open: %s", s->name));
-  s->file = fileTable_openFile (context_fileTable (), s->name, "r");
+  DPRINTF (("Opening: %s", s->name));
+  s->file = fileTable_openReadFile (context_fileTable (), s->name);
   return (s->file != 0 || s->fromString);
 }
 
index cc7d66135a8088c5d3de6f223aa760ceee6b7502..ac388a67d1edf5de4b45ecec8cd79ba9eadcbc7c 100644 (file)
@@ -274,7 +274,7 @@ 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);
 
   displayScanOpen (message ("Dumping to %s ", fname)); 
   
@@ -355,7 +355,7 @@ loadStandardState ()
     }
   else
     {
-      stdlib = fileTable_openFile (context_fileTable (), fpath, "r");
+      stdlib = fileTable_openReadFile (context_fileTable (), fpath);
 
       if (stdlib == NULL)
        {
@@ -405,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);
@@ -569,7 +569,7 @@ 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)
     {
index 9a44f211c7aa9aeb8fc933f5e75e9da872d5e8b3..2c477d9d58bd73b6315b38d884c4afb0b455e238 100644 (file)
--- a/src/lh.c
+++ b/src/lh.c
 # include "llmain.h"
 
 /*@constant static char TABCH; @*/
-# define TABCH                 '\1'
+# define TABCH                 ' '
 
 /*@constant static char TABINCH; @*/
-# define TABINCH       '\2'
+# define TABINCH       '\t'
 
-/*@constant static char TABOUTCH; @*/
-# define TABOUTCH      '\3'
-
-/*
-  # define TAB                         fputc (TABCH,   LhFile.f);
-  # define TABIN               fputc (TABINCH,         LhFile.f);
-  # define TABOUT              fputc (TABOUTCH, LhFile.f);
-*/
 
 /*@private@*/ typedef struct
 {
@@ -82,15 +74,6 @@ static cstring lhTypeSpecNode (lclTypeSpecNode p_typespec);
 static /*@only@*/ cstring lhTypeExpr (/*@null@*/ typeExpr p_x);
 static /*@only@*/ cstring lhDeclaratorNode (declaratorNode p_x);
 
-static /*:open:*/ /*@dependent@*/ /*@null@*/ FILE *out_open (cstring name, cstring suffix)
-     /*@modifies fileSystem@*/
-{
-  cstring fullname = cstring_concat (name, suffix);
-  FILE *ret = fileTable_openFile (context_fileTable (), fullname, "w+");
-  cstring_free (fullname);
-  return ret;
-}
-
 /*@only@*/ cstring 
 lhFunction (lclTypeSpecNode lclTypeSpec, declaratorNode declarator)
 {
@@ -99,7 +82,7 @@ lhFunction (lclTypeSpecNode lclTypeSpec, declaratorNode declarator)
   if (!genLh)
     return cstring_undefined;
   
-  s = message ("extern %q\1%q;", lhTypeSpecNode (lclTypeSpec),
+  s = message ("extern %q %q;", lhTypeSpecNode (lclTypeSpec),
               lhDeclaratorNode (declarator));
   
   return s;
@@ -261,7 +244,7 @@ lhVarDecl (lclTypeSpecNode lclTypeSpec, initDeclNodeList initDecls,
       break;
     }
   
-  s = message ("%q %q\1", s, lhTypeSpecNode (lclTypeSpec));
+  s = message ("%q %q ", s, lhTypeSpecNode (lclTypeSpec));
 
   initDeclNodeList_elements (initDecls, i)
   {
@@ -289,71 +272,19 @@ lhCleanup (void)
     }
   else
     {
-      FILE *f;
-      int c, col = 0, tabcol = 0;
-      cstring fullname;
-
-      f = out_open (LhFile.name, LH_EXTENSION);
       llassert (LhFile.f != NULL);
       
-      fullname = cstring_concat (LhFile.name, LHTMP_EXTENSION);
-
-      if (f == NULL)
+      if (LhFile.f == NULL)
        {
          /*@i25534  check this!  does it report the right filename? */
-         lldiagmsg (message ("Cannot open lh file for output: %s", 
-                             fullname));
+         lldiagmsg (message ("Cannot open lh file for output: %s", LhFile.name));
        }
       else
        {
-         fprintf (f, "/* Output from %s */\n", LCL_PARSE_VERSION);
-
-         rewind (LhFile.f);
-
-         while (EOF != (c = getc (LhFile.f)))
-           {
-             switch (c)
-               {
-               case TABCH:
-                 if (col == 0)
-                   {
-                     if (tabcol > 0)
-                       fprintf (f, "%*s", tabcol, "");
-                   }
-                 else
-                   {
-                     check (fputc (' ', f) == (int) ' ');
-                   }
-                 /*@switchbreak@*/ break;
-                 
-               case TABINCH:
-                 tabcol += 4;
-                 /*@switchbreak@*/ break;
-                 
-               case TABOUTCH:
-                 tabcol -= 4;
-                 /*@switchbreak@*/ break;
-                 
-               case '\n':
-                 col = 0;
-                 check (fputc (c, f) == (int) c);
-                 /*@switchbreak@*/ break;
-                 
-               default:
-                 col++;
-                 check (fputc (c, f) == (int) c);
-                 /*@switchbreak@*/ break;
-               }
-           }
-
-         check (fileTable_closeFile (context_fileTable (), f));
+         check (fprintf (LhFile.f, "/* Output from %s */\n", LCL_PARSE_VERSION) > 0);
          check (fileTable_closeFile (context_fileTable (), LhFile.f));
-
-         (void) osd_unlink (fullname);
          LhFile.f = NULL;
        }
-      
-      cstring_free (fullname);
     }
 }
 
@@ -364,32 +295,7 @@ lhIncludeBool (void)
   needIncludeBool = TRUE;
 }
 
-/*
-**++
-**  FUNCTIONAL DESCRIPTION:
-**
-**      Initialize the .lh file processing.
-**
-**  FORMAL PARAMETERS:
-**
-**      source * f: The source file, from which we compute the name of
-**     the .lh file.
-**
-**     bool outputLh: If true, produce a .lh file, otherwise don't.
-**
-**  RETURN VALUE:
-**
-**      None
-**
-**  SIDE EFFECTS:
-**
-**      The .lh file may be opened.
-**
-**
-**--
-*/
-
-void lhInit (inputStream  f) /*@globals undef LhFile; @*/
+void lhInit (inputStream f) /*@globals undef LhFile; @*/
 {
   static bool lherror = FALSE;
   
@@ -401,18 +307,17 @@ void lhInit (inputStream  f) /*@globals undef LhFile; @*/
       return;
     }
   
-  LhFile.name = LSLRootName (inputStream_fileName (f));
-  LhFile.f = out_open (LhFile.name, LHTMP_EXTENSION);
+  LhFile.name = cstring_concatFree1 (LSLRootName (inputStream_fileName (f)),
+                                    LH_EXTENSION);
+  LhFile.f = fileTable_openWriteUpdateFile (context_fileTable (), LhFile.name);
 
   if (LhFile.f == NULL)
     {
       genLh = FALSE;
       if (!lherror)
        {
-         lclplainerror (message ("Cannot write temporary %s file: %s%s", 
-                                 LH_EXTENSION,
-                                 LhFile.name,
-                                 LHTMP_EXTENSION));
+         lclplainerror (message ("Cannot write temporary file: %s", 
+                                 LhFile.name));
          lherror = TRUE;
        }
     } 
@@ -423,6 +328,7 @@ void lhOutLine (/*@only@*/ cstring s)
   if (genLh)
     {
       llassert (LhFile.f != NULL);
+      DPRINTF (("lhOutLine: %s / %s", s, LhFile.name));
 
       if (cstring_length (s) > 0) 
        {
index 9b2251f6e89b560bfd77884ff6f8160ed8d2ab28..a847b1bf530537ed6c4ebb31d7e9d7c37bb507c6 100644 (file)
@@ -2295,7 +2295,7 @@ bool readOptionsFile (cstring fname, cstringSList *passThroughArgs, bool report)
     }
   else
     {
-      FILE *innerf = fileTable_openFile (context_fileTable (), fname, "r");
+      FILE *innerf = fileTable_openReadFile (context_fileTable (), fname);
       
       if (innerf != NULL)
        {
index 053ed81b3f25356aa4c15ef59e8e8f262d52f0e1..9f7b3af77d1f42bfc5814fdd4c31a4e2e9b2f35c 100644 (file)
@@ -387,7 +387,7 @@ callLSL (/*@unused@*/ cstring specfile, /*@only@*/ cstring text)
   FILE *inptr;
 
   infile = fileTable_fileName (fileTable_addltemp (context_fileTable ()));
-  inptr = fileTable_openFile (context_fileTable (), infile, "w");
+  inptr = fileTable_createFile (context_fileTable (), infile);
   
   if (inptr == NULL)
     {
@@ -428,7 +428,7 @@ static void invokeLSL (cstring infile, cstring outfile, bool deletep)
   ** way to do this. 
   */
   
-  outptr = fileTable_openFile (context_fileTable (), outfile, "w");
+  outptr = fileTable_createFile (context_fileTable (), outfile);
 
   if (outptr == NULL)
     {                  
index 6a59b64bbdde7c0ce4b7d8e0ead88dde62817069..027eb52aefd6041732ed48a27c9b0557e8865b31 100644 (file)
@@ -237,7 +237,7 @@ static void pushString (/*@only@*/ cstring s)
       mtid = fileTable_addMacrosFile (context_fileTable ());
       
       fname = fileTable_fileName (mtid);
-      s_macFile = fileTable_openFile (context_fileTable (), fname, "wb+");
+      s_macFile = fileTable_createMacrosFile (context_fileTable (), fname); /* , "wb+"); ? **/
       
       if (s_macFile == NULL)
        {
index 9af9d100282934657127474b9e1e402408e2e3fb..8ba1c6045d2bba2bc41246203b566420045a50ee 100644 (file)
--- a/src/osd.c
+++ b/src/osd.c
@@ -305,7 +305,7 @@ osd_fileExists (cstring filespec)
   return (stat (cstring_toCharsSafe (filespec), &buf) == 0);
 # else
 # if defined (WIN32) || defined (OS2)
-  FILE *test = fileTable_openFile (context_fileTable (), filespec, "r");
+  FILE *test = fileTable_openReadFile (context_fileTable (), filespec);
   
   if (test != NULL) 
     {
@@ -567,7 +567,7 @@ cstring osd_fixDefine (cstring x)
 
 bool osd_fileIsReadable (cstring f)
 {
-  FILE *fl = fileTable_openFile (context_fileTable (), f, "r");
+  FILE *fl = fileTable_openReadFile (context_fileTable (), f);
 
   if (fl != NULL)
     {
index 69e810c8fae651f73c6a11676bd82db6b3e85083..52a2f287262529be444f11d86434160812477cfa 100644 (file)
@@ -1594,7 +1594,7 @@ usymtab_rehash (/*@notnull@*/ usymtab s)
       cstringTable_free (s->htable);
     }
   
-  s->htable = cstringTable_create (LLHASHSIZE);
+  s->htable = cstringTable_create (LLAHSHSIZE);
 
   for (i = 0; i < s->nentries; i++)
     {
index 3a27d48519e3e82afc7e1dbe08e1fbcb6fcd5c38..dafec7b68517017b35e765a79abbe53384b3ae4e 100644 (file)
@@ -561,25 +561,25 @@ drive.c:134: Return value (type bool) ignored: fire(17)
 drive.c:158: Return value (type bool) ignored: fire(empset_choo...
 drive.c:11: Parameter argv not used
 dbase.c:11: Type employeeKinds declared but not used
-eref.lh:8: Function exported but not used outside eref: eref_free
+eref.lh:7: Function exported but not used outside eref: eref_free
    eref.h:23: Definition of eref_free
-empset.lh:8: Function exported but not used outside empset: empset_final
+empset.lh:7: Function exported but not used outside empset: empset_final
    empset.h:29: Definition of empset_final
-empset.lh:9: Function exported but not used outside empset: empset_clear
+empset.lh:8: Function exported but not used outside empset: empset_clear
    empset.c:24: Definition of empset_clear
-empset.lh:11: Function exported but not used outside empset:
+empset.lh:10: Function exported but not used outside empset:
                  empset_insertUnique
    empset.c:53: Definition of empset_insertUnique
-empset.lh:17: Function exported but not used outside empset: empset_member
+empset.lh:16: Function exported but not used outside empset: empset_member
    empset.h:30: Definition of empset_member
-empset.lh:18: Function exported but not used outside empset: empset_subset
+empset.lh:17: Function exported but not used outside empset: empset_subset
    empset.c:144: Definition of empset_subset
-ereftab.lh:10: Function exported but not used outside ereftab: ereftab_delete
+ereftab.lh:9: Function exported but not used outside ereftab: ereftab_delete
    ereftab.c:26: Definition of ereftab_delete
 dbase.c:13: Variable exported but not used outside dbase: db
-dbase.lh:27: Function exported but not used outside dbase: promote
+dbase.lh:26: Function exported but not used outside dbase: promote
    dbase.c:182: Definition of promote
-dbase.lh:28: Function exported but not used outside dbase: setSalary
+dbase.lh:27: Function exported but not used outside dbase: setSalary
    dbase.c:206: Definition of setSalary
 empset.h:10: Variable exported but not used outside empset: known
 dbase.c:15: Variable exported but not used outside dbase: initDone
index bf162d162f874a583564e0a847a346d8ab0c7372..41ce3327737ecbcde7944c6ace714c7d93b0c8db 100644 (file)
@@ -119,6 +119,6 @@ repexpose.c:51:10: Function returns reference to parameter im: (im->name)
 repexpose.c:51:10: Return value exposes rep of immut: (im->name)
 repexpose.c: (in function abst_setIm)
 repexpose.c:57:3: Undocumented modification of a->im: a->im = im
-repexpose.lh:6:16: Variable globstring declared but not defined
+repexpose.lh:5:16: Variable globstring declared but not defined
 
 Finished checking --- 27 code warnings, as expected
index 008e6193bd90393de73d9afccdb43fceae73f6b6..9a3bf8a5f1609565d0c90bdf629f77d53e7c3371 100644 (file)
@@ -4,13 +4,13 @@ utypes.c:16: Include file <sys/types.h> matches the name of a POSIX library,
     +posixstrictlib to select the POSIX library, or -warnposix to suppress this
     message.
 utypes.c:3:23: Variable uchar inconsistently redeclared as datatype
-   utypes.c:13: Previous definition of uchar as variable: ?
+   utypes.c:13: Previous definition of uchar as variable: <any>
 utypes.c:4:24: Variable ushort inconsistently redeclared as datatype
-   utypes.c:15: Previous definition of ushort as variable: ?
+   utypes.c:15: Previous definition of ushort as variable: <any>
 utypes.c:5:22: Variable uint inconsistently redeclared as datatype
-   utypes.c:14: Previous definition of uint as variable: ?
+   utypes.c:14: Previous definition of uint as variable: <any>
 utypes.c:6:23: Variable ulong inconsistently redeclared as datatype
-   utypes.c:16: Previous definition of ulong as variable: ?
+   utypes.c:16: Previous definition of ulong as variable: <any>
 utypes.c: (in function f)
 utypes.c:26:8: Variable src_bytes declared but not used
 
This page took 0.144662 seconds and 5 git commands to generate.