summaryrefslogtreecommitdiff
path: root/tools/ocamldep.ml
diff options
context:
space:
mode:
authorGabriel Scherer <gabriel.scherer@gmail.com>2014-10-03 20:31:32 +0000
committerGabriel Scherer <gabriel.scherer@gmail.com>2014-10-03 20:31:32 +0000
commitdfcccc7999587195625a71a2051c9d75673a9dfd (patch)
tree1bd8c0fa8f163c3b1bb9b66364fd578abdc27682 /tools/ocamldep.ml
parent230e723a8575db643c9d6744c7594e75e9f29281 (diff)
downloadocaml-dfcccc7999587195625a71a2051c9d75673a9dfd.tar.gz
minor refactoring in ocamldep.ml
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15467 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'tools/ocamldep.ml')
-rw-r--r--tools/ocamldep.ml13
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/ocamldep.ml b/tools/ocamldep.ml
index 59fecc412c..0ca6adb191 100644
--- a/tools/ocamldep.ml
+++ b/tools/ocamldep.ml
@@ -56,18 +56,21 @@ let readdir dir =
dirs := StringMap.add dir contents !dirs;
contents
+let add_to_list li s =
+ li := s :: !li
+
let add_to_load_path dir =
try
let dir = Misc.expand_directory Config.standard_library dir in
let contents = readdir dir in
- load_path := (dir, contents) :: !load_path
+ add_to_list load_path (dir, contents)
with Sys_error msg ->
Format.fprintf Format.err_formatter "@[Bad -I option: %s@]@." msg;
error_occurred := true
let add_to_synonym_list synonyms suffix =
if (String.length suffix) > 1 && suffix.[0] = '.' then
- synonyms := suffix :: !synonyms
+ add_to_list synonyms suffix
else begin
Format.fprintf Format.err_formatter "@[Bad suffix: '%s'@]@." suffix;
error_occurred := true
@@ -405,14 +408,14 @@ let print_version_num () =
let _ =
Clflags.classic := false;
- first_include_dirs := Filename.current_dir_name :: !first_include_dirs;
+ add_to_list first_include_dirs Filename.current_dir_name;
Compenv.readenv ppf Before_args;
Arg.parse [
"-absname", Arg.Set Location.absname,
" Show absolute filenames in error messages";
"-all", Arg.Set all_dependencies,
" Generate dependencies on all files";
- "-I", Arg.String (fun s -> Clflags.include_dirs := s :: !Clflags.include_dirs),
+ "-I", Arg.String (add_to_list Clflags.include_dirs),
"<dir> Add <dir> to the list of include directories";
"-impl", Arg.String (file_dependencies_as ML),
"<f> Process <f> as a .ml file";
@@ -430,7 +433,7 @@ let _ =
" Output one line per file, regardless of the length";
"-pp", Arg.String(fun s -> Clflags.preprocessor := Some s),
"<cmd> Pipe sources through preprocessor <cmd>";
- "-ppx", Arg.String(fun s -> first_ppx := s :: !first_ppx),
+ "-ppx", Arg.String (add_to_list first_ppx),
"<cmd> Pipe abstract syntax trees through preprocessor <cmd>";
"-slash", Arg.Set Clflags.force_slash,
" (Windows) Use forward slash / instead of backslash \\ in file paths";