From 17a935085d171c7ba4d9894931bfe6c74dc93528 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Tue, 26 Oct 2004 12:44:13 +0000 Subject: [PATCH] bugfix: implemented interactive_user_uri_choice (trivial non-"advanced" implementation: filter out variables) --- helm/searchEngine/searchEngine.ml | 32 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/helm/searchEngine/searchEngine.ml b/helm/searchEngine/searchEngine.ml index 8bcd141b0..d327c71bf 100644 --- a/helm/searchEngine/searchEngine.ml +++ b/helm/searchEngine/searchEngine.ml @@ -98,6 +98,10 @@ let javascript_quote s = let string_tail s = let len = String.length s in String.sub s 1 (len-1) +let nonvar s = + let len = String.length s in + let suffix = String.sub s (len-4) 4 in + not (suffix = ".var") let add_param_substs params = List.map @@ -196,19 +200,19 @@ let exec_action dbh (req: Http_types.request) outchan = List.map int_of_string (Pcre.split ~pat:" " choices) in let parse_choices choices_raw = let choices = Pcre.split ~pat:";" choices_raw in - List.fold_left - (fun f x -> - match Pcre.split ~pat:"\\s" x with - | ""::id::tail - | id::tail when id<>"" -> - (fun id' -> - if id = id' then - Some (List.map (fun u -> Netencoding.Url.decode u) tail) - else - f id') - | _ -> failwith "Can't parse choices") - (fun _ -> None) - choices + List.fold_left + (fun f x -> + match Pcre.split ~pat:"\\s" x with + | ""::id::tail + | id::tail when id<>"" -> + (fun id' -> + if id = id' then + Some (List.map (fun u -> Netencoding.Url.decode u) tail) + else + f id') + | _ -> failwith "Can't parse choices") + (fun _ -> None) + choices in let id_to_uris = CicTextualParser2.EnvironmentP3.of_string id_to_uris_raw in let id_to_choices = @@ -231,7 +235,7 @@ let exec_action dbh (req: Http_types.request) outchan = = match id_to_choices id with | Some choices -> choices - | None -> assert false + | None -> List.filter nonvar choices let interactive_interpretation_choice interpretations = match interpretation_choices with -- 2.39.2