diff --git a/doc/io.xml b/doc/io.xml index be66f7f5e..9a1acd273 100644 --- a/doc/io.xml +++ b/doc/io.xml @@ -138,7 +138,9 @@ gap> for i in [1 .. 10] do gap> IO_Close(file);; gap> file := DigraphFile(filename, "r");; gap> ReadDigraphs(file, 9); -]]> + +gap> IO_Close(file);; +]]> <#/GAPDoc> diff --git a/gap/io.gi b/gap/io.gi index 43417b5cf..933546dd5 100644 --- a/gap/io.gi +++ b/gap/io.gi @@ -1285,6 +1285,7 @@ function(func, name, delimiter, offset, ignore) fi; lines := IO_ReadLines(file); + IO_Close(file); edges := EmptyPlist(Length(lines)); nr := 0; diff --git a/tst/standard/io.tst b/tst/standard/io.tst index ab66b00d6..4f39d59a8 100644 --- a/tst/standard/io.tst +++ b/tst/standard/io.tst @@ -284,6 +284,7 @@ gap> filename := Concatenation(DIGRAPHS_Dir(), "/tst/out/helloworld.g6");; gap> f := DigraphFile(filename, "w");; gap> WriteDigraphs(f, List([1 .. 5], CompleteDigraph)); IO_OK +gap> IO_Close(f);; gap> f := DigraphFile(filename, "r");; gap> ReadDigraphs(f); [ , @@ -291,12 +292,14 @@ gap> ReadDigraphs(f); , , ] +gap> IO_Close(f);; gap> f := DigraphFile(filename, "a");; gap> WriteDigraphs(f, CycleDigraph(5)); Error, the argument must be a symmetric digraph with no loops or multiple \ edges, gap> WriteDigraphs(f, JohnsonDigraph(6, 3)); IO_OK +gap> IO_Close(f);; gap> f := DigraphFile(filename, "r");; gap> ReadDigraphs(f); [ , @@ -316,6 +319,7 @@ gap> NextIterator(it); gap> NextIterator(it); +gap> for x in it do od; gap> it := IteratorFromDigraphFile(newfilename, DigraphFromGraph6String); gap> NextIterator(it); @@ -342,12 +346,14 @@ gap> it := ShallowCopy(it); gap> NextIterator(it); +gap> for x in it do od; gap> IteratorFromDigraphFile(1, 2, 3); Error, there must be 1 or 2 arguments, gap> IteratorFromDigraphFile(1, 2); Error, the 1st argument must be a string, gap> IteratorFromDigraphFile("happy", "happy"); Error, the 2nd argument must be a function or fail, +gap> IO_Close(f);; gap> f := DigraphFile(Concatenation(DIGRAPHS_Dir(), "/data/test-1.d6"));; gap> IO_Close(f); true