/*
** 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
*/
# include "splintMacros.nf"
-# include "llbasic.h"
+# include "basic.h"
# include "osd.h"
-# include "portab.h"
extern bool
inputStream_close (inputStream s)
}
extern /*@only@*/ inputStream
- inputStream_create (cstring name, cstring suffix, bool echo)
+inputStream_create (cstring name, cstring suffix, bool echo)
{
char *ps;
inputStream s = (inputStream) dmalloc (sizeof (*s));
-
+
s->name = name;
s->file = NULL;
/*@access cstring@*/
llassert (cstring_isDefined (s->name));
- /*@i534 clean this up...*/
ps = strrchr (s->name, CONNECTCHAR);
if (ps == NULL)
s->fromString = FALSE;
s->stringSource = NULL;
s->stringSourceTail = NULL;
-
- /*@i3254@*/ return s;
+ s->buffer[0] = '\0';
+
+ return s;
}
extern /*@only@*/ inputStream
char *inputStream_nextLine (inputStream s)
{
char *currentLine;
- int len;
+ size_t len;
llassert (inputStream_isDefined (s));
llassert (s->curLine == NULL);
c = strchr (s->stringSourceTail, '\0');
}
- len = c - s->stringSourceTail + 1;
+ len = size_fromInt (c - s->stringSourceTail + 1);
- if (len > STUBMAXRECORDSIZE - 2)
+ if (len > size_fromInt (STUBMAXRECORDSIZE - 2))
{
- len = (STUBMAXRECORDSIZE - 2);
+ len = size_fromInt (STUBMAXRECORDSIZE - 2);
}
currentLine = &(s->buffer)[0];
- strncpy (currentLine, s->stringSourceTail, size_fromInt (len));
+ strncpy (currentLine, s->stringSourceTail, len);
currentLine[len] = '\0';
s->stringSourceTail += len;
/*@noaccess cstring@*/
}
else
{
- if (len >= STUBMAXRECORDSIZE - 2)
+ if (len >= size_fromInt (STUBMAXRECORDSIZE - 2))
{
lldiagmsg (message ("Input line too long: %s",
cstring_fromChars (currentLine)));
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);
}