Coccinelle release 1.0.0-rc3
[bpt/coccinelle.git] / ctl / ctl_engine.ml
index d39ad0a..776dcc6 100644 (file)
@@ -1,27 +1,7 @@
 (*
- * Copyright 2005-2010, 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.
- *)
-
-
-(*
- * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
+ * Copyright 2010, 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.
  *
@@ -1358,8 +1338,11 @@ let satEG dir ((_,_,states) as m) s reqst =
 (* **************************************************************** *)
 (* applied to the result of matching a node.  collect witnesses when the
 states and environments are the same *)
+(* not a good idea, poses problem for unparsing, because don't realize that
+adjacent things come from different matches, leading to loss of newlines etc.
+exple struct I { ... - int x; + int y; ...} *)
 
-let inner_and trips =
+let inner_and trips = trips (*
   let rec loop = function
       [] -> ([],[])
     | (s,th,w)::trips ->
@@ -1376,7 +1359,7 @@ let inner_and trips =
        | _ -> ([(s,th,w)],cur@acc)) in
   let (cur,acc) =
     loop (List.sort state_compare trips) (* is this sort needed? *) in
-  cur@acc
+  cur@acc *)
 
 (* *************** *)
 (* Partial matches *)
@@ -1542,19 +1525,20 @@ let satLabel label required p =
            (List.map (function (st,th,_) -> (st,th)) triples);
          triples
     else setify(label p) in
-    normalize
-      (if !pREQUIRED_ENV_OPT
-      then
-       foldl
-         (function rest ->
-           function ((s,th,_) as t) ->
-             if List.for_all
-                 (List.exists (function th' -> not(conj_subst th th' = None)))
-                 required
-             then t::rest
-             else rest)
-         [] triples
-      else triples)
+    (* normalize first; conj_subst relies on sorting *)
+    let ntriples = normalize triples in
+    if !pREQUIRED_ENV_OPT
+    then
+      foldl
+       (function rest ->
+         function ((s,th,_) as t) ->
+           if List.for_all
+               (List.exists (function th' -> not(conj_subst th th' = None)))
+               required
+           then t::rest
+           else rest)
+       [] ntriples
+    else ntriples
 
 let get_required_states l =
   if !pREQUIRED_STATES_OPT && not !Flag_ctl.partial_match