Skip to content

Commit

Permalink
set binary mode in file io
Browse files Browse the repository at this point in the history
  • Loading branch information
Haoqiang Fan committed Dec 29, 2016
1 parent b7375c3 commit 02ce70c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion UData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ applyBVal :: BValue -> BValue -> BResult
applyBVal (BFuncVal b) (BNumVal v) = applyBFunc b v
applyBVal (BFuncVal b) _ = BException ("cannot apply built-in function "++(showBFunc b)++" on non-numeric value")
applyBVal (BIntList args) (BNumVal (BInt v)) = BClean (BIntList (v:args))
applyBVal (BIntList args) _ = BException "cannot append non-integer number in IntList"
applyBVal (BIntList args) _ = BException "cannot append non-integer number to IntList"
applyBVal _ _ = BException "cannot use numeric value as function"

applyBFunc :: BFunc -> BNum -> BResult
Expand Down
2 changes: 1 addition & 1 deletion UEnvironment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ instance UEnv URealWorldEnv where
else if (any (not.isValidCharInt) filename) then
return ((-3),initfiles)
else
(openFile (map chr filename) (efOpenModes!!mode) >>=
(openBinaryFile (map chr filename) (efOpenModes!!mode) >>=
(\handle -> ( let (fno,files1) = flAddHandle handle initfiles in
return (fno,files1)
)))
Expand Down
6 changes: 6 additions & 0 deletions test.u
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
(import* str)
(import* io)
(run
(fin (open "2.bin" 0))
(c (getCharF fin))
(_ (putStrLn (itoa c)))
;(fout (open "2.bin" 1))
;(_ (putCharF fout 255))
;(_ (close fout))
;(line readLine)
;(_ (putStrLn line))
;(r (system "ls -l"))
Expand Down

0 comments on commit 02ce70c

Please sign in to comment.