> 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.law...@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 _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci