[MLton-commit] r6261

Vesa Karvonen vesak at mlton.org
Thu Dec 13 05:21:32 PST 2007


Fixed bug in ImperativeIOExtra.canInput.

The canInput implementation did not distinguish between readArrNB
returning NONE (meaning: eos not seen, any read will block) and SOME 0
(meaning: eos seen and at eos).

----------------------------------------------------------------------

U   mlton/trunk/basis-library/io/imperative-io.fun
U   mlton/trunk/doc/changelog

----------------------------------------------------------------------

Modified: mlton/trunk/basis-library/io/imperative-io.fun
===================================================================
--- mlton/trunk/basis-library/io/imperative-io.fun	2007-12-12 06:53:12 UTC (rev 6260)
+++ mlton/trunk/basis-library/io/imperative-io.fun	2007-12-13 13:21:31 UTC (rev 6261)
@@ -541,23 +541,27 @@
                    (* 0 = !first *)
                    fun loop read =
                       if read = size
-                         then read
+                         then {read = read, eos = false}
                       else
                          let
                             val slice = AS.slice (buf, read, NONE)
                             val i = readArrNB slice
                          in
                             case i of
-                               NONE => read
+                               NONE => {read = read, eos = false}
                              | SOME i =>
-                                  if 0 = i then read else loop (read + i)
+                                  if 0 = i
+                                     then {read = read, eos = true}
+                                  else loop (read + i)
                          end
-                   val read = loop read
+                   val {read, eos} = loop read
                    val _ = last := read
                 in
-                   SOME (if read > 0
-                            then Int.min (n, read)
-                         else (state := Open {eos = true}; 0))
+                   if read > 0
+                      then SOME (Int.min (n, read))
+                   else if eos
+                      then (state := Open {eos = true}; SOME 0)
+                   else NONE
                 end)
        | Stream s => SIO.canInput (s, n)
 

Modified: mlton/trunk/doc/changelog
===================================================================
--- mlton/trunk/doc/changelog	2007-12-12 06:53:12 UTC (rev 6260)
+++ mlton/trunk/doc/changelog	2007-12-13 13:21:31 UTC (rev 6261)
@@ -1,5 +1,9 @@
 Here are the changes from version 20070826 to version YYYYMMDD.
 
+* 2007-12-13
+   - Fixed bug in ImperativeIOExtra.canInput (TextIO.canInput).
+     Thanks to Ville Laurikari for the bug report.
+
 * 2007-12-07
    - Fixed bug in algebraic simplification of real primitives.
      Real.<= (x, x) is false when x is NaN.




More information about the MLton-commit mailing list