diff options
author | 2018-12-29 14:31:32 -0500 | |
---|---|---|
committer | 2018-12-29 14:31:32 -0500 | |
commit | 2708a015fcf65f72328be4296a00dd32b1f1c17a (patch) | |
tree | 696f9b5fb84817e1a5c8d9271976a92e25aef18a /tools/md5sum.ml | |
parent | d7d80c5bea564b7cb0eadc33e9ee38c9d9de1cd8 (diff) | |
parent | 9043add656177eeac1491a73d2f3ab92bec0013c (diff) |
Updated version 8.8.2 from 'upstream/8.8.2'
with Debian dir a16bcf46abacaf1a684eda04f02555c984bf540d
Diffstat (limited to 'tools/md5sum.ml')
-rw-r--r-- | tools/md5sum.ml | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/md5sum.ml b/tools/md5sum.ml new file mode 100644 index 00000000..2fdcacc8 --- /dev/null +++ b/tools/md5sum.ml @@ -0,0 +1,24 @@ +let get_content file = + let ic = open_in_bin file in + let buf = Buffer.create 2048 in + let rec fill () = + match input_char ic with + | '\r' -> fill () (* NOTE: handles the case on Windows where the + git checkout has included return characters. + See: https://github.com/coq/coq/pull/6305 *) + | c -> Buffer.add_char buf c; fill () + | exception End_of_file -> close_in ic; Buffer.contents buf + in + fill () + +let () = + match Sys.argv with + | [|_; file|] -> + let content = get_content file in + let md5 = Digest.to_hex (Digest.string content) in + print_string (md5 ^ " " ^ file) + | _ -> + prerr_endline "Error: This program needs exactly one parameter."; + prerr_endline "Usage: ocaml md5sum.ml <FILE>"; + prerr_endline "Print MD5 (128-bit) checksum of the file content modulo \\r."; + exit 1 |