2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 University of Virginia,
4 ** Massachusetts Institute of Technology
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** General Public License for more details.
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
20 ** For information on splint: info@splint.org
21 ** To report a bug: splint-bug@splint.org
22 ** For more information: http://www.splint.org
27 ** replaces filenamemap.c
28 ** based (loosely) on typeTable.c
30 ** entries in the fileTable are:
32 ** name - name of the file
33 ** type - kind of file (a temp file to be deleted?)
34 ** link - derived from this file
39 * - Added conditional stuff (macros OS2 and MSDOS) to make names of temporary
40 * files under Windows or OS/2 not larger than 8+3 characters to avoid
41 * trouble with FAT file systems or Novell Netware volumes.
42 * - Added include of new header file portab.h containing OS dependent stuff.
43 * - Changed occurance of '/' as path delimiter to a macro.
44 * - Added conditional stuff (#define and #include) for IBM's compiler.
47 # include <sys/types.h>
48 # include <sys/stat.h>
50 # include "splintMacros.nf"
59 # if defined(__IBMC__) && defined(OS2)
62 # define getpid _getpid
63 # define S_IRUSR S_IREAD
64 # define S_IWUSR S_IWRITE
65 # define S_IXUSR S_IEXEC
72 fileTable_addOpen (fileTable p_ft, /*@observer@*/ FILE *p_f, /*@only@*/ cstring p_fname)
75 static bool fileTable_inRange (fileTable ft, fileId fid) /*@*/
77 return (fileTable_isDefined (ft) && (fid >= 0) && (fid < ft->nentries));
80 static fileId fileTable_internAddEntry (fileTable p_ft, /*@only@*/ ftentry p_e)
82 static /*@only@*/ cstring makeTempName (cstring p_dir, cstring p_pre, cstring p_suf);
84 static /*@only@*/ cstring
85 fileType_unparse (fileType ft)
89 case FILE_NORMAL: return cstring_makeLiteral ("normal");
90 case FILE_NODELETE: return cstring_makeLiteral ("normal");
91 case FILE_LSLTEMP: return cstring_makeLiteral ("ltemp");
92 case FILE_HEADER: return cstring_makeLiteral ("header");
93 case FILE_XH: return cstring_makeLiteral ("xh");
94 case FILE_MACROS: return cstring_makeLiteral ("macros");
95 case FILE_METASTATE: return cstring_makeLiteral ("metastate");
102 fileTable_getIndex (fileTable ft, cstring s)
106 if (ft == NULL) return NOT_FOUND;
107 abspath = osd_absolutePath (cstring_undefined, s);
109 if (context_getFlag (FLG_CASEINSENSITIVEFILENAMES))
111 abspath = cstring_downcase (abspath);
114 DPRINTF (("Absolute path: %s: %s", s, abspath));
115 res = cstringTable_lookup (ft->htable, abspath);
116 cstring_free (abspath);
120 static cstring ftentry_unparse (fileTable ft, ftentry fte)
122 if (fileId_isValid (fte->fder))
124 llassert (fileTable_isDefined (ft));
126 return message ("%s %q %d (%s)",
128 fileType_unparse (fte->ftype),
130 ft->elements[fte->fder]->fname);
134 return message ("%s %q", fte->fname,
135 fileType_unparse (fte->ftype));
140 fileTable_unparse (fileTable ft)
142 cstring s = cstring_undefined;
145 if (fileTable_isUndefined (ft))
147 return (cstring_makeLiteral ("<fileTable undefined>"));
150 for (i = 0; i < ft->nentries; i++)
152 s = message ("%s\n[%d] %q", s, i, ftentry_unparse (ft, ft->elements[i]));
158 void fileTable_printTemps (fileTable ft)
160 if (fileTable_isDefined (ft))
164 for (i = 0; i < ft->nentries; i++)
166 if (ft->elements[i]->ftemp)
168 if (fileId_isValid (ft->elements[i]->fder))
170 fprintf (stderr, " %s:1\n\t%s:1\n",
171 cstring_toCharsSafe (ft->elements[ft->elements[i]->fder]->fname),
172 cstring_toCharsSafe (ft->elements[i]->fname));
176 fprintf (stderr, "[no file]\n\t%s:1\n",
177 cstring_toCharsSafe (ft->elements[i]->fname));
185 ** loads in fileTable from fileTable_dump
188 static /*@notnull@*/ ftentry
189 ftentry_create (/*@keep@*/ cstring tn, bool temp, fileType typ, fileId der)
191 ftentry t = (ftentry) dmalloc (sizeof (*t));
193 if (cstring_isUndefined (tn))
195 llbug (cstring_makeLiteral ("Undefined filename!"));
199 t->basename = cstring_undefined;
204 /* Don't set these until the basename is needed. */
212 ftentry_free (/*@only@*/ ftentry t)
214 cstring_free (t->fname);
215 cstring_free (t->basename);
219 /*@only@*/ /*@notnull@*/ fileTable
222 fileTable ft = (fileTable) dmalloc (sizeof (*ft));
225 ft->nspace = FTBASESIZE;
226 ft->elements = (ftentry *) dmalloc (FTBASESIZE * sizeof (*ft->elements));
227 ft->htable = cstringTable_create (FTHASHSIZE);
230 ft->nopenspace = FTBASESIZE;
231 ft->openelements = (foentry *) dmalloc (FTBASESIZE * sizeof (*ft->openelements));
238 fileTable_grow (fileTable ft)
243 llassert (fileTable_isDefined (ft));
245 ft->nspace = FTBASESIZE;
247 newent = (ftentry *) dmalloc ((ft->nentries + ft->nspace) * sizeof (*newent));
249 for (i = 0; i < ft->nentries; i++)
251 newent[i] = ft->elements[i];
254 sfree (ft->elements);
255 ft->elements = newent;
259 fileTable_growOpen (fileTable ft)
264 llassert (fileTable_isDefined (ft));
266 ft->nopenspace = FTBASESIZE;
268 newent = (foentry *) dmalloc ((ft->nopen + ft->nopenspace) * sizeof (*newent));
270 for (i = 0; i < ft->nopen; i++)
272 newent[i] = ft->openelements[i];
275 sfree (ft->openelements);
276 ft->openelements = newent;
280 fileTable_internAddEntry (fileTable ft, /*@only@*/ ftentry e)
282 llassert (fileTable_isDefined (ft));
289 DPRINTF (("Adding: %s", e->fname));
291 if (context_getFlag (FLG_CASEINSENSITIVEFILENAMES))
293 cstring sd = cstring_downcase (e->fname);
294 cstringTable_insert (ft->htable, sd, ft->nentries);
298 cstringTable_insert (ft->htable, cstring_copy (e->fname), ft->nentries);
302 Before, there was no cstring_copy above, and e->fname was free'd in the if branch.
303 Splint should have caught this, and produced a warning for this assignment.
306 ft->elements[ft->nentries] = e;
309 return (ft->nentries - 1);
312 void fileTable_noDelete (fileTable ft, cstring name)
314 fileId fid = fileTable_lookup (ft, name);
316 if (fileId_isValid (fid))
318 llassert (fileTable_isDefined (ft));
319 ft->elements[fid]->ftype = FILE_NODELETE;
323 DPRINTF (("Invalid no delete: %s", name));
328 fileTable_addFilePrim (fileTable ft, /*@temp@*/ cstring name,
329 bool temp, fileType typ, fileId der)
332 cstring absname = osd_absolutePath (NULL, name);
333 int tindex = fileTable_getIndex (ft, absname);
335 llassert (ft != fileTable_undefined);
337 if (tindex != NOT_FOUND)
339 llcontbug (message ("fileTable_addFilePrim: duplicate entry: %q", absname));
344 ftentry e = ftentry_create (absname, temp, typ, der);
346 if (der == fileId_invalid)
348 llassert (cstring_isUndefined (e->basename));
350 e->basename = fileLib_removePathFree (fileLib_removeAnyExtension (absname));
351 e->fsystem = context_isSystemDir (absname);
354 ** evans 2002-03-15: change suggested by Jim Zelenka
355 ** support relative paths for system directories
360 e->fsystem = context_isSystemDir (name);
363 e->fspecial = context_isSpecialFile (absname);
367 cstring srcname = cstring_concatFree1 (fileLib_removeAnyExtension (absname),
369 fileId fid = fileTable_lookup (ft, srcname);
370 cstring_free (srcname);
372 if (fileId_isValid (fid))
374 fileId derid = ft->elements[fid]->fder;
376 ft->elements[fid]->fspecial = TRUE;
378 if (fileId_isValid (derid))
380 ft->elements[derid]->fspecial = TRUE;
387 ftentry de = ft->elements[der];
389 llassert (cstring_isUndefined (e->basename));
390 e->basename = cstring_copy (de->basename);
391 e->fsystem = de->fsystem;
392 e->fspecial = de->fspecial;
395 return (fileTable_internAddEntry (ft, e));
400 fileTable_addFile (fileTable ft, cstring name)
402 return (fileTable_addFilePrim (ft, name, FALSE, FILE_NORMAL, fileId_invalid));
406 fileTable_addFileOnly (fileTable ft, /*@only@*/ cstring name)
408 fileId res = fileTable_addFilePrim (ft, name, FALSE, FILE_NORMAL, fileId_invalid);
414 fileTable_addHeaderFile (fileTable ft, cstring name)
417 res = fileTable_addFilePrim (ft, name, FALSE, FILE_HEADER, fileId_invalid);
423 fileTable_addStreamFile (fileTable ft, FILE *fstream, cstring name)
425 fileTable_addOpen (ft, fstream, cstring_copy (name));
429 fileTable_isHeader (fileTable ft, fileId fid)
431 if (fileId_isInvalid (fid))
436 llassert (fileTable_isDefined (ft) && fileTable_inRange (ft, fid));
437 return (ft->elements[fid]->ftype == FILE_HEADER);
441 fileTable_isSystemFile (fileTable ft, fileId fid)
443 if (fileId_isInvalid (fid))
448 llassert (fileTable_isDefined (ft) && fileTable_inRange (ft, fid));
449 return (ft->elements[fid]->fsystem);
453 fileTable_isXHFile (fileTable ft, fileId fid)
455 if (fileId_isInvalid (fid))
460 if (!(fileTable_isDefined (ft) && fileTable_inRange (ft, fid)))
462 llcontbug (message ("Bad file table or id: %s %d", bool_unparse (fileTable_isDefined (ft)), fid));
467 return (ft->elements[fid]->ftype == FILE_XH);
472 fileTable_isSpecialFile (fileTable ft, fileId fid)
474 if (fileId_isInvalid (fid))
479 llassert (fileTable_isDefined (ft) && fileTable_inRange (ft, fid));
480 return (ft->elements[fid]->fspecial);
484 fileTable_addLibraryFile (fileTable ft, cstring name)
486 return (fileTable_addFilePrim (ft, name, FALSE, FILE_HEADER, fileId_invalid));
490 fileTable_addXHFile (fileTable ft, cstring name)
492 return (fileTable_addFilePrim (ft, name, FALSE, FILE_XH, fileId_invalid));
496 fileTable_addImportFile (fileTable ft, cstring name)
498 return (fileTable_addFilePrim (ft, name, FALSE, FILE_HEADER, fileId_invalid));
502 fileTable_addLCLFile (fileTable ft, cstring name)
504 return (fileTable_addFilePrim (ft, name, FALSE, FILE_HEADER, fileId_invalid));
507 static int tmpcounter = 0;
510 fileTable_addMacrosFile (fileTable ft)
513 makeTempName (context_tmpdir (), cstring_makeLiteralTemp ("lmx"),
514 cstring_makeLiteralTemp (".llm"));
515 fileId res = fileTable_addFilePrim (ft, newname, TRUE, FILE_MACROS, fileId_invalid);
516 cstring_free (newname);
521 fileTable_addMetastateFile (fileTable ft, cstring name)
523 return (fileTable_addFilePrim (ft, name, FALSE, FILE_METASTATE, fileId_invalid));
527 fileTable_addCTempFile (fileTable ft, fileId fid)
530 makeTempName (context_tmpdir (), cstring_makeLiteralTemp ("cl"),
534 DPRINTF (("tmp dir: %s", context_tmpdir ()));
535 DPRINTF (("new name: %s", newname));
537 llassert (fileTable_isDefined (ft));
539 if (!fileId_isValid (ft->elements[fid]->fder))
541 if (fileTable_isXHFile (ft, fid))
543 res = fileTable_addFilePrim (ft, newname, TRUE, FILE_XH, fid);
547 res = fileTable_addFilePrim (ft, newname, TRUE, FILE_NORMAL, fid);
552 if (fileTable_isXHFile (ft, fid))
554 res = fileTable_addFilePrim (ft, newname, TRUE, FILE_XH,
555 ft->elements[fid]->fder);
559 res = fileTable_addFilePrim (ft, newname, TRUE, FILE_NORMAL,
560 ft->elements[fid]->fder);
564 DPRINTF (("Added file: %s", fileTable_fileName (res)));
565 cstring_free (newname);
570 fileTable_addltemp (fileTable ft)
572 cstring newname = makeTempName (context_tmpdir (),
573 cstring_makeLiteralTemp ("ls"),
574 cstring_makeLiteralTemp (".lsl"));
577 if (cstring_hasNonAlphaNumBar (newname))
579 char *lastpath = (char *)NULL;
585 ("Operating system generates tmp filename containing invalid charater: %s",
587 lldiagmsg (cstring_makeLiteral
588 ("Try cleaning up the tmp directory. Attempting to continue."));
592 llassert (cstring_isDefined (newname));
593 lastpath = strrchr (newname, CONNECTCHAR); /* get the directory */
594 llassert (lastpath != NULL);
597 newname = message ("%q%hlsl%d.lsl",
601 /*@noaccess cstring@*/
606 ** this is kind of yucky...need to make the result of cstring_fromChars
607 ** refer to the same storage as its argument. Of course, this loses,
608 ** since cstring is abstract. Should make it an only?
611 ret = fileTable_addFilePrim (ft, newname, TRUE, FILE_LSLTEMP, fileId_invalid);
612 cstring_free (newname);
617 fileTable_exists (fileTable ft, cstring s)
619 int tindex = fileTable_getIndex (ft, s);
621 if (tindex == NOT_FOUND)
623 DPRINTF (("Not found: %s", s));
633 fileTable_lookup (fileTable ft, cstring s)
635 int tindex = fileTable_getIndex (ft, s);
637 if (tindex == NOT_FOUND)
639 return fileId_invalid;
648 ** This is pretty awkward --- when we find the real path of
649 ** a .xh file, we may need to change the recorded name. [Sigh]
653 fileTable_setFilePath (fileTable ft, fileId fid, cstring path)
655 llassert (fileId_isValid (fid));
656 llassert (fileTable_isDefined (ft));
657 /* Need to put new string in hash table */
658 cstringTable_insert (ft->htable, cstring_copy (path), fid);
659 ft->elements[fid]->fname = cstring_copy (path);
663 fileTable_lookupBase (fileTable ft, cstring base)
667 if (context_getFlag (FLG_CASEINSENSITIVEFILENAMES))
669 cstring dbase = cstring_downcase (base);
670 tindex = fileTable_getIndex (ft, dbase);
671 cstring_free (dbase);
675 tindex = fileTable_getIndex (ft, base);
678 if (tindex == NOT_FOUND)
680 return fileId_invalid;
686 llassert (fileTable_isDefined (ft));
688 der = ft->elements[tindex]->fder;
690 if (!fileId_isValid (der))
700 fileTable_getName (fileTable ft, fileId fid)
702 if (!fileId_isValid (fid))
705 (message ("fileTable_getName: called with invalid type id: %d", fid));
706 return cstring_makeLiteralTemp ("<invalid>");
709 llassert (fileTable_isDefined (ft));
710 return (ft->elements[fid]->fname);
714 fileTable_getRootName (fileTable ft, fileId fid)
718 if (!fileId_isValid (fid))
720 llcontbug (message ("fileTable_getName: called with invalid id: %d", fid));
721 return cstring_makeLiteralTemp ("<invalid>");
724 if (!fileTable_isDefined (ft))
726 return cstring_makeLiteralTemp ("<no file table>");
729 fder = ft->elements[fid]->fder;
731 if (fileId_isValid (fder))
733 return (ft->elements[fder]->fname);
737 return (ft->elements[fid]->fname);
742 fileTable_getNameBase (fileTable ft, fileId fid)
744 if (!fileId_isValid (fid))
746 llcontbug (message ("fileTable_getName: called with invalid id: %d", fid));
747 return cstring_makeLiteralTemp ("<invalid>");
750 if (!fileTable_isDefined (ft))
752 return cstring_makeLiteralTemp ("<no file table>");
755 return (ft->elements[fid]->basename);
759 fileTable_sameBase (fileTable ft, fileId f1, fileId f2)
763 if (!fileId_isValid (f1))
768 if (!fileId_isValid (f2))
773 llassert (fileTable_isDefined (ft));
780 fd1 = ft->elements[f1]->fder;
782 if (!fileId_isValid (fd1))
787 fd2 = ft->elements[f2]->fder;
790 if (!fileId_isValid (fd2))
799 fileTable_cleanup (fileTable ft)
805 llassert (fileTable_isDefined (ft));
807 msg = ((ft->nentries > 40) && context_getFlag (FLG_SHOWSCAN));
808 skip = ft->nentries / 10;
812 (void) fflush (g_warningstream);
813 displayScanOpen (cstring_makeLiteral ("cleaning"));
816 for (i = 0; i < ft->nentries; i++)
818 ftentry fe = ft->elements[i];
822 /* let's be real careful now, hon! */
825 ** Make sure it is really a derived file
829 if (fe->ftype == FILE_LSLTEMP || fe->ftype == FILE_NODELETE)
831 ; /* already removed */
833 else if (fileId_isValid (fe->fder))
835 /* this should use close (fd) also... */
836 (void) osd_unlink (fe->fname);
838 else if (fe->ftype == FILE_MACROS)
840 (void) osd_unlink (fe->fname);
844 llbug (message ("Temporary file is not derivative: %s "
845 "(not deleted)", fe->fname));
853 if (msg && ((i % skip) == 0))
855 displayScanContinue (cstring_makeLiteral (i == 0 ? " " : "."));
866 fileTable_free (/*@only@*/ fileTable f)
870 if (f == (fileTable)NULL)
875 while ( i < f->nentries )
877 ftentry_free (f->elements[i]);
881 cstringTable_free (f->htable);
883 sfree (f->openelements); /*!! why didn't splint report this? */
888 ** unique temp filename are constructed from <dir><pre><pid><msg>.<suf>
889 ** requires: <dir> must end in '/'
892 static void nextMsg (char *msg)
922 llassertprint (FALSE, ("nextMsg: out of unique names!!!"));
930 static /*@only@*/ cstring makeTempName (cstring dir, cstring pre, cstring suf)
933 static /*@owned@*/ char *msg = NULL;
934 static /*@only@*/ cstring pidname = NULL;
938 llassert (cstring_length (pre) <= 3);
941 ** We limit the temp name to 8 characters:
949 msg = mstring_copy ("AAA"); /* there are 26^3 temp names */
954 /*@+matchanyintegral@*/
956 /*@=matchanyintegral@*/
959 if (cstring_isUndefined (pidname))
961 pidname = message ("%d", pid % 100);
964 maxlen = (cstring_length (dir) + cstring_length (pre) + mstring_length (msg)
965 + cstring_length (pidname) + cstring_length (suf) + 2);
967 DPRINTF (("Dir: %s / %s / %s / %s / %s",
968 dir, pre, pidname, msg, suf));
970 smsg = message ("%s%s%s%s%s", dir, pre, pidname, cstring_fromChars (msg), suf);
973 DPRINTF (("Trying: %s", smsg));
975 while (osd_fileExists (smsg))
978 smsg = message ("%s%s%s%s%s", dir, pre, pidname, cstring_fromChars (msg), suf);
986 foentry_create (/*@exposed@*/ FILE *f, /*@only@*/ cstring fname)
988 foentry t = (foentry) dmalloc (sizeof (*t));
995 foentry_free (/*@only@*/ foentry foe)
997 cstring_free (foe->fname);
1002 fileTable_addOpen (fileTable ft, /*@observer@*/ FILE *f, /*@only@*/ cstring fname)
1004 llassert (fileTable_isDefined (ft));
1006 if (ft->nopenspace <= 0)
1008 fileTable_growOpen (ft);
1012 ft->openelements[ft->nopen] = foentry_create (f, fname);
1016 FILE *fileTable_createFile (fileTable ft, cstring fname)
1019 int fdesc = _open (cstring_toCharsSafe (fname),
1020 O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,
1021 _S_IWRITE | S_IREAD);
1023 int fdesc = open (cstring_toCharsSafe (fname),
1024 O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,
1030 osd_setTempError ();
1031 llfatalerror (message ("Temporary file for "
1032 "pre-processor output already exists. Trying to "
1036 /*@notreached@*/ return NULL;
1040 FILE *res = fdopen (fdesc, "w");
1044 fileTable_addOpen (ft, res, cstring_copy (fname));
1045 DPRINTF (("Opening file: %s / %p", fname, res));
1049 DPRINTF (("Error opening: %s", fname));
1056 FILE *fileTable_createMacrosFile (fileTable ft, cstring fname)
1059 int fdesc = _open (cstring_toCharsSafe (fname),
1060 O_RDWR | O_CREAT | O_TRUNC | O_EXCL,
1061 _S_IREAD | _S_IWRITE);
1063 int fdesc = open (cstring_toCharsSafe (fname),
1064 O_RDWR | O_CREAT | O_TRUNC | O_EXCL,
1070 osd_setTempError ();
1071 llfatalerror (message ("Temporary file for "
1072 "pre-processor output already exists. Trying to "
1076 /*@notreached@*/ return NULL;
1080 FILE *res = fdopen (fdesc, "w+");
1084 fileTable_addOpen (ft, res, cstring_copy (fname));
1085 DPRINTF (("Opening file: %s / %p", fname, res));
1089 DPRINTF (("Error opening: %s", fname));
1096 FILE *fileTable_openReadFile (fileTable ft, cstring fname)
1098 FILE *res = fopen (cstring_toCharsSafe (fname), "r");
1102 fileTable_addOpen (ft, res, cstring_copy (fname));
1103 DPRINTF (("Opening read file: %s / %p", fname, res));
1107 DPRINTF (("Cannot open read file: %s", fname));
1114 ** Allows overwriting
1117 FILE *fileTable_openWriteFile (fileTable ft, cstring fname)
1119 FILE *res = fopen (cstring_toCharsSafe (fname), "w");
1122 fileTable_addOpen (ft, res, cstring_copy (fname));
1123 DPRINTF (("Opening file: %s / %p", fname, res));
1129 FILE *fileTable_openWriteUpdateFile (fileTable ft, cstring fname)
1131 FILE *res = fopen (cstring_toCharsSafe (fname), "w+");
1134 fileTable_addOpen (ft, res, cstring_copy (fname));
1135 DPRINTF (("Opening file: %s / %p", fname, res));
1141 bool fileTable_closeFile (fileTable ft, FILE *f)
1143 bool foundit = FALSE;
1146 llassert (fileTable_isDefined (ft));
1148 DPRINTF (("Closing file: %p", f));
1150 for (i = 0; i < ft->nopen; i++)
1152 if (ft->openelements[i]->f == f)
1154 DPRINTF (("Closing file: %p = %s", f, ft->openelements[i]->fname));
1156 if (i == ft->nopen - 1)
1158 foentry_free (ft->openelements[i]);
1159 ft->openelements[i] = NULL;
1163 foentry_free (ft->openelements[i]);
1164 ft->openelements[i] = ft->openelements[ft->nopen - 1];
1165 ft->openelements[ft->nopen - 1] = NULL;
1176 return (fclose (f) == 0);
1179 void fileTable_closeAll (fileTable ft)
1183 llassert (fileTable_isDefined (ft));
1185 for (i = 0; i < ft->nopen; i++)
1188 lldiagmsg (message ("Unclosed file at exit: %s", ft->openelements[i]->fname));
1191 if (ft->openelements[i]->f != NULL)
1193 (void) fclose (ft->openelements[i]->f); /* No check - cleaning up after errors */
1196 ft->openelements[i]->f = NULL;
1197 foentry_free (ft->openelements[i]);
1198 ft->openelements[i] = NULL;
1201 ft->nopenspace += ft->nopen;