12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849openStdLabelsletpatdiff_cmd~use_color~extra_patdiff_args=letargs=List.concat[["-keep-whitespace"];["-location-style omake"];(ifuse_colorthen[]else["-ascii"]);extra_patdiff_args;]inString.concat~sep:" "("patdiff"::args)letprint?diff_command?(extra_patdiff_args=[])?(use_color=false)~file1~file2()=letexeccmd=letcmd=Printf.sprintf"%s %s %s 1>&2"cmd(Filename.quotefile1)(Filename.quotefile2)inmatchSys.commandcmdwith|0->`Same|1->`Different|n->`Error(n,cmd)inmatchdiff_commandwith|Somes->ignore(execs:[>`Same|`Different|`Errorofint*string])|None->(matchexec(patdiff_cmd~use_color~extra_patdiff_args)with|`Same->(* patdiff produced no output, fallback to diff -u *)Printf.eprintf"File \"%s\", line 1, characters 0-0:\n%!"file1;ignore(exec"diff -u":[>`Same|`Different|`Errorofint*string])|`Different->(* patdiff successfully found a difference *)()|`Error(err_code,cmd)->(* patdiff threw an error... perhaps it wasn't installed? fallback to diff -u *)Printf.eprintf"Error:\n\
> %S exited with code %d\n\
> Perhaps patdiff is not installed? Hint, try: opam install patdiff\n\
> Falling back to diff -u\n\n"cmderr_code;Printf.eprintf"File \"%s\", line 1, characters 0-0:\n%!"file1;ignore(exec"diff -u":[>`Same|`Different|`Errorofint*string]))