/*
** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2002 University of Virginia,
+** Copyright (C) 1994-2003 University of Virginia,
** Massachusetts Institute of Technology
**
** This program is free software; you can redistribute it and/or modify it
}
t->fname = tn;
-
t->basename = cstring_undefined;
t->ftemp = temp;
t->ftype = typ;
ft->nopen = 0;
ft->nopenspace = FTBASESIZE;
ft->openelements = (foentry *) dmalloc (FTBASESIZE * sizeof (*ft->openelements));
-
+
return (ft);
}
+/*@-bounds@*/
static void
fileTable_grow (fileTable ft)
{
sfree (ft->elements);
ft->elements = newent;
}
-
+/*@=bounds@*/
static void
fileTable_growOpen (fileTable ft)
{
{
cstring sd = cstring_downcase (e->fname);
cstringTable_insert (ft->htable, sd, ft->nentries);
- cstring_free (e->fname);
}
else
{
- cstringTable_insert (ft->htable, e->fname, ft->nentries);
+ cstringTable_insert (ft->htable, cstring_copy (e->fname), ft->nentries);
}
+ /* evans 2002-07-12:
+ Before, there was no cstring_copy above, and e->fname was free'd in the if branch.
+ Splint should have caught this, and produced a warning for this assignment.
+ Why not?
+ */
ft->elements[ft->nentries] = e;
ft->nentries++;
cstring absname = osd_absolutePath (NULL, name);
int tindex = fileTable_getIndex (ft, absname);
- DPRINTF (("Got abs path: %s", absname));
+ /*@i534 fprintf (stderr, "Got abs path: %s", absname); */
llassert (ft != fileTable_undefined);
if (tindex != NOT_FOUND)
return (fileTable_addFilePrim (ft, name, FALSE, FILE_XH, fileId_invalid));
}
-# ifndef NOLCL
fileId
fileTable_addImportFile (fileTable ft, cstring name)
{
{
return (fileTable_addFilePrim (ft, name, FALSE, FILE_HEADER, fileId_invalid));
}
-# endif
-# ifndef NOLCL
static int tmpcounter = 0;
-# endif
fileId
fileTable_addMacrosFile (fileTable ft)
return res;
}
-# ifndef NOLCL
fileId
fileTable_addltemp (fileTable ft)
{
cstring_free (newname);
return (ret);
}
-# endif
bool
fileTable_exists (fileTable ft, cstring s)
if (msg)
{
(void) fflush (g_warningstream);
- fprintf (stderr, "< cleaning");
+ displayScanOpen (cstring_makeLiteral ("cleaning"));
}
for (i = 0; i < ft->nentries; i++)
if (msg && ((i % skip) == 0))
{
- (void) fflush (g_warningstream);
-
- if (i == 0) {
- fprintf (stderr, " ");
- } else {
- fprintf (stderr, ".");
- }
-
- (void) fflush (stderr);
+ displayScanContinue (cstring_makeLiteral (i == 0 ? " " : "."));
}
}
-
+
if (msg)
{
- fprintf (stderr, " >\n");
+ displayScanClose ();
}
}
cstringTable_free (f->htable);
sfree (f->elements);
+ sfree (f->openelements); /*!! why didn't splint report this? */
sfree (f);
}
static int pid = 0;
static /*@owned@*/ char *msg = NULL;
static /*@only@*/ cstring pidname = NULL;
- int maxlen;
+ size_t maxlen;
cstring smsg;
llassert (cstring_length (pre) <= 3);
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);
+# ifdef WIN32
+ int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL); /* not supported by VS.net: , S_IRUSR | S_IWUSR); */
+# else
+ int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR);
+# endif
if (fdesc == -1)
{