[Nickle] files not auto-closed on exit?
Jamey Sharp
nickle@nickle.org
Tue, 22 Apr 2003 14:28:06 -0700
--JbaLeU65fPBt7QWN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
I have some nickle code that uses fprintf to write to a bunch of
different files, but at first I got only zero-length files. Bart glanced
at it and suggested I explicitly close the files, at which point I got
the output I expected. Bart says this is a bug.
(Hopefully) relevant excerpts:
import File;
void gen_test(file in, file out) {
/* ... stuff happens here, then: */
for (int i =3D 0; i < 7; i++) {
nut x =3D spin_nut(nuts[i], spin[i]);
fprintf(in, "%d", x[0]);
for (int j =3D 1; j < 6; j++)
fprintf(in, " %d", x[j]);
fprintf(in, "\n");=20
}
close(in); /* added */
for (int i =3D 0; i < 7; i++)=20
fprintf(out, "%d %d\n", i + 1, spin[i] + 1);
close(out); /* added */
}
for (int i =3D 1; i < 50; i++)
gen_test(open(sprintf("In/%d", i), "w"), open(sprintf("Out/%d", i), "w"=
));
exit(0);
--=20
Jamey Sharp <jamey@minilop.net> - http://minilop.net/
--JbaLeU65fPBt7QWN
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+pbPmNgAXSpyH6VcRAhW5AJ0T4RDovnuHtOrtmNivVqMwlkDvxgCdEGe0
RSiYB3dsZgehFLmiUj4KI5w=
=Pg9t
-----END PGP SIGNATURE-----
--JbaLeU65fPBt7QWN--