PageRenderTime 50ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/lib_test/unison.ml

http://github.com/avsm/ocaml-re
OCaml | 180 lines | 170 code | 7 blank | 3 comment | 4 complexity | 26a615b387883f1086058455a8946336 MD5 | raw file
Possible License(s): LGPL-2.1
  1. let desc =
  2. [ `Path "lablgtk-1.00/config.make";
  3. `Path "lablgtk-1.00/lablgtktop_t";
  4. `Path "lablgtk-1.00/lablgtktop";
  5. `Path "lablgtk-1.00/lablgtkrun";
  6. `Path "lablgtk-1.00/lablgtk";
  7. `Path "unison3/src/unison";
  8. `Name "core";
  9. `Path "lipe/caisse/val_parse.h";
  10. `Path "lipe/caisse/val_parse.c";
  11. `Path "lipe/caisse/val_lex.c";
  12. `Path "lipe/caisse/caisse";
  13. `Path "lipe/runtime";
  14. `Path "lipe/demo";
  15. `Path "unison2/doc/unison-manual.ps";
  16. `Path "unison/doc/unison-mal.ps";
  17. `Name "*.ppi";
  18. `Path "unison2/src/unison";
  19. `Path "Xduce/xduce/pref.ml";
  20. `Path "Xduce/xduce/xduce{,.opt}";
  21. `Path "unison/src/TAGS";
  22. `Path "unison/src/unison";
  23. `Name "*.old";
  24. `Name "#*#";
  25. `Name "*.cm{i,o,x,a,xa}";
  26. `Name "*.vo";
  27. `Name "*{~,.aux,.bbl,.blg,.log,.toc,.o,.a}";
  28. `Name "gmon.out";
  29. `Name "ocamlprof.dump";
  30. `Name "CVS";
  31. `Name ".*.prcs_aux";
  32. `Path "icfp2000/tools/src2tex";
  33. `Path "icfp2000/temp.dvi";
  34. `Path "icfp2000/main.dvi";
  35. `Path "icfp2000/whole.dvi";
  36. `Path "icfp2000/regsub.ps";
  37. `Path "Views/main.dvi";
  38. `Path "lipe/perso/caisse";
  39. `Name "obsolete";
  40. `Path "misc/fingerprint/cksum/cksum";
  41. `Path "misc/relay/relay";
  42. `Path "Xduce/xduce.current/xduce.opt";
  43. `Path "Xduce/xduce.current/pref.ml";
  44. `Path "Xduce/xduce.new/pref.ml";
  45. `Path "Xduce/xduce.new/xduce.opt";
  46. `Path "profiler/profiler";
  47. `Path "ocaml/boot/Saved";
  48. `Path "ocaml/byterun/ocamlrun";
  49. `Path "ocaml/config/Makefile";
  50. `Path "ocaml/config/m.h";
  51. `Path "ocaml/config/s.h";
  52. `Path "ocaml/expunge";
  53. `Path "ocaml/asmcomp/arch.ml";
  54. `Path "ocaml/asmcomp/emit.ml";
  55. `Path "ocaml/asmcomp/proc.ml";
  56. `Path "ocaml/asmcomp/reload.ml";
  57. `Path "ocaml/asmcomp/scheduling.ml";
  58. `Path "ocaml/asmcomp/selection.ml";
  59. `Path "ocaml/debugger/ocamldebug";
  60. `Path "ocaml/lex/ocamllex";
  61. `Path "ocaml/ocaml";
  62. `Path "ocaml/ocamlc";
  63. `Path "ocaml/ocamlopt";
  64. `Path "ocaml/otherlibs/dynlink/extract_crc";
  65. `Path "ocaml/otherlibs/labltk/browser/ocamlbrowser";
  66. `Path "ocaml/otherlibs/labltk/compiler/tkcompiler";
  67. `Path "ocaml/otherlibs/str/regex-0.12/config.status";
  68. `Path "ocaml/stdlib/camlheader";
  69. `Path "ocaml/tools/cvt_emit";
  70. `Path "ocaml/boot/camlheader";
  71. `Path "ocaml/boot/ocamlrun";
  72. `Path "ocaml/boot/ocamlyacc";
  73. `Path "ocaml/otherlibs/labltk/lib/.depend";
  74. `Path "ocaml/otherlibs/labltk/lib/labltk";
  75. `Path "ocaml/otherlibs/labltk/lib/labltktop";
  76. `Path "ocaml/otherlibs/labltk/lib/tk.ml";
  77. `Path "ocaml/tools/ocamlcp";
  78. `Path "ocaml/tools/ocamldep";
  79. `Path "ocaml/tools/ocamlmktop";
  80. `Path "ocaml/tools/ocamlprof";
  81. `Path "ocaml/utils/config.ml";
  82. `Path "ocaml/yacc/ocamlyacc";
  83. `Path "Xduce/interleave/tools/src2tex";
  84. `Path "xml/parser";
  85. `Path "ocaml/ocamlopt.opt";
  86. `Path "ocaml/boot/ocamlc";
  87. `Path "ocaml/boot/ocamllex";
  88. `Path "ocaml/ocamlc.opt";
  89. `Path "specs/tools/src2f";
  90. `Path "specs/tools/src2tex" ]
  91. let paths =
  92. [ "These";
  93. "Xduce";
  94. "unison";
  95. "unison2";
  96. "unison3";
  97. "tinkertype";
  98. "lipe";
  99. "icfp2000";
  100. "Views";
  101. "sync";
  102. "misc";
  103. "lablgtk-1.00";
  104. "mydb";
  105. "yacc";
  106. "db-papers";
  107. "submissions";
  108. "xml";
  109. "profiler";
  110. "specs";
  111. "ocaml";
  112. "rx" ]
  113. let rec children p =
  114. let rec loop ch dir =
  115. try
  116. let file = Unix.readdir dir in
  117. let ch' =
  118. if file = "." || file = ".." then
  119. ch
  120. else
  121. file :: ch in
  122. loop ch' dir
  123. with End_of_file ->
  124. ch
  125. in
  126. let dir = Unix.opendir p in
  127. let result = loop [] dir in
  128. Unix.closedir dir;
  129. result
  130. let is_dir p =
  131. try
  132. (Unix.lstat p).Unix.st_kind = Unix.S_DIR
  133. with Unix.Unix_error _ ->
  134. false
  135. let prefix ="/home/jerome/"
  136. let count = ref 0
  137. let hit = ref 0
  138. let rec visit rx p =
  139. (*incr count; if !count > 0 then raise Exit;*)
  140. try
  141. incr count;
  142. ignore (Re.exec ~group:false rx p);
  143. (*Format.eprintf "-%s@." p*)
  144. with Not_found ->
  145. (*Format.eprintf "+%s@." p;*)
  146. let fp = prefix ^ p in
  147. incr hit;
  148. if is_dir fp then
  149. List.iter (fun n -> visit rx (p ^ "/" ^ n)) (children fp)
  150. let _ =
  151. for i = 0 to 9 do
  152. count := 0; hit := 0;
  153. let rx =
  154. Re.seq
  155. [ Re.bos;
  156. Re.alt
  157. (List.map
  158. (fun p ->
  159. match p with
  160. `Path s ->
  161. Re_glob.globx s
  162. | `Name s ->
  163. Re.seq [Re.no_group (Re_posix.re "(.*/)?");
  164. Re_glob.globx s])
  165. desc);
  166. Re.eos ]
  167. in
  168. let rx = Re.compile rx in
  169. begin try
  170. List.iter (fun p -> visit rx p) paths
  171. with Exit -> () end;
  172. Format.eprintf "%d/%d@." !hit !count;
  173. done