[MLton-commit] r5281

Matthew Fluet fluet at mlton.org
Tue Feb 20 12:44:46 PST 2007


Fix bug in PackReal<N>.toBytes, reported by Eric McCorkle.


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

U   mlton/trunk/basis-library/arrays-and-vectors/mono-vector.sig
U   mlton/trunk/basis-library/arrays-and-vectors/vector.sig
U   mlton/trunk/basis-library/arrays-and-vectors/vector.sml
U   mlton/trunk/basis-library/io/imperative-io.fun
U   mlton/trunk/basis-library/net/socket.sml
U   mlton/trunk/basis-library/posix/io.sml
U   mlton/trunk/basis-library/real/pack-real.sml
U   mlton/trunk/basis-library/real/real.sml
U   mlton/trunk/basis-library/text/string.sig
U   mlton/trunk/basis-library/util/CUtil.sml
U   mlton/trunk/doc/changelog

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

Modified: mlton/trunk/basis-library/arrays-and-vectors/mono-vector.sig
===================================================================
--- mlton/trunk/basis-library/arrays-and-vectors/mono-vector.sig	2007-02-20 20:21:15 UTC (rev 5280)
+++ mlton/trunk/basis-library/arrays-and-vectors/mono-vector.sig	2007-02-20 20:44:43 UTC (rev 5281)
@@ -31,11 +31,13 @@
 
       type array
 
+      val unsafeFromArray: array -> vector
+      val unsafeSub: vector * int -> elem
+
       val append: vector * vector -> vector
       val concatWith: vector -> vector list -> vector
       val duplicate: vector -> vector
       val fields: (elem -> bool) -> vector -> vector list
-      val fromArray: array -> vector
       val isPrefix: (elem * elem -> bool) -> vector -> vector -> bool
       val isSubvector: (elem * elem -> bool) -> vector -> vector -> bool
       val isSuffix: (elem * elem -> bool) -> vector -> vector -> bool
@@ -43,7 +45,6 @@
       val tokens: (elem -> bool) -> vector -> vector list
       val translate: (elem -> vector) -> vector -> vector
       val unfoldi: int * 'a * (int * 'a -> elem * 'a) -> vector * 'a
-      val unsafeSub: vector * int -> elem
       val vector: int * elem -> vector
    end
 

Modified: mlton/trunk/basis-library/arrays-and-vectors/vector.sig
===================================================================
--- mlton/trunk/basis-library/arrays-and-vectors/vector.sig	2007-02-20 20:21:15 UTC (rev 5280)
+++ mlton/trunk/basis-library/arrays-and-vectors/vector.sig	2007-02-20 20:44:43 UTC (rev 5281)
@@ -34,7 +34,7 @@
       include VECTOR
       structure VectorSlice: VECTOR_SLICE_EXTRA 
 
-      val fromArray: 'a array -> 'a vector
+      val unsafeFromArray: 'a array -> 'a vector
       val unsafeSub: 'a vector * int -> 'a
 
       (* Used to implement Substring/String functions *)

Modified: mlton/trunk/basis-library/arrays-and-vectors/vector.sml
===================================================================
--- mlton/trunk/basis-library/arrays-and-vectors/vector.sml	2007-02-20 20:21:15 UTC (rev 5280)
+++ mlton/trunk/basis-library/arrays-and-vectors/vector.sml	2007-02-20 20:44:43 UTC (rev 5281)
@@ -57,7 +57,7 @@
 
       val isSubvector = isSubsequence
 
-      val fromArray = Primitive.Vector.fromArray
+      val unsafeFromArray = Primitive.Vector.fromArray
 
       val vector = new
 

Modified: mlton/trunk/basis-library/io/imperative-io.fun
===================================================================
--- mlton/trunk/basis-library/io/imperative-io.fun	2007-02-20 20:21:15 UTC (rev 5280)
+++ mlton/trunk/basis-library/io/imperative-io.fun	2007-02-20 20:44:43 UTC (rev 5281)
@@ -16,7 +16,7 @@
       structure PrimIO: PRIM_IO
       structure Vector: sig 
                            include MONO_VECTOR
-                           val fromArray: Array.array -> vector
+                           val unsafeFromArray: Array.array -> vector
                         end
       structure VectorSlice: MONO_VECTOR_SLICE
       sharing type Array.array
@@ -396,7 +396,7 @@
                             val i = loop size
                          in
                             if i = n
-                               then V.fromArray inp
+                               then V.unsafeFromArray inp
                             else AS.vector (AS.slice (inp, 0, SOME i))
                          end)
                 | Stream s =>

Modified: mlton/trunk/basis-library/net/socket.sml
===================================================================
--- mlton/trunk/basis-library/net/socket.sml	2007-02-20 20:21:15 UTC (rev 5280)
+++ mlton/trunk/basis-library/net/socket.sml	2007-02-20 20:44:43 UTC (rev 5281)
@@ -589,7 +589,7 @@
 
 fun getVec (a, n, bytesRead) =
    if n = bytesRead
-      then Word8Vector.fromArray a
+      then Word8Vector.unsafeFromArray a
    else Word8ArraySlice.vector (Word8ArraySlice.slice (a, 0, SOME bytesRead))
 
 fun recvVec' (sock, n, in_flags) =

Modified: mlton/trunk/basis-library/posix/io.sml
===================================================================
--- mlton/trunk/basis-library/posix/io.sml	2007-02-20 20:21:15 UTC (rev 5280)
+++ mlton/trunk/basis-library/posix/io.sml	2007-02-20 20:44:43 UTC (rev 5281)
@@ -240,7 +240,7 @@
             in 
                fromVector
                (if n = bytesRead
-                   then Vector.fromArray buf
+                   then Vector.unsafeFromArray buf
                    else ArraySlice.vector (ArraySlice.slice (buf, 0, SOME bytesRead)))
             end
          fun writeArr (fd, sl): int =

Modified: mlton/trunk/basis-library/real/pack-real.sml
===================================================================
--- mlton/trunk/basis-library/real/pack-real.sml	2007-02-20 20:21:15 UTC (rev 5280)
+++ mlton/trunk/basis-library/real/pack-real.sml	2007-02-20 20:44:43 UTC (rev 5281)
@@ -49,13 +49,13 @@
       updA (a, i, r)
    end
 
-local
-   val a = Array.arrayUninit bytesPerElem
-in
-   fun toBytes (r: real): Word8Vector.vector =
+fun toBytes (r: real): Word8Vector.vector =
+   let
+      val a = Array.arrayUninit bytesPerElem
+   in
       (updA (a, 0, r)
-       ; Word8Vector.fromPoly (Vector.fromArray a))
-end
+       ; Word8Vector.fromPoly (Array.vector a))
+   end
 
 local
    fun make (sub, length, toPoly) (s, i) =

Modified: mlton/trunk/basis-library/real/real.sml
===================================================================
--- mlton/trunk/basis-library/real/real.sml	2007-02-20 20:21:15 UTC (rev 5280)
+++ mlton/trunk/basis-library/real/real.sml	2007-02-20 20:44:43 UTC (rev 5281)
@@ -338,7 +338,7 @@
                   val i = upd (i, #"E")
                   val i = CharVector.foldl (fn (c, i) => upd (i, c)) i exp
                   val _ = upd (i, #"\000")
-                  val x = Vector.fromArray a
+                  val x = Vector.unsafeFromArray a
                   val x = Prim.strto (NullString.fromString x)
                in
                   if sign

Modified: mlton/trunk/basis-library/text/string.sig
===================================================================
--- mlton/trunk/basis-library/text/string.sig	2007-02-20 20:21:15 UTC (rev 5280)
+++ mlton/trunk/basis-library/text/string.sig	2007-02-20 20:44:43 UTC (rev 5281)
@@ -46,7 +46,8 @@
       include STRING
       type array
       
-      val fromArray: array -> string
+      val unsafeFromArray: array -> string
+
       val new: int * char -> string
       val nullTerm: string -> string
       val tabulate: int * (int -> char) -> string

Modified: mlton/trunk/basis-library/util/CUtil.sml
===================================================================
--- mlton/trunk/basis-library/util/CUtil.sml	2007-02-20 20:21:15 UTC (rev 5280)
+++ mlton/trunk/basis-library/util/CUtil.sml	2007-02-20 20:44:43 UTC (rev 5281)
@@ -65,7 +65,7 @@
                toArrayOfLength (cs, sub, n)
 
             fun toStringOfLength (cs, n) =
-               String.fromArray 
+               String.unsafeFromArray 
                (CharArray.fromPoly (toCharArrayOfLength (cs, n)))
 
             fun toString cs = toStringOfLength (cs, length cs)

Modified: mlton/trunk/doc/changelog
===================================================================
--- mlton/trunk/doc/changelog	2007-02-20 20:21:15 UTC (rev 5280)
+++ mlton/trunk/doc/changelog	2007-02-20 20:44:43 UTC (rev 5281)
@@ -1,5 +1,9 @@
 Here are the changes since version 20051202.
 
+* 2007-02-20
+   - Fixed bug in PackReal<N>.toBytes.  Thanks to Eric McCorkle for the
+     bug report.
+
 * 2007-02-18
    - Added command line switch -profile-val, to profile the evaluation of
      val bindings; this is particularly useful with exception history for




More information about the MLton-commit mailing list