2 * Copyright 2005-2008, Ecole des Mines de Nantes, University of Copenhagen
3 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller
4 * This file is part of Coccinelle.
6 * Coccinelle is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, according to version 2 of the License.
10 * Coccinelle is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
18 * The authors reserve the right to distribute this or future versions of
19 * Coccinelle under other licenses.
25 (*****************************************************************************)
27 (*****************************************************************************)
29 (* In addition to flags that can be tweaked via -xxx options (cf the
30 * full list of options in "the spatch options" section below), the
31 * spatch program also depends on external files, described in
32 * globals/config.ml, mainly a standard.h and standard.iso file *)
34 let cocci_file = ref ""
36 let output_file = ref ""
37 let inplace_modif = ref false (* but keeps a .cocci_orig *)
38 let outplace_modif = ref false (* generates a .cocci_res *)
40 (* could be avoided by using Common.files_of_dir_or_files instead *)
43 let include_headers = ref false
44 let kbuild_info = ref ""
47 let test_mode = ref false
48 let test_all = ref false
49 let test_okfailed = ref false
50 let test_regression_okfailed = ref false
56 (* works with -test but also in "normal" spatch mode *)
57 let compare_with_expected = ref false
60 let distrib_index = ref (None
: int option)
61 let distrib_max = ref (None
: int option)
62 let mod_distrib = ref false
65 (*****************************************************************************)
67 (*****************************************************************************)
69 (* pair of (list of flags to set true, list of flags to set false *)
74 (* Flag_cocci.show_diff; just leave this as it is *)
80 Flag_cocci.show_cocci
;
82 Flag_cocci.show_before_fixed_flow
;
83 Flag_cocci.show_ctl_tex
;
84 Flag_cocci.show_ctl_text
;
85 Flag_cocci.show_transinfo
;
86 Flag_cocci.show_binding_in_out
;
88 Flag_parsing_cocci.show_SP
;
89 Flag_parsing_cocci.show_iso_failures
;
90 Flag_ctl.verbose_ctl_engine
;
91 Flag_ctl.verbose_match
;
92 Flag_engine.debug_engine
;
93 Flag_parsing_c.debug_unparsing
;
94 Flag_parsing_c.verbose_type
;
95 Flag_parsing_c.verbose_parsing
;
100 Flag_cocci.show_diff
;
107 Flag_cocci.show_cocci
;
108 Flag_cocci.show_flow
;
109 Flag_cocci.show_before_fixed_flow
;
110 Flag_cocci.show_ctl_tex
;
111 Flag_cocci.show_ctl_text
;
112 Flag_cocci.show_transinfo
;
113 Flag_cocci.show_binding_in_out
;
115 Flag_parsing_cocci.show_SP
;
116 Flag_parsing_cocci.show_iso_failures
;
117 Flag_ctl.verbose_ctl_engine
;
118 Flag_ctl.verbose_match
;
119 Flag_engine.debug_engine
;
120 Flag_parsing_c.debug_unparsing
;
121 Flag_parsing_c.verbose_type
;
122 Flag_parsing_c.verbose_parsing
;
125 (*****************************************************************************)
126 (* The spatch options *)
127 (*****************************************************************************)
130 "Usage: " ^ basename
Sys.argv
.(0) ^
131 " -sp_file <SP> <infile> [-o <outfile>] [-iso_file <iso>] [options]" ^
132 "\n" ^
"Options are:"
134 (* forward reference trick *)
135 let short_usage_func = ref (fun () -> ())
136 let long_usage_func = ref (fun () -> ())
139 (* The short_options are user-oriented. The other options are for
140 * the developers of coccinelle or advanced-users that know
141 * quite well the underlying semantics of coccinelle.
145 (* will be printed when use only ./spatch. For the rest you have to
146 * use -longhelp to see them.
148 let short_options = [
149 "-sp_file", Arg.Set_string
cocci_file,
150 " <file> the semantic patch file";
152 "-o", Arg.Set_string
output_file,
153 " <file> the output file";
154 "-inplace", Arg.Set
inplace_modif,
155 " do the modification on the file directly";
156 "-outplace", Arg.Set
outplace_modif,
157 " store modifications in a .cocci_res file";
159 "-U", Arg.Int
(fun n
-> Flag_parsing_c.diff_lines
:= Some
(i_to_s n
)),
160 " set number of diff context lines";
161 "-partial_match", Arg.Set
Flag_ctl.partial_match
,
162 " report partial matches of the SP on the C file";
164 "-iso_file", Arg.Set_string
Config.std_iso
,
165 " <file> (default=" ^
!Config.std_iso ^
")";
166 "-macro_file", Arg.Set_string
Config.std_h
,
167 " <file> (default=" ^
!Config.std_h ^
")";
169 "-all_includes", Arg.Set
Flag_cocci.all_includes
,
170 " causes all available include files to be used";
171 "-no_includes", Arg.Set
Flag_cocci.no_includes
,
172 " causes not even local include files to be used";
173 "-I", Arg.Set_string
Flag_cocci.include_path
,
174 " <dir> containing the Linux headers (optional)";
178 " <dir> process all files in directory recursively";
180 "-include_headers", Arg.Set
include_headers,
181 " process header files independently";
182 "-use_glimpse", Arg.Set
Flag.use_glimpse
,
183 " works with -dir, use info generated by glimpseindex";
184 "-patch", Arg.String
(function s
-> Flag.patch
:= Some s
),
185 (" <dir> path name with respect to which a patch should be created\n"^
186 " \"\" for a file in the current directory");
187 "-kbuild_info", Arg.Set_string
kbuild_info,
188 " <file> improve -dir by grouping related c files";
189 "-pyoutput", Arg.Set_string
Flag.pyoutput
,
190 " Sets output routine: Standard values: <coccilib.output.Gtk|coccilib.output.Console>";
193 "-version", Arg.Unit
(fun () ->
194 pr2
(spf
"spatch version: %s" Config.version
);
199 "-date", Arg.Unit
(fun () ->
200 pr2
"version: $Date: 2008/09/26 00:44:57 $";
201 raise
(Common.UnixExit
0)
205 "-shorthelp", Arg.Unit
(fun () ->
207 raise
(Common.UnixExit
0)
209 " see short list of options";
210 "-longhelp", Arg.Unit
(fun () ->
212 raise
(Common.UnixExit
0)
214 " see all the available options in different categories";
215 "-help", Arg.Unit
(fun () ->
217 raise
(Common.UnixExit
0)
220 "--help", Arg.Unit
(fun () ->
222 raise
(Common.UnixExit
0)
228 (* the format is a list of triples:
229 * (title of section * (optional) explanation of sections * option list)
231 let other_options = [
232 "aliases and obsolete options",
235 "-cocci_file", Arg.Set_string
cocci_file,
236 " <file> the semantic patch file";
237 "-c", Arg.Set_string
cocci_file, " short option of -cocci_file";
238 "-iso", Arg.Set_string
Config.std_iso
, " short option of -iso_file";
239 "-D", Arg.Set_string
Config.std_h
, " short option of -macro_file";
242 "most useful show options",
245 "-show_diff" , Arg.Set
Flag_cocci.show_diff
, " ";
246 "-no_show_diff" , Arg.Clear
Flag_cocci.show_diff
, " ";
247 "-show_flow" , Arg.Set
Flag_cocci.show_flow
, " ";
248 "-no_show_ctl_text" , Arg.Clear
Flag_cocci.show_ctl_text
, " ";
249 (* works in conjunction with -show_ctl *)
250 "-ctl_inline_let", Arg.Set
Flag_cocci.inline_let_ctl
, " ";
251 "-ctl_show_mcodekind", Arg.Set
Flag_cocci.show_mcodekind_in_ctl
, " ";
252 "-show_binding_in_out", Arg.Set
Flag_cocci.show_binding_in_out
, " ";
253 "-no_show_transinfo", Arg.Clear
Flag_cocci.show_transinfo
, " ";
254 "-no_show_misc", Arg.Clear
Flag.show_misc
, " ";
255 "-show_trying", Arg.Set
Flag.show_trying
,
256 " show the name of each function being processed";
259 "verbose subsystems options",
262 "-verbose_ctl_engine", Arg.Set
Flag_ctl.verbose_ctl_engine
, " ";
263 "-verbose_match", Arg.Set
Flag_ctl.verbose_match
, " ";
264 "-verbose_engine", Arg.Set
Flag_engine.debug_engine
, " ";
266 "-no_parse_error_msg", Arg.Clear
Flag_parsing_c.verbose_parsing
, " ";
267 "-no_type_error_msg", Arg.Clear
Flag_parsing_c.verbose_type
, " ";
268 (* could also use Flag_parsing_c.options_verbose *)
271 "other show options",
274 "-show_c" , Arg.Set
Flag_cocci.show_c
, " ";
275 "-show_cocci" , Arg.Set
Flag_cocci.show_cocci
, " ";
276 "-show_before_fixed_flow" , Arg.Set
Flag_cocci.show_before_fixed_flow
, " ";
277 "-show_ctl_tex" , Arg.Set
Flag_cocci.show_ctl_tex
, " ";
278 "-show_SP_julia" , Arg.Set
Flag_parsing_cocci.show_SP
, " ";
282 "debug C parsing/unparsing",
285 "-debug_cpp", Arg.Set
Flag_parsing_c.debug_cpp
, " ";
286 "-debug_lexer", Arg.Set
Flag_parsing_c.debug_lexer
, " ";
287 "-debug_etdt", Arg.Set
Flag_parsing_c.debug_etdt
, " ";
288 "-debug_typedef", Arg.Set
Flag_parsing_c.debug_typedef
, " ";
290 "-filter_msg", Arg.Set
Flag_parsing_c.filter_msg
,
291 " filter some cpp message when the macro is a \"known\" cpp construct";
292 "-filter_define_error",Arg.Set
Flag_parsing_c.filter_define_error
," ";
293 "-filter_classic_passed",Arg.Set
Flag_parsing_c.filter_classic_passed
," ";
295 "-debug_cfg", Arg.Set
Flag_parsing_c.debug_cfg
, " ";
296 "-debug_unparsing", Arg.Set
Flag_parsing_c.debug_unparsing
, " ";
299 (* could use Flag_parsing_c.options_debug_with_title instead *)
302 "shortcut for enabling/disabling a set of debugging options at once",
305 (* todo: other profile ? *)
306 "-quiet", Arg.Unit
(fun () ->
307 let (set_to_true
, set_to_false
) = quiet_profile in
308 List.iter
(fun x
-> x
:= false) set_to_false
;
309 List.iter
(fun x
-> x
:= true) set_to_true
;
312 "-pad", Arg.Unit
(fun () ->
313 let (set_to_true
, set_to_false
) = pad_profile in
314 List.iter
(fun x
-> x
:= false) set_to_false
;
315 List.iter
(fun x
-> x
:= true) set_to_true
;
323 "-profile", Arg.Unit
(function () -> Common.profile
:= Common.PALL
) ,
324 " gather timing information about the main coccinelle functions";
325 "-bench", Arg.Int
(function x
-> Flag_ctl.bench
:= x
),
326 " <level> for profiling the CTL engine";
327 "-timeout", Arg.Int
(fun x
-> Flag_cocci.timeout
:= Some x
),
328 " <sec> timeout in seconds";
329 "-steps", Arg.Int
(fun x
-> Flag_ctl.steps
:= Some x
),
330 " max number of model checking steps per code unit";
331 "-track_iso", Arg.Set
Flag.track_iso_usage
,
332 " gather information about isomorphism usage";
336 Common.profile
:=PSOME
["parse cocci";"mysat";"asttoctl2";"full_engine"]),
337 " gather information about the cost of isomorphism usage"
342 "change of algorithm options",
345 "-popl", Arg.Set
Flag_cocci.popl
,
346 " simplified SmPL, for the popl paper";
350 (function _
-> Flag_cocci.popl
:= true; Flag_popl.mark_all
:= true),
351 " simplified SmPL, for the popl paper";
353 "-popl_keep_all_wits",
355 (function _
-> Flag_cocci.popl
:= true; Flag_popl.keep_all_wits
:= true),
356 " simplified SmPL, for the popl paper";
358 "-hrule", Arg.String
(function s
-> Flag.make_hrule
:= Some s
),
359 " semantic patch generation";
361 "-loop", Arg.Set
Flag_ctl.loop_in_src_code
, " ";
363 "-l1", Arg.Clear
Flag_parsing_c.label_strategy_2
, " ";
364 "-ifdef", Arg.Set
Flag_parsing_c.ifdef_to_if
,
365 " convert ifdef to if (buggy!)";
366 "-noif0_passing", Arg.Clear
Flag_parsing_c.if0_passing
,
368 "-noadd_typedef_root", Arg.Clear
Flag_parsing_c.add_typedef_root
, " ";
369 (* could use Flag_parsing_c.options_algo instead *)
372 "-disallow_nested_exps", Arg.Set
Flag_engine.disallow_nested_exps
,
373 "disallow an expresion pattern from matching a term and its subterm";
374 "-disable_worth_trying_opt", Arg.Clear
Flag_cocci.worth_trying_opt
,
376 "-only_return_is_error_exit",
377 Arg.Set
Flag_engine.only_return_is_error_exit
,
378 "if this flag is not set, then break and continue are also error exits";
379 (* the following is a hack to make it easier to add code in sgrep-like
380 code, essentially to compensate for the fact that we don't have
381 any way of printing things out *)
382 "-allow_inconsistent_paths",
383 Arg.Set
Flag_engine.allow_inconsistent_paths
,
384 "if this flag is set don't check for inconsistent paths; dangerous";
390 "-debugger", Arg.Set
Common.debugger
,
391 " option to set if launch spatch in ocamldebug";
392 "-disable_once", Arg.Set
Common.disable_pr2_once
,
393 " to print more messages";
394 "-save_tmp_files", Arg.Set
Common.save_tmp_files
, " ";
400 "-index", Arg.Int
(function x
-> distrib_index := Some x
) ,
401 " the processor to use for this run of spatch";
402 "-max", Arg.Int
(function x
-> distrib_max := Some x
) ,
403 " the number of processors available";
404 "-mod_distrib", Arg.Set
mod_distrib,
405 " use mod to distribute files among the processors";
411 "-use_cache", Arg.Set
Flag_parsing_c.use_cache
,
412 " use .ast_raw pre-parsed cached C file";
413 (* could use Flag_parsing_c.options_pad instead *)
418 "test mode and test options (works with tests/ or .ok files)",
419 "The test options don't work with the -sp_file and so on.",
421 "-test", Arg.Set
test_mode,
422 " <file> launch spatch on tests/file.[c,cocci]";
423 "-testall", Arg.Set
test_all,
424 " launch spatch on all files in tests/ having a .res";
425 "-test_okfailed", Arg.Set
test_okfailed,
426 " generates .{ok,failed,spatch_ok} files using .res files";
427 "-test_regression_okfailed", Arg.Set
test_regression_okfailed,
428 " process the .{ok,failed,spatch_ok} files in current dir";
430 "-compare_with_expected", Arg.Set
compare_with_expected,
431 " use also file.res";
432 "-relax_include_path", Arg.Set
Flag_cocci.relax_include_path
,
438 ("The action options don't work with the -sp_file and so on." ^
"\n" ^
439 "It's for the other (internal) uses of the spatch program."
442 (* -token_c, -parse_c, etc *)
443 ((Common.options_of_actions
action (Test_parsing_c.actions
())) ++
445 (let s = "-parse_cocci" in s, Arg.Unit
(fun () -> action := s),
447 (let s = "-compare_c" in s, Arg.Unit
(fun () -> action := s),
454 short_options ++ List.concat
(List.map
Common.thd3
other_options)
458 (* I don't want the -help and --help that are appended by Arg.align *)
460 Arg.align xs
+> List.rev
+> Common.drop
2 +> List.rev
462 (* copy paste of Arg.parse. Don't want the default -help msg *)
463 let arg_parse2 l f msg
=
465 Arg.parse_argv
Sys.argv l f msg
;
467 | Arg.Bad msg
-> (* eprintf "%s" msg; exit 2; *)
468 let xs = Common.lines msg
in
469 (* take only head, it's where the error msg is *)
472 raise
(Common.UnixExit
(2))
473 | Arg.Help msg
-> (* printf "%s" msg; exit 0; *)
474 raise Impossible
(* -help is specified in speclist *)
480 Common.short_usage usage_msg short_options;
482 pr2
"Example of use:";
483 pr2
" ./spatch -sp_file foo.cocci foo.c -o /tmp/newfoo.c";
489 Common.long_usage usage_msg short_options other_options
491 let _ = short_usage_func := short_usage
492 let _ = long_usage_func := long_usage
494 (*****************************************************************************)
496 (*****************************************************************************)
498 let adjust_stdin cfile k
=
503 let (dir, base
, ext
) = Common.dbe_of_filename cfile
in
504 let varfile = Common.filename_of_dbe
(dir, base
, "var") in
505 if ext
= "c" && Common.lfile_exists
varfile
508 Common.redirect_stdin_opt
newin k
510 let glimpse_filter (coccifile
, isofile
) dir =
511 let (astcocci
,_free_var_lists
,_negated_positions
,
512 _used_after_lists
,_positions_lists
,_,query
) =
513 Cocci.sp_of_file coccifile
(Some isofile
) in
515 None
-> pr2
"no glimpse keyword infered from snippet"; None
517 let suffixes = if !include_headers then ["c";"h"] else ["c"] in
518 pr2
("glimpse request = " ^ query
);
519 let command = spf
"glimpse -y -H %s -N -W -w '%s'" dir query
in
520 let (glimpse_res
,stat
) = Common.cmd_to_list_and_status
command in
522 Unix.WEXITED
(0) | Unix.WEXITED
(1) ->
526 (fun file
-> List.mem
(Common.filesuffix file
) suffixes))
527 | _ -> None
(* error, eg due to pattern too big *)
532 (*****************************************************************************)
533 (* The coccinelle main entry point *)
534 (*****************************************************************************)
539 arg_parse2 (Arg.align
all_options) (fun x
-> args := x
::!args) usage_msg;
541 (if !dir && List.length
!args > 1
544 let chosen = List.hd
!args in
545 pr2
("ignoring all but the last specified directory: "^
chosen);
548 args := List.rev
!args;
550 (if !Flag_cocci.all_includes
&& !Flag_cocci.no_includes
551 then failwith
"cannot set both all_includes and no_includes");
553 if !cocci_file <> "" && (not
(!cocci_file =~
".*\\.\\(sgrep\\|spatch\\)$"))
554 then cocci_file := Common.adjust_ext_if_needed
!cocci_file ".cocci";
556 if !Config.std_iso
<> ""
557 then Config.std_iso
:= Common.adjust_ext_if_needed
!Config.std_iso
".iso";
558 if !Config.std_h
<> ""
559 then Config.std_h
:= Common.adjust_ext_if_needed
!Config.std_h
".h";
561 if !Config.std_h
<> ""
562 then Parse_c.init_defs
!Config.std_h
;
565 (* must be done after Arg.parse, because Common.profile is set by it *)
566 Common.profile_code
"Main total" (fun () ->
569 let all_actions = Test_parsing_c.actions
() in
573 (* --------------------------------------------------------- *)
574 (* The test framework. Works with tests/ or .ok and .failed *)
575 (* --------------------------------------------------------- *)
576 | [x
] when !test_mode ->
577 Flag_cocci.include_path
:= "tests/include";
578 Testing.testone x
!compare_with_expected
580 | [] when !test_all ->
581 Flag_cocci.include_path
:= "tests/include";
584 | [] when !test_regression_okfailed ->
585 Testing.test_regression_okfailed ()
587 | x
::xs when !test_okfailed ->
588 (* do its own timeout on Flag_cocci.timeout internally *)
589 Flag_cocci.relax_include_path
:= true;
590 adjust_stdin x
(fun () ->
591 Testing.test_okfailed !cocci_file (x
::xs)
594 (* --------------------------------------------------------- *)
595 (* Actions, useful to debug subpart of coccinelle *)
596 (* --------------------------------------------------------- *)
598 | xs when List.mem
!action (Common.action_list
all_actions) ->
599 Common.do_action
!action xs all_actions
601 | [file
] when !action = "-parse_cocci" ->
602 Testing.test_parse_cocci file
604 (* I think this is used by some scripts in some Makefile for our
605 * big-tests. So dont remove.
607 | [file1
;file2
] when !action = "-compare_c" ->
608 Test_parsing_c.test_compare_c file1 file2
(* result = unix code *)
610 (* could add the Test_parsing_c.test_actions such as -parse_c & co *)
613 (* --------------------------------------------------------- *)
614 (* This is the main entry *)
615 (* --------------------------------------------------------- *)
617 adjust_stdin x
(fun () ->
619 then failwith
"I need a cocci file, use -sp_file <file>";
621 if !dir && !Flag.patch
= None
624 | [] -> Flag.patch
:= Some x
627 ("warning: patch output can only be created when only one\n"^
628 "directory is specified or when the -patch flag is used")
632 Common.profile_code
"Main.infiles computation" (fun () ->
633 match !dir, !kbuild_info, !Flag.use_glimpse
with
636 failwith
"-use_glimpse works only with -dir"
637 | true, s, true when s <> "" ->
638 failwith
"-use_glimpse does not work with -kbuild"
641 then failwith
"-use_glimpse can accept only one dir";
644 match glimpse_filter (!cocci_file, !Config.std_iso
) x
with
646 Common.cmd_to_list
(* same as "true, "", _" case *)
648 then ("find "^
(join
" " (x
::xs))^
" -name \"*.[ch]\"")
649 else ("find "^
(join
" " (x
::xs))^
" -name \"*.c\""))
650 | Some
files -> files in
651 files +> List.map
(fun x
-> [x
])
653 | false, _, _ -> [x
::xs]
657 then ("find "^
(join
" " (x
::xs))^
" -name \"*.[ch]\"")
658 else ("find "^
(join
" " (x
::xs))^
" -name \"*.c\""))
659 +> List.map
(fun x
-> [x
])
662 | true, kbuild_info_file
,_ ->
664 Common.cmd_to_list
("find "^
(join
" " (x
::xs))^
" -type d")
666 let info = Kbuild.parse_kbuild_info kbuild_info_file
in
667 let groups = Kbuild.files_in_dirs
dirs info in
669 groups +> List.map
(function Kbuild.Group
xs -> xs)
674 match (!distrib_index,!distrib_max) with
675 (None
,None
) -> infiles
676 | (Some index
,Some max
) ->
679 failwith
"index starts at 0, and so must be less than max");
682 let rec loop ct
= function
685 if (ct
mod max
) = index
686 then x
::(loop (ct
+1) xs)
687 else loop (ct
+1) xs in
691 let all_files = List.length
infiles in
692 let regions = (all_files + (max
- 1)) / max
in
693 let this_min = index
* regions in
694 let this_max = (index
+1) * regions in
695 let rec loop ct
= function
698 if this_min <= ct
&& ct
< this_max
699 then x
::(loop (ct
+1) xs)
700 else loop (ct
+1) xs in
703 | _ -> failwith
"inconsistent distribution information" in
706 Common.profile_code
"Main.outfiles computation" (fun () ->
707 infiles +> List.map
(fun cfiles
->
708 pr2
("HANDLING: " ^
(join
" " cfiles
));
709 Common.timeout_function_opt
!Flag_cocci.timeout
(fun () ->
710 Common.report_if_take_time
10 (join
" " cfiles
) (fun () ->
713 (* this is the main call *)
714 Cocci.full_engine
(!cocci_file, !Config.std_iso
) cfiles
716 | Common.UnixExit x
-> raise
(Common.UnixExit x
)
720 pr2
("EXN:" ^
Printexc.to_string e
);
727 Common.profile_code
"Main.result analysis" (fun () ->
729 Ctlcocci_integration.print_bench
();
731 let outfiles = Cocci.check_duplicate_modif
outfiles in
733 outfiles +> List.iter
(fun (infile
, outopt
) ->
734 outopt
+> Common.do_option
(fun outfile
->
737 Common.command2
("cp "^infile^
" "^infile^
".cocci_orig");
738 Common.command2
("cp "^outfile^
" "^infile
);
742 then Common.command2
("cp "^outfile^
" "^infile^
".cocci_res");
746 let tmpfile = "/tmp/"^
Common.basename infile
in
747 pr2
(spf
"One file modified. Result is here: %s" tmpfile);
748 Common.command2
("cp "^outfile^
" "^
tmpfile);
751 if !output_file <> "" then
753 | [infile
, Some outfile
] when infile
= x
&& null
xs ->
754 Common.command2
("cp " ^outfile^
" " ^
!output_file);
755 | [infile
, None
] when infile
= x
&& null
xs ->
756 Common.command2
("cp " ^infile^
" " ^
!output_file);
759 ("-o can not be applied because there is multiple " ^
763 if !compare_with_expected
764 then Testing.compare_with_expected outfiles))
766 (* --------------------------------------------------------- *)
768 (* --------------------------------------------------------- *)
769 | [] -> short_usage()
772 if !Pycocci.initialised
&& (Pycocci.py_isinitialized
()) != 0 then begin
773 ignore
(Pycocci.pyrun_simplestring
"cocci.finalise()");
775 then Common.pr2
"Finalizing python\n";
776 Pycocci.py_finalize
();
780 (*****************************************************************************)
782 Common.main_boilerplate
(fun () ->
784 Ctlcocci_integration.print_bench
();