]> andersk Git - splint.git/blobdiff - src/inputStream.c
Fixed line numbering when multi-line macro parameters are used.
[splint.git] / src / inputStream.c
index b454fee8266840c1997fbc8aecd3f08bb138b2e1..c38bb077d0ae91a2e0161284c4ca4767e26c4050 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2002 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -17,9 +17,9 @@
 ** 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 more information: http://lclint.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
 */
 /*
 ** source.c
@@ -44,7 +44,7 @@
 **     Joe Wild, Technical Languages and Environments, DECspec project
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "llbasic.h"
 # include "osd.h"
 # include "portab.h"
@@ -56,7 +56,7 @@ inputStream_close (inputStream s)
 
   if (s->file != NULL)
     {
-      check (fclose (s->file) == 0);
+      check (fileTable_closeFile (context_fileTable (), s->file));
       s->file = NULL;
       return TRUE;
     }
@@ -127,6 +127,7 @@ inputStream_fromString (cstring name, cstring str)
   s->lineNo = 0;
   s->charNo = 0;
   s->curLine = NULL;
+  s->buffer[0] = '\0';
 
   return s;
 }
@@ -160,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]);
@@ -167,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;
@@ -197,6 +201,7 @@ char *inputStream_nextLine (inputStream s)
   char *currentLine;
   int len;
 
+  llassert (inputStream_isDefined (s));
   llassert (s->curLine == NULL);
   s->charNo = 0;
 
@@ -266,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,7 +280,7 @@ inputStream_open (inputStream s)
     }
 
   DPRINTF (("Open: %s", s->name));
-  s->file = fopen (cstring_toCharsSafe (s->name), "r");
+  s->file = fileTable_openFile (context_fileTable (), s->name, "r");
   return (s->file != 0 || s->fromString);
 }
 
@@ -331,9 +337,10 @@ extern bool inputStream_getPath (cstring path, inputStream s)
   return rVal;
 }
 
-/*@open@*/ FILE *inputStream_getFile (inputStream s)
+/*:open:*/ FILE *inputStream_getFile (inputStream s)
 {
   llassert (inputStream_isDefined (s));
+  llassert (s->file != NULL);
   return s->file;
 }
 
This page took 0.056832 seconds and 4 git commands to generate.