/*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)
/*@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;
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
** 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;
/*@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@*/;
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@*/
void clearerr (FILE *stream) /*@modifies *stream@*/ ;
int feof (FILE *stream) /*@modifies errno@*/ ;
+
int ferror (FILE *stream) /*@modifies errno@*/ ;
void perror (/*@null@*/ char *s)
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)
/*@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@*/ ;
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 *);
/*@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
} ;
/*@=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@*/
/*@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 */
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 *);
/*@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")
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))
# 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)
typedef enum
{
- CTK_ANYTYPE = -4,
CTK_UNKNOWN = -3,
CTK_INVALID = -2,
CTK_DNE = -1,
/*@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
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) /*@*/ ;
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))
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@*/ ;
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:
{
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:
{
{ 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; ;
| 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; }
{
; /* 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) == '\"')
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)
llexit (LLFAILURE);
}
- ofile = fileTable_openFile (context_fileTable (), outfile, "w");
+ ofile = fileTable_createFile (context_fileTable (), outfile);
if (ofile == NULL)
{
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
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))
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;
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;
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))
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)
{
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;
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))));
}
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))
ctype
ctype_getReturnType (ctype c)
{
- if (ctype_isSpecialType (c))
+ if (ctype_isUnknown (c))
{
- return c;
+ return ctype_unknown;
}
return (ctbase_baseFunction (ctype_getCtbaseSafe (c)));
/*@observer@*/ uentryList
ctype_argsFunction (ctype c)
{
- if (ctype_isSpecialType (c))
+ if (ctype_isUnknown (c))
{
return uentryList_undefined;
}
ctentry ce1;
ctentry ce2;
- if (ctype_isSpecialType (c1))
+ if (ctype_isUnknown (c1))
{
- if (ctype_isSpecialType (c2))
+ if (ctype_isUnknown (c2))
{
return 0;
}
}
}
- if (ctype_isSpecialType (c2))
+ if (ctype_isUnknown (c2))
{
return -1;
}
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;
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);
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)
{
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;
}
{
;
}
-
return (cttable_addComplex (ctbase_makeConj (c1, c2, FALSE)));
}
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
{
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)));
}
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);
}
{
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@*/
switch (ctentry_getKind (cte))
{
- case CTK_ANYTYPE:
case CTK_UNKNOWN:
case CTK_INVALID:
case CTK_PLAIN:
bool ctype_isVisiblySharable (ctype t)
{
- if (ctype_isSpecialType (t)) return TRUE;
+ if (ctype_isUnknown (t)) return TRUE;
if (ctype_isConj (t))
{
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)
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;
}
}
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)
* - 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
smsg = message ("%s%s%s%s%s", dir, pre, pidname, cstring_fromChars (msg), suf);
nextMsg (msg);
}
-
return smsg;
}
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));
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]);
NULL, 0, 0
},
{
- FK_LIBS, FK_INIT, globalFlag,
+ FK_LIBS, FK_INIT, idemGlobalFlag,
"isolib",
FLG_ANSILIB,
"use normal standard library",
0, 0
},
{
- FK_LIBS, FK_INIT, globalFlag,
+ FK_LIBS, FK_INIT, idemGlobalFlag,
"strictlib",
FLG_STRICTLIB,
"interpret standard library strictly",
0, 0
},
{
- FK_LIBS, FK_INIT, globalFlag,
+ FK_LIBS, FK_INIT, idemGlobalFlag,
"unixlib",
FLG_UNIXLIB,
"use UNIX (sort-of) standard library",
0, 0
},
{
- FK_LIBS, FK_INIT, globalFlag,
+ FK_LIBS, FK_INIT, idemGlobalFlag,
"unixstrictlib",
FLG_UNIXSTRICTLIB,
"use strict version of UNIX (sort-of) library",
0, 0
},
{
- FK_LIBS, FK_INIT, globalFlag,
+ FK_LIBS, FK_INIT, idemGlobalFlag,
"posixlib",
FLG_POSIXLIB,
"use POSIX standard library",
0, 0
},
{
- FK_LIBS, FK_INIT, globalFlag,
+ FK_LIBS, FK_INIT, idemGlobalFlag,
"posixstrictlib",
FLG_POSIXSTRICTLIB,
"use strict POSIX standard library",
0, 0
},
{
- FK_LIBS, FK_INIT, globalFlag,
+ FK_LIBS, FK_INIT, idemGlobalFlag,
"whichlib",
FLG_WHICHLIB,
"show standard library filename",
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));
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);
}
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));
}
else
{
- stdlib = fileTable_openFile (context_fileTable (), fpath, "r");
+ stdlib = fileTable_openReadFile (context_fileTable (), fpath);
if (stdlib == NULL)
{
sfree (ot);
check (fileTable_closeFile (context_fileTable (), stdlib));
- stdlib = fileTable_openFile (context_fileTable (), fpath, "r");
+ stdlib = fileTable_openReadFile (context_fileTable (), fpath);
}
llassert (stdlib != NULL);
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)
{
# 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
{
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)
{
if (!genLh)
return cstring_undefined;
- s = message ("extern %q\1%q;", lhTypeSpecNode (lclTypeSpec),
+ s = message ("extern %q %q;", lhTypeSpecNode (lclTypeSpec),
lhDeclaratorNode (declarator));
return s;
break;
}
- s = message ("%q %q\1", s, lhTypeSpecNode (lclTypeSpec));
+ s = message ("%q %q ", s, lhTypeSpecNode (lclTypeSpec));
initDeclNodeList_elements (initDecls, i)
{
}
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);
}
}
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;
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;
}
}
if (genLh)
{
llassert (LhFile.f != NULL);
+ DPRINTF (("lhOutLine: %s / %s", s, LhFile.name));
if (cstring_length (s) > 0)
{
}
else
{
- FILE *innerf = fileTable_openFile (context_fileTable (), fname, "r");
+ FILE *innerf = fileTable_openReadFile (context_fileTable (), fname);
if (innerf != NULL)
{
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)
{
** way to do this.
*/
- outptr = fileTable_openFile (context_fileTable (), outfile, "w");
+ outptr = fileTable_createFile (context_fileTable (), outfile);
if (outptr == NULL)
{
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)
{
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)
{
bool osd_fileIsReadable (cstring f)
{
- FILE *fl = fileTable_openFile (context_fileTable (), f, "r");
+ FILE *fl = fileTable_openReadFile (context_fileTable (), f);
if (fl != NULL)
{
cstringTable_free (s->htable);
}
- s->htable = cstringTable_create (LLHASHSIZE);
+ s->htable = cstringTable_create (LLAHSHSIZE);
for (i = 0; i < s->nentries; i++)
{
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
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
+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