diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2002-11-12 14:07:28 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2002-11-12 14:07:28 +0000 |
commit | 695c5b66f3a8da169c48e7989edb4db2a894e5aa (patch) | |
tree | 8ac6e0561f382c2636ab41c0be90b11da2033f7c /perl_checker.src/common.ml | |
parent | 7fff947a462837c0cc7ea4cbf4da146b796ac349 (diff) | |
download | perl-MDK-Common-695c5b66f3a8da169c48e7989edb4db2a894e5aa.tar perl-MDK-Common-695c5b66f3a8da169c48e7989edb4db2a894e5aa.tar.gz perl-MDK-Common-695c5b66f3a8da169c48e7989edb4db2a894e5aa.tar.bz2 perl-MDK-Common-695c5b66f3a8da169c48e7989edb4db2a894e5aa.tar.xz perl-MDK-Common-695c5b66f3a8da169c48e7989edb4db2a894e5aa.zip |
*** empty log message ***
Diffstat (limited to 'perl_checker.src/common.ml')
-rw-r--r-- | perl_checker.src/common.ml | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/perl_checker.src/common.ml b/perl_checker.src/common.ml index 0f20e7a..f600e01 100644 --- a/perl_checker.src/common.ml +++ b/perl_checker.src/common.ml @@ -8,18 +8,6 @@ exception GraphSort_circular_deps type ('a, 'b) either = Left of 'a | Right of 'b type ('a, 'b) or_option = Or_some of 'a | Or_error of 'b -let bpos = "",-1,-1 - -let norm (a,b) = if a = -1 then b else a -let unipos (s,a,b) (s2,c,d) = - if (a,b) = (-1,-1) then s2,c,d else - if (c,d) = (-1,-1) then s,a,b else - if s <> s2 then bpos else s, min (norm(a,c)) (norm(c,a)), max (norm(b,d)) (norm(d,b)) - -let uniposl l = match l with - | [] -> bpos - | e::l -> fold_left unipos e l - (**********************************************************************************) let internal_error s = failwith ("internal error: " ^ s) @@ -267,6 +255,9 @@ let rec l_option2option_l = function | Some e :: l -> map_option (fun l -> e :: l) (l_option2option_l l) let map_option_env f (e, env) = map_option f e, env +let t2_to_list (a,b) = [ a ; b ] +let t3_to_list (a,b,c) = [ a ; b ; c ] + let if_some bool val_ = if bool then Some val_ else None let rec fold_left_option f val_ = function @@ -653,17 +644,13 @@ let skip_n_char_ beg end_ s = String.sub s beg (String.length s - beg - end_) let skip_n_char n s = skip_n_char_ n 0 s -let rec index_spaces_from beg s = - if s.[beg] = ' ' || s.[beg] = '\t' then beg else index_spaces_from (beg+1) s -let index_spaces s = index_spaces_from 0 s - -let rec index_non_spaces_from beg s = - if s.[beg] = ' ' || s.[beg] = '\t' then index_non_spaces_from (beg+1) s else beg -let index_non_spaces s = index_non_spaces_from 0 s +let rec non_index_from s beg c = + if s.[beg] = c then non_index_from s (beg+1) c else beg +let non_index s c = non_index_from s 0 c -let rec rindex_non_spaces_from beg s = - if s.[beg] = ' ' || s.[beg] = '\t' then rindex_non_spaces_from (beg-1) s else beg -let rindex_non_spaces s = rindex_non_spaces_from (String.length s - 1) s +let rec non_rindex_from s beg c = + if s.[beg] = c then non_rindex_from s (beg-1) c else beg +let non_rindex s c = non_rindex_from s (String.length s - 1) c let rec explode_string = function | "" -> [] |