]> andersk Git - splint.git/blobdiff - src/inputStream.c
Fixed all /*@i...@*/ tags (except 1).
[splint.git] / src / inputStream.c
index 667f6687c5f40db898dce1f326568cbe524c2637..70931d02209eda960510641366a11baea6d2934f 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 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
@@ -17,8 +17,8 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-bug@cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
 ** For more information: http://www.splint.org
 */
 /*
@@ -44,8 +44,8 @@
 **     Joe Wild, Technical Languages and Environments, DECspec project
 */
 
-# include "lclintMacros.nf"
-# include "llbasic.h"
+# include "splintMacros.nf"
+# include "basic.h"
 # include "osd.h"
 # include "portab.h"
 
@@ -76,17 +76,16 @@ inputStream_free (/*@null@*/ /*@only@*/ 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)
@@ -109,8 +108,9 @@ extern /*@only@*/ inputStream
   s->fromString = FALSE;
   s->stringSource = NULL;
   s->stringSourceTail = NULL;
-  
-  /*@i3254@*/ return s;
+  s->buffer[0] = '\0';
+
+  return s;
 }
 
 extern /*@only@*/ inputStream 
@@ -161,6 +161,7 @@ extern int inputStream_nextChar (inputStream s)
 extern int inputStream_peekNChar (inputStream s, int n)
      /* Doesn't work across lines! */
 {
+  llassert (inputStream_isDefined (s));
   llassert (s->curLine != NULL);
   llassert (s->charNo + n < strlen (s->curLine));
   return ((int) s->curLine [s->charNo + n]);
@@ -168,6 +169,8 @@ extern int inputStream_peekNChar (inputStream s, int n)
 
 extern int inputStream_peekChar (inputStream s)
 {  
+  llassert (inputStream_isDefined (s));
+
   if (s->curLine == NULL)
     {
       char *cur;
@@ -196,8 +199,9 @@ extern /*@dependent@*/ /*@null@*/
 char *inputStream_nextLine (inputStream s)
 {
   char *currentLine;
-  int len;
+  size_t len;
 
+  llassert (inputStream_isDefined (s));
   llassert (s->curLine == NULL);
   s->charNo = 0;
 
@@ -218,15 +222,15 @@ char *inputStream_nextLine (inputStream s)
              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@*/
@@ -252,7 +256,7 @@ char *inputStream_nextLine (inputStream s)
        }
       else 
        {
-         if (len >= STUBMAXRECORDSIZE - 2)
+         if (len >= size_fromInt (STUBMAXRECORDSIZE - 2))
            {
              lldiagmsg (message ("Input line too long: %s",
                                  cstring_fromChars (currentLine)));
@@ -267,6 +271,7 @@ char *inputStream_nextLine (inputStream s)
 extern bool
 inputStream_open (inputStream s)
 {
+  llassert (inputStream_isDefined (s));
   if (s->fromString)
     {
       /* not an error: tail is dependent */
@@ -274,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);
 }
 
@@ -335,6 +340,7 @@ extern bool inputStream_getPath (cstring path, inputStream s)
 /*:open:*/ FILE *inputStream_getFile (inputStream s)
 {
   llassert (inputStream_isDefined (s));
+  llassert (s->file != NULL);
   return s->file;
 }
 
This page took 0.218345 seconds and 4 git commands to generate.