Coccinelle release-1.0.0-rc11
[bpt/coccinelle.git] / globals / iteration.ml
index be5fd30..5d282c7 100644 (file)
@@ -1,3 +1,29 @@
+(*
+ * Copyright 2012, INRIA
+ * Julia Lawall, Gilles Muller
+ * Copyright 2010-2011, INRIA, University of Copenhagen
+ * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
+ * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
+ * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
+ * This file is part of Coccinelle.
+ *
+ * Coccinelle is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, according to version 2 of the License.
+ *
+ * Coccinelle is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Coccinelle.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The authors reserve the right to distribute this or future versions of
+ * Coccinelle under other licenses.
+ *)
+
+
 type init_info = (string (* language *) * string (* rule name *)) *
       string list (* defined virtual rules *)
 
@@ -24,7 +50,14 @@ let add_pending_instance (files,a,b) =
       pending_instances_dir := (!base_file_list,a,b) :: !pending_instances_dir
   | Some f ->
       (* if one specifies a file, it is assumed to be the current one *)
-      pending_instances_file := (f,a,b) :: !pending_instances_file
+      (* put at the end of the list of information about this file *)
+      let rec loop = function
+         [] -> [(f,a,b)]
+       | ((f1,a1,b1) as front)::rest ->
+           if f = f1
+           then front :: (loop rest)
+           else (f,a,b) :: front :: rest in
+      pending_instances_file := loop !pending_instances_file
                                              
 let get_pending_instance _ =
   (if (List.length !pending_instances_file) > 0 or