X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fmatita%2Fcontribs%2Flambdadelta%2Fbasic_2%2Frt_transition%2Fhls.ml;h=01f59045d18adb38f6dd3652f8002996ac2f282d;hb=cbcadc678c098f64e7eac31cb73297558ba37b4a;hp=9c12ae1c74ec42be84a07d4fa057dcd4ec35a6b5;hpb=d055e3276446167c8f903e9292aeabb4334947d4;p=helm.git diff --git a/matita/matita/contribs/lambdadelta/basic_2/rt_transition/hls.ml b/matita/matita/contribs/lambdadelta/basic_2/rt_transition/hls.ml index 9c12ae1c7..01f59045d 100644 --- a/matita/matita/contribs/lambdadelta/basic_2/rt_transition/hls.ml +++ b/matita/matita/contribs/lambdadelta/basic_2/rt_transition/hls.ml @@ -15,6 +15,19 @@ let rec read ich = let length l s = max l (String.length s) +let split s = +try + let i = String.rindex s '.' in + if i = 0 then s, "" else + String.sub s 0 i, String.sub s i (String.length s - i) +with Not_found -> s, "" + +let compare s1 s2 = + let n1, e1 = split s1 in + let n2, e2 = split s2 in + let e = String.compare e1 e2 in + if e = 0 then String.compare n1 n2 else e + let write l c s = let pre, post = if List.mem s !hl then color, normal else "", "" in let spc = String.make (l - String.length s) ' ' in @@ -34,8 +47,8 @@ let help = "" let main = Arg.parse [] process help; let files = Sys.readdir "." in - Array.fast_sort String.compare files; let l = Array.fold_left length 0 files in if cols < l then failwith "window too small"; + Array.fast_sort compare files; let c = Array.fold_left (write l) 0 files in - if 0 < c && c < cols then print_newline () + if 0 < c && c < cols then print_newline ();