🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.graphics.avs
Article #123

AVS does not close input file?

#123
From: Etienne van der Poel
Date: Sun, 30 Aug 1992 15:35
48 lines
2326 bytes
Hi

I am in the process of writing a module that reads an external data file (which
is in a non-AVS format) and outputs data in the AVS field format. The input 
file name is specified with a file name browser. The file is opened, and the
data read into memory with a parser (the data is in the form of a formal grammar).
The user then selects a subset of the data, which is then output in the AVS
field format.

Everything works fine, until the filename parameter is changed. The parser tries
to continue parsing at the end of previous file!? It is as if the previous file
is never closed.

Here is the code. Could some guru please point out my mistake. Please E-mail me
directly.  Oh yes, the module is written as a subroutine.

-----
int read_mbpo_compute( output, infilename, extract)
  AVSfield  **output;
  char       *infilename;
  char       *extract;
{
  FILE *infile=NULL;

  if (!infilename)                     /* if no infilename             */
    return(1);

  if (!(infile = fopen(infilename, "r")))  /* open the input file      */
    {
      AVSerror("Cannot open input file %s", infilename);
      return(0);
    }
  mbpo_read( infile);                  /* parse the input file         */
  fclose( infile);                     /* close the input file         */

  check_extracted_select( extract);    /* mark data to be extracted    */
  write_output( output);               /* write extracted data         */
  return(1);
}
-----

Etienne  

\_\_\_ \_    \_ \_\_\_  \_\_\_\_\_\_\_           Department of Computer Science
 \_     \_    \_ \_   \_ \_\_\_\_\_\_\_\_\_\_\_   University of Stellenbosch
  \_\_   \_    \_ \_\_\_  \_\_\_\_\_\_\_\_         Stellenbosch 7600
   \_      \_ \_   \_      \_\_\_\_\_\_\_\_\_\_\_\_ South Africa
    \_\_\_   \_     \_      \_\_\_\_\_\_\_\_\_\_     Internet: evp@cs.sun.ac.za
Technical Details
Message-ID: <1992Aug30.153547.15303@hippo.ru.ac.za>
Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!wupost!uwm.edu!ogicse!psgrain!hippo!evp

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!wupost!uwm.edu!ogicse!psgrain!hippo!evp
From: evp@oliver.sun.ac.za (Etienne van der Poel)
Newsgroups: comp.graphics.avs
Subject: AVS does not close input file?
Message-ID: <1992Aug30.153547.15303@hippo.ru.ac.za>
Date: 30 Aug 92 15:35:47 GMT
Article-I.D.: hippo.1992Aug30.153547.15303
Sender: news@hippo.ru.ac.za
Organization: Rhodes University, Grahamstown, South Africa
Lines: 48
X-Newsreader: Tin 1.1 PL5