diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 4 | ||||
-rw-r--r-- | src/algebra/net.spad.pamphlet | 18 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 3fbd1464..c025a12f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2008-10-01 Gabriel Dos Reis <gdr@cs.tamu.edu> + * algebra/net.spad.pamphlet (InputBinaryFile): Tidy. + +2008-10-01 Gabriel Dos Reis <gdr@cs.tamu.edu> + * algebra/array2.spad.pamphlet (TwoDimensionalArrayCategory): Tidy. * algebra/sregset.spad.pamphlet (SquareFreeRegularTriangularSet): Remove unused function decompose. diff --git a/src/algebra/net.spad.pamphlet b/src/algebra/net.spad.pamphlet index ef5f7cec..c44130e2 100644 --- a/src/algebra/net.spad.pamphlet +++ b/src/algebra/net.spad.pamphlet @@ -127,27 +127,31 @@ InputBinaryFile(): Public == Private where ++ inputBinaryFile(f) returns an input conduit obtained by ++ opening the file named by `f' as a binary file. eof?: % -> Boolean - ++ eof?(ifile) holds when end-of-file has been reached - ++ for the conduit file `ifile'. + ++ eof?(ifile) holds when the last read reached end of file. isOpen?: % -> Boolean ++ open?(ifile) holds if `ifile' is in open state. Private == add - Rep == Record(stream: SExpression, filename: FileName) + Rep == Record(stream: SExpression, filename: FileName, eof: Boolean) inputBinaryFile(f: FileName) == - per [openBinaryFile(f::String,input$IOMode)$Lisp,f] + per [openBinaryFile(f::String,input$IOMode)$Lisp,f,false] inputBinaryFile(f: String) == - per [openBinaryFile(f,input$IOMode)$Lisp,f::FileName] + per [openBinaryFile(f,input$IOMode)$Lisp,f::FileName,false] isOpen? ifile == not null? rep(ifile).stream readByteIfCan! ifile == - isOpen? ifile => readByteFromFile(rep(ifile).stream)$Lisp + isOpen? ifile => + b: SingleInteger := readByteFromFile(rep(ifile).stream)$Lisp + if b < 0@SingleInteger then + rep(ifile).eof := true + b error "file is not open" eof? ifile == - isOpen? ifile => readByteIfCan! ifile < 0@SingleInteger + isOpen? ifile => rep(ifile).eof error "file is not open" close! ifile == if isOpen? ifile then rep(ifile).stream := closeFile(rep(ifile).stream)$Lisp + rep(ifile).eof := true ifile coerce(ifile: %): OutputForm == rep(ifile).filename::OutputForm |