--- smlnj-lib/Util/array-qsort.sml.orig	Mon Nov  5 11:08:23 2007
+++ smlnj-lib/Util/array-qsort.sml	Mon Nov  5 11:08:48 2007
@@ -15,8 +15,8 @@
 
     type 'a array = 'a A.array
 
-    val sub = Unsafe.Array.sub
-    val update = Unsafe.Array.update
+    val sub = Array.sub
+    val update = Array.update
 
     fun isort (array, start, n, cmp) = let
           fun item i = sub(array,i)
--- smlnj-lib/Util/graph-scc-fn.sml.orig	Mon Nov  5 10:53:00 2007
+++ smlnj-lib/Util/graph-scc-fn.sml	Mon Nov  5 10:53:10 2007
@@ -8,7 +8,7 @@
  * author: Matthias Blume
  *) 
 
-functor GraphSCCFn (Nd: ORD_KEY) :> GRAPH_SCC where Nd = Nd =
+functor GraphSCCFn (Nd: ORD_KEY) :> GRAPH_SCC where type Nd.ord_key = Nd.ord_key =
   struct
     structure Nd = Nd
 
--- smlnj-lib/Util/hash-string.sml.orig	Mon Nov  5 10:44:23 2007
+++ smlnj-lib/Util/hash-string.sml	Mon Nov  5 10:48:42 2007
@@ -26,7 +26,7 @@
   (* fun hashString s = CharVector.foldl hashChar 0w0 s *)
     local
       fun x + y = Word.toIntX (Word.+ (Word.fromInt x, Word.fromInt y))
-      val sub = Unsafe.CharVector.sub
+      val sub = CharVector.sub
       fun hash (s, i0, e) = let
 	    fun loop (h, i) = if i >= e
 		  then h
--- smlnj-lib/Util/real-order-stats.sml.orig	Mon Nov  5 11:14:23 2007
+++ smlnj-lib/Util/real-order-stats.sml	Mon Nov  5 11:14:43 2007
@@ -23,8 +23,8 @@
 
 end = struct
 
-    infix 8 $  val op $ = Unsafe.Array.sub
-    infix 3 <- fun (a, i) <- x = Unsafe.Array.update (a, i, x)
+    infix 8 $  val op $ = Array.sub
+    infix 3 <- fun (a, i) <- x = Array.update (a, i, x)
 
     (* initialize random number generator *)
     val rand = Random.rand (123, 73256)
--- smlnj-lib/Util/redblack-map-fn.sml.orig	Mon Nov  5 10:52:04 2007
+++ smlnj-lib/Util/redblack-map-fn.sml	Mon Nov  5 10:52:16 2007
@@ -20,7 +20,7 @@
  * its child will be a red leaf.
  *)
 
-functor RedBlackMapFn (K : ORD_KEY) :> ORD_MAP where Key = K =
+functor RedBlackMapFn (K : ORD_KEY) :> ORD_MAP where type Key.ord_key = K.ord_key =
   struct
 
     structure Key = K
--- smlnj-lib/Util/redblack-set-fn.sml.orig	Mon Nov  5 10:50:56 2007
+++ smlnj-lib/Util/redblack-set-fn.sml	Mon Nov  5 10:51:19 2007
@@ -20,7 +20,7 @@
  * its child will be a red leaf.
  *)
 
-functor RedBlackSetFn (K : ORD_KEY) :> ORD_SET where Key = K =
+functor RedBlackSetFn (K : ORD_KEY) :> ORD_SET where type Key.ord_key = K.ord_key =
   struct
 
     structure Key = K
--- smlnj-lib/Util/univariate-stats.sml.orig	Mon Nov  5 11:14:56 2007
+++ smlnj-lib/Util/univariate-stats.sml	Mon Nov  5 11:15:15 2007
@@ -44,8 +44,8 @@
 
 end = struct
 
-    infix 8 $  val op $ = Unsafe.Array.sub
-    infix 3 <- fun (a, i) <- x = Unsafe.Array.update (a, i, x)
+    infix 8 $  val op $ = Array.sub
+    infix 3 <- fun (a, i) <- x = Array.update (a, i, x)
 
     (* two kinds of "extra info" *)
     type light = unit		  (* nothing *)
--- smlnj-lib/HTML/html-elements-fn.sml.orig	Mon Nov  5 18:02:27 2007
+++ smlnj-lib/HTML/html-elements-fn.sml	Mon Nov  5 18:02:44 2007
@@ -144,7 +144,8 @@
    *   3) a string literal enclosed in ''
    *)
     fun scanAttrVal (ctx, attrName, ss) = let
-	  fun isNameChar (#"." | #"-") = true
+	  fun isNameChar #"." = true
+            | isNameChar #"-" = true
 	    | isNameChar c = (Char.isAlphaNum c)
 	  in
 	    case SS.getc ss
--- smlnj-lib/HTML/html-attrs-fn.sml.orig	Mon Nov  5 18:03:13 2007
+++ smlnj-lib/HTML/html-attrs-fn.sml	Mon Nov  5 18:04:51 2007
@@ -89,19 +89,24 @@
 		fun error () = (
 		      Err.badAttrVal ctx (attrName, attrValToString attrVal);
 		      NONE)
-		fun cvt (AT_IMPLICIT, IMPLICIT) = SOME IMPLICIT
-		  | cvt (AT_INSTANCE, IMPLICIT) = SOME(NAME attrName)
-		  | cvt (AT_TEXT, v) = SOME v
-		  | cvt (AT_NUMBER, v) = SOME v
-		  | cvt (AT_NAMES names, (NAME s | STRING s)) = (
+		fun atNames (names, s) = (
 		      case (List.find (eqName s) names)
 		       of NONE => error()
 			| (SOME name) => SOME(NAME name)
 		      (* end case *))
-		  | cvt (AT_IMPLICIT, (NAME s | STRING s)) =
+		fun atImplicit (s) = 
 		      if (s = attrName)
 			then SOME IMPLICIT
 			else error()
+
+		fun cvt (AT_IMPLICIT, IMPLICIT) = SOME IMPLICIT
+		  | cvt (AT_INSTANCE, IMPLICIT) = SOME(NAME attrName)
+		  | cvt (AT_TEXT, v) = SOME v
+		  | cvt (AT_NUMBER, v) = SOME v
+		  | cvt (AT_NAMES names, NAME s) = atNames (names, s)
+		  | cvt (AT_NAMES names, STRING s) = atNames (names, s)
+		  | cvt (AT_IMPLICIT, NAME s) = atImplicit (s)
+		  | cvt (AT_IMPLICIT, STRING s) = atImplicit (s)
 		  | cvt _ = error()
 		in
 		  case (HTbl.find attrTbl attrName)
@@ -138,7 +143,8 @@
 	  val getFn = bindFindAttr (attrMap, attr)
 	  fun get attrVec = (case (getFn attrVec)
 		 of NONE => NONE
-		  | (SOME((STRING s) | (NAME s))) => SOME s
+		  | SOME (STRING s) => SOME s
+		  | SOME (NAME s) => SOME s
 		  | _ => (
 		      Err.missingAttrVal (getContext attrVec) attr;
 		      NONE)
@@ -162,31 +168,41 @@
 	  end
     fun getNUMBER (attrMap, attr) = let
 	  val getFn = bindFindAttr (attrMap, attr)
-	  fun get attrVec = (case (getFn attrVec)
+	  fun get attrVec = let
+	  fun doitStringName s = (case (Int.fromString s)
+		 of NONE =>  (
+		      Err.badAttrVal (getContext attrVec) (attr, s);
+		      NONE)
+		  | someN => someN
+		(* end case *))
+          in 
+             (case (getFn attrVec)
 		 of NONE => NONE
-		  | (SOME((STRING s) | (NAME s))) => (case (Int.fromString s)
-		       of NONE =>  (
-			    Err.badAttrVal (getContext attrVec) (attr, s);
-			    NONE)
-			| someN => someN
-		      (* end case *))
+		  | SOME (STRING s) => doitStringName s
+		  | SOME (NAME s) => doitStringName s
 		  | SOME IMPLICIT => raise Fail "getNUMBER: IMPLICIT unexpected"
 		(* end case *))
+          end
 	  in
 	    get
 	  end
     fun getChar (attrMap, attr) = let
 	  val getFn = bindFindAttr (attrMap, attr)
-	  fun get attrVec = (case (getFn attrVec)
-		 of NONE => NONE
-		  | (SOME((STRING s) | (NAME s))) =>
-		      if (size s = 1) then SOME(String.sub(s, 0))
+	  fun get attrVec = let 
+	  fun doitStringName s =
+		if (size s = 1) then SOME(String.sub(s, 0))
 (** NOTE: we should probably accept &#xx; as a character value **)
-			else  (
-			Err.badAttrVal (getContext attrVec) (attr, s);
-			NONE)
+		  else  (
+		  Err.badAttrVal (getContext attrVec) (attr, s);
+		  NONE)
+          in 
+             (case (getFn attrVec)
+		 of NONE => NONE
+		  | SOME (STRING s) => doitStringName s
+		  | SOME (NAME s) => doitStringName s
 		  | SOME IMPLICIT => raise Fail "getChar: IMPLICIT unexpected"
 		(* end case *))
+	  end
 	  in
 	    get
 	  end
