From e741cbf7dfaea51173635b7c5c47c12e1e515b1b Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Fri, 24 Jun 2005 08:06:59 +0000 Subject: [PATCH] Small improvement in extracting suffixes. --- helm/ocaml/urimanager/uriManager.ml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/helm/ocaml/urimanager/uriManager.ml b/helm/ocaml/urimanager/uriManager.ml index f701125ed..203093c7e 100644 --- a/helm/ocaml/urimanager/uriManager.ml +++ b/helm/ocaml/urimanager/uriManager.ml @@ -93,33 +93,32 @@ let strip_xpointer ((uri,_) as olduri) = with Not_found -> olduri -let clear_suffix uri ?(pat2="") pat1 = +let clear_suffix uri ?(pat2="",0) pat1 = try let index = String.rindex uri '.' in let index' = index + 1 in let suffix = String.sub uri index' (String.length uri - index') in - if pat1 = suffix || pat2 = suffix then + if fst pat1 = suffix || fst pat2 = suffix then String.sub uri 0 index else uri with Not_found -> assert false -let has_suffix uri pat = +let has_suffix uri (pat,n) = try - let index = String.rindex uri '.' + 1 in - let suffix = String.sub uri index (String.length uri - index) in + let suffix = String.sub uri (String.length uri - n) n in pat = suffix with Not_found -> assert false -let _types = "types" let _dottypes = ".types" -let _ann = "ann" +let _types = "types",5 +let _ann = "ann",3 let _dotann = ".ann" -let _var = "var" +let _var = "var",3 let _dotbody = ".body" -let _con = "con" +let _con = "con",3 let _xpointer = "#xpointer(1/" let cicuri_of_uri (uri, _) = uri_of_string (clear_suffix uri ~pat2:_types _ann) -- 2.39.2