1. HongboZhang
  2. ocaml

Commits

meyer  committed cb5325a

PR#5468: ocamlbuild should preserve order of parametric tags

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12909f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

  • Participants
  • Parent commits f7e3a46
  • Branches master

Comments (0)

Files changed (4)

File Changes

View file
 - PR#4994: ocaml-mode doesn't work with xemacs21
 - PR#5327: (Windows) Unix.select blocks if same socket listed in first and
   third arguments
+- PR#5468: ocamlbuild should preserve order of parametric tags
 - PR#5551: Avoid repeated lookups for missing cmi files
 - PR#5552: try to use camlp4.opt if it's possible
 - PR#5611: avoid clashes betwen .cmo files and output files during linking

File ocamlbuild/my_std.ml

View file
   let union a b =
     rev (rev_append_uniq (rev_append_uniq [] a) b)
 
+  let ordered_unique (type el) (lst : el list)  =
+    let module Set = Set.Make(struct
+      type t = el
+      let compare = Pervasives.compare
+      let print _ _ = ()
+    end)
+    in
+    let _, lst =
+      List.fold_left (fun (set,acc) el ->
+        if Set.mem el set
+        then set, acc
+        else Set.add el set, el :: acc) (Set.empty,[]) lst
+    in
+    List.rev lst
+
 end
 
 module String = struct

File ocamlbuild/param_tags.ml

View file
 (* Original author: Romain Bardou *)
 
 module StringSet = Set.Make(String)
-module SSOSet = Set.Make(struct
-  type t = string * string option
-  let compare = Pervasives.compare
-end)
 
 (* tag name -> tag action (string -> unit) *)
 let declared_tags = Hashtbl.create 17
 
-let acknowledged_tags = ref SSOSet.empty
+let acknowledged_tags = ref []
 
 let only_once f =
   let instances = ref StringSet.empty in
 
 let acknowledge tag =
   let tag = Lexers.tag_gen (Lexing.from_string tag) in
-  acknowledged_tags := SSOSet.add tag !acknowledged_tags
+  acknowledged_tags := tag :: !acknowledged_tags
+
 
 let really_acknowledge (name, param) =
   match param with
         List.iter (fun f -> f param) actions
 
 let init () =
-  SSOSet.iter really_acknowledge !acknowledged_tags
+  List.iter really_acknowledge (My_std.List.ordered_unique !acknowledged_tags)
 
 let make = Printf.sprintf "%s(%s)"

File ocamlbuild/signatures.mli

View file
   val print : (Format.formatter -> 'a -> 'b) -> Format.formatter -> 'a list -> unit
   val filter_opt : ('a -> 'b option) -> 'a list -> 'b list
   val union : 'a list -> 'a list -> 'a list
-
+  val ordered_unique : 'a list -> 'a list
   (* Original functions *)
   include module type of List
 end