Release coccinelle-0.2.2-rc1
[bpt/coccinelle.git] / main.ml
diff --git a/main.ml b/main.ml
index f5780a6..b96cba4 100644 (file)
--- a/main.ml
+++ b/main.ml
@@ -296,7 +296,9 @@ let short_options = [
   "  causes local include files to be used";
   "-include_headers", Arg.Set include_headers,
   "    process header files independently";
-  "-I",   Arg.String (function x -> FC.include_path := Some x),
+  "-I",   Arg.String (fun x ->
+                       FC.include_path:= x::!FC.include_path
+                    ),
   "  <dir> containing the header files (optional)";
 
   "-preprocess", Arg.Set preprocess,
@@ -311,7 +313,8 @@ let short_options = [
   "    works with -dir, use info generated by glimpseindex";
   "-use_google", Arg.String (function s -> Flag.scanner := Flag.Google s),
   "    find relevant files using google code search";
-  "-patch", Arg.String (function s -> Flag.patch := Some s),
+  "-patch",
+    Arg.String (function s -> Flag.patch := Some (Cocci.normalize_path s)),
   ("    <dir> path name with respect to which a patch should be created\n"^
    "    \"\" for a file in the current directory");
   "-kbuild_info", Arg.Set_string kbuild_info,
@@ -328,7 +331,7 @@ let short_options = [
     "  guess what";
 
   "-date",   Arg.Unit (fun () ->
-    pr2 "version: $Date: 2010/01/26 06:01:55 $";
+    pr2 "version: $Date: 2010/03/05 21:12:11 $";
     raise (Common.UnixExit 0)
     ),
   "   guess what";
@@ -732,7 +735,7 @@ let main_action xs =
        if !dir && !Flag.patch =*= None
        then
          (match xs with
-         | [] -> Flag.patch := Some x
+         | [] -> Flag.patch := Some (Cocci.normalize_path x)
          | _ ->
              pr2
                ("warning: patch output can only be created when only one\n"^
@@ -938,8 +941,8 @@ let main () =
             chosen
           end
         else List.hd !args in
-      if !FC.include_path =*= None
-      then FC.include_path := Some (Filename.concat chosen_dir "include"));
+      if !FC.include_path =*= []
+      then FC.include_path := [Filename.concat chosen_dir "include"]);
 
     args := List.rev !args;
 
@@ -970,11 +973,18 @@ let main () =
     (* The test framework. Works with tests/ or .ok and .failed  *)
     (* --------------------------------------------------------- *)
     | [x] when !test_mode    ->
-        FC.include_path := Some "tests/include";
-        Testing.testone x !compare_with_expected
+       begin
+         try
+           let prefix = "tests/" in
+              FC.include_path := [prefix^"include"];
+              Testing.testone prefix x !compare_with_expected
+         with _ ->
+            FC.include_path := ["include"];
+            Testing.testone "" x !compare_with_expected
+       end
 
     | []  when !test_all ->
-        FC.include_path := Some "tests/include";
+        FC.include_path := ["tests/include"];
         if !expected_score_file <> ""
         then Testing.testall ~expected_score_file:!expected_score_file ()
         else Testing.testall ()