* [Cocci] id-utils?
2013-05-27 20:08 ` Wolfram Sang
@ 2013-05-27 20:15 ` Julia Lawall
2013-05-27 21:14 ` Julia Lawall
1 sibling, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2013-05-27 20:15 UTC (permalink / raw)
To: cocci
On Mon, 27 May 2013, Wolfram Sang wrote:
> On Sat, May 25, 2013 at 06:42:47PM +0200, Julia Lawall wrote:
> > Attached.
>
> Thanks, works like a charm! Processing the kernel took 20 seconds (plus
> 3 minutes to generate the index once). Without idutils, processing was 9
> minutes. So, I love it!
>
> I found out that I can also use the index generated by the viewer
> 'seascope'. The name is 'ID' instead of '.id-utils.index', so I
> symlinked to it. It might be an idea to give the --use-idutils option an
> optional filename argument to point to the index it should use?
I'll try to do that. I don't know if the ocaml argumenmt parser supports
optional arguments. If not it will have to be some other argument flag.
Thanks for the feedback.
julia
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cocci] id-utils?
2013-05-27 20:08 ` Wolfram Sang
2013-05-27 20:15 ` Julia Lawall
@ 2013-05-27 21:14 ` Julia Lawall
1 sibling, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2013-05-27 21:14 UTC (permalink / raw)
To: cocci
> I found out that I can also use the index generated by the viewer
> 'seascope'. The name is 'ID' instead of '.id-utils.index', so I
> symlinked to it. It might be an idea to give the --use-idutils option an
> optional filename argument to point to the index it should use?
A patch is below. It is only very lightly tested.
julia
commit 4bac82f94d224182f8af80046d23f2e708c9a7b5
Author: julia <julia.lawall@lip6.fr>
Date: Mon May 27 22:54:57 2013 +0200
optional file name argument for idutils
diff --git a/docs/manual/spatch_options.tex b/docs/manual/spatch_options.tex
index feca3f1..d163d2d 100644
--- a/docs/manual/spatch_options.tex
+++ b/docs/manual/spatch_options.tex
@@ -188,12 +188,19 @@ specified. The index may be created using the script {\tt
http://webglimpse.net/. In conjunction with the option {\bf --patch-cocci}
this option prints the regular expression that will be passed to glimpse.}
-\normal{--use-idutils}{ Use an id-utils index created using lid to select
+\normal{--use-idutils $[\langle$file$\rangle]$}
+{ Use an id-utils index created using lid to select
the files to which a semantic patch may be relevant. This option
requires that a directory is specified. The index may be created using
the script {\tt coccinelle/scripts/ idindex-cocci.sh}. In conjunction
with the option {\bf --patch-cocci} this option prints the regular
- expression that will be passed to glimpse.}
+ expression that will be passed to glimpse.
+
+The optional file name option is the name of the file in which to find the
+index. It has been reported that the viewer seascope can be used to
+generate an appropriate index. If no file name is specified, the default
+is .id-utils.index.
+}
\rare{--dir}{ Specify a directory containing C files to process. A trailing
{\tt /} is permitted on the directory name and has no impact on the
diff --git a/main.ml b/main.ml
index 22c1f32..ac570b1 100644
--- a/main.ml
+++ b/main.ml
@@ -302,7 +302,9 @@ 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";
- "--use-idutils", Arg.Unit (function s -> Flag.scanner := Flag.IdUtils),
+ "--use-idutils",
+ Arg.String (function s -> Flag_parsing_cocci.id_utils_index := s;
+ Flag.scanner := Flag.IdUtils),
" find relevant files using id-utils";
"--patch",
Arg.String (function s -> Flag.patch := Some (Cocci.normalize_path s)),
@@ -1021,6 +1023,14 @@ let fix_chars s =
then "-"^(String.concat "-" (Str.split (Str.regexp_string "_") s))
else s
+let rec fix_idutils = function
+ [] -> []
+ | ["--use-idutils"] -> ["--use-idutils";".id-utils.index"]
+ | "--use-idutils"::second::rest
+ when String.length second > 0 && String.get second 0 = '-' ->
+ "--use-idutils"::".id-utils.index" :: (fix_idutils (second :: rest))
+ | x :: rest -> x :: (fix_idutils rest)
+
(*****************************************************************************)
(* The coccinelle main entry point *)
(*****************************************************************************)
@@ -1029,6 +1039,7 @@ let main () =
let arglist = Array.to_list Sys.argv in
let arglist = Command_line.command_line arglist in
let arglist = List.map fix_chars arglist in
+ let arglist = fix_idutils arglist in
let contains_cocci =
(* rather a hack... don't want to think about all possible options *)
diff --git a/parsing_cocci/flag_parsing_cocci.ml b/parsing_cocci/flag_parsing_cocci.ml
index 4f446d2..76f415b 100644
--- a/parsing_cocci/flag_parsing_cocci.ml
+++ b/parsing_cocci/flag_parsing_cocci.ml
@@ -14,3 +14,5 @@ let disabled_isos = ref ([] : string list)
(* Used to debug embedded ML scripts *)
let keep_ml_script = ref false
+
+let id_utils_index = ref ".id-utils.index" (* default id-utils value *)
diff --git a/parsing_cocci/id_utils.ml b/parsing_cocci/id_utils.ml
index a53feca..d7052dc 100644
--- a/parsing_cocci/id_utils.ml
+++ b/parsing_cocci/id_utils.ml
@@ -17,8 +17,8 @@ let rec interpret dir exp =
(match exp with
GC.Elem oo ->
let cmd =
- Printf.sprintf
- "lid -f %s/.id-utils.index -l %s -S newline" dir oo in
+ Printf.sprintf "lid -f %s/%s -l %s -S newline"
+ dir !Flag_parsing_cocci.id_utils_index oo in
Common.cmd_to_list cmd
| GC.And l ->
let rec loop = function
^ permalink raw reply related [flat|nested] 6+ messages in thread