Coccinelle release-1.0.0-rc11
[bpt/coccinelle.git] / engine / sgrep.ml
index d18659e..c5689b0 100644 (file)
@@ -1,25 +1,31 @@
 (*
-* Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
-* Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller
-* 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 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.
+ *)
 
 
+(* no longer used *)
+
 type marker =
     NoMark | BefMark of string | AftMark of string
   | BefAftMark of string * string
@@ -72,7 +78,7 @@ let process_sgrep ii mck =
            amarker file line (col + String.length str);
          Ast_cocci.MINUS(pos,inst,adj,repl))
   | Ast_cocci.CONTEXT(pos,Ast_cocci.NOTHING) -> mck
-  | Ast_cocci.CONTEXT(pos,Ast_cocci.BEFORE(bef)) ->
+  | Ast_cocci.CONTEXT(pos,Ast_cocci.BEFORE(bef,c)) ->
       (match extract_sgrep_marker bef with
        (NoMark,_) -> mck
       |        (BefMark(marker),[]) ->
@@ -82,9 +88,9 @@ let process_sgrep ii mck =
       |        (BefMark(marker),bef) ->
          Printf.printf "Match on line %s starting at %s: line %d offset %d\n"
            marker file line col;
-         Ast_cocci.CONTEXT(pos,Ast_cocci.BEFORE(bef))
+         Ast_cocci.CONTEXT(pos,Ast_cocci.BEFORE(bef,c))
       |        _ -> failwith "after not possible")
-  | Ast_cocci.CONTEXT(pos,Ast_cocci.AFTER(aft)) ->
+  | Ast_cocci.CONTEXT(pos,Ast_cocci.AFTER(aft,c)) ->
       (match extract_sgrep_marker aft with
        (NoMark,_) -> mck
       |        (AftMark(marker),[]) ->
@@ -94,9 +100,9 @@ let process_sgrep ii mck =
       |        (AftMark(marker),aft) ->
          Printf.printf "Match on line %s ending at %s: line %d offset %d\n"
            marker file line (col + String.length str);
-         Ast_cocci.CONTEXT(pos,Ast_cocci.AFTER(aft))
+         Ast_cocci.CONTEXT(pos,Ast_cocci.AFTER(aft,c))
       |        _ -> failwith "before not possible")
-  | Ast_cocci.CONTEXT(pos,Ast_cocci.BEFOREAFTER(bef,aft)) ->
+  | Ast_cocci.CONTEXT(pos,Ast_cocci.BEFOREAFTER(bef,aft,c)) ->
       (match extract_sgrep_marker bef with
        (NoMark,_) ->
          (match extract_sgrep_marker aft with
@@ -105,18 +111,18 @@ let process_sgrep ii mck =
              Printf.printf
                "Match on line %s ending at %s: line %d offset %d\n"
                marker file line (col + String.length str);
-             Ast_cocci.CONTEXT(pos,Ast_cocci.BEFORE(bef))
+             Ast_cocci.CONTEXT(pos,Ast_cocci.BEFORE(bef,c))
          | (AftMark(marker),aft) ->
              Printf.printf
                "Match on line %s ending at %s: line %d offset %d\n"
                marker file line (col + String.length str);
-             Ast_cocci.CONTEXT(pos,Ast_cocci.BEFOREAFTER(bef,aft))
+             Ast_cocci.CONTEXT(pos,Ast_cocci.BEFOREAFTER(bef,aft,c))
          | _ -> failwith "before not possible")
       | (BefMark(marker),[]) ->
          Printf.printf "Match on line %s starting at %s: line %d offset %d\n"
            marker file line col;
          (match extract_sgrep_marker aft with
-           (NoMark,_) -> Ast_cocci.CONTEXT(pos,Ast_cocci.AFTER(aft))
+           (NoMark,_) -> Ast_cocci.CONTEXT(pos,Ast_cocci.AFTER(aft,c))
          | (AftMark(marker),[]) ->
              Printf.printf
                "Match on line %s ending at %s: line %d offset %d\n"
@@ -126,24 +132,24 @@ let process_sgrep ii mck =
              Printf.printf
                "Match on line %s ending at %s: line %d offset %d\n"
                marker file line (col + String.length str);
-             Ast_cocci.CONTEXT(pos,Ast_cocci.AFTER(aft))
+             Ast_cocci.CONTEXT(pos,Ast_cocci.AFTER(aft,c))
          | _ -> failwith "before not possible")
       | (BefMark(marker),bef) ->
          Printf.printf "Match on line %s starting at %s: line %d offset %d\n"
            marker file line col;
          (match extract_sgrep_marker aft with
            (NoMark,_) ->
-             Ast_cocci.CONTEXT(pos,Ast_cocci.BEFOREAFTER(bef,aft))
+             Ast_cocci.CONTEXT(pos,Ast_cocci.BEFOREAFTER(bef,aft,c))
          | (AftMark(marker),[]) ->
              Printf.printf
                "Match on line %s ending at %s: line %d offset %d\n"
                marker file line (col + String.length str);
-             Ast_cocci.CONTEXT(pos,Ast_cocci.BEFORE(bef))
+             Ast_cocci.CONTEXT(pos,Ast_cocci.BEFORE(bef,c))
          | (AftMark(marker),aft) ->
              Printf.printf
                "Match on line %s ending at %s: line %d offset %d\n"
                marker file line (col + String.length str);
-             Ast_cocci.CONTEXT(pos,Ast_cocci.BEFOREAFTER(bef,aft))
+             Ast_cocci.CONTEXT(pos,Ast_cocci.BEFOREAFTER(bef,aft,c))
          | _ -> failwith "before not possible")
       |        _ -> failwith "after not possible")
   | _ -> failwith "unexpected plus code"