1fun die s = 2 (TextIO.output(TextIO.stdErr, s ^ "\n"); 3 TextIO.flushOut TextIO.stdErr; 4 OS.Process.exit OS.Process.failure) 5 6fun usage() = 7 die ("Usage:\n " ^ CommandLine.name() ^ " file1 file2") 8 9fun openIn s = 10 BinIO.openIn s handle IO.Io _ => die ("Bad file: "^s) 11 12fun main() = let 13 val (file1, file2) = 14 case CommandLine.arguments() of 15 [f1, f2] => (f1, f2) 16 | _ => usage() 17 val is1 = openIn file1 18 val is2 = openIn file2 19 fun recurse () = let 20 val i1 = BinIO.inputN(is1, 1024) 21 handle IO.Io _ => die "File 1 had I/O error" 22 val i2 = BinIO.inputN(is2, 1024) 23 handle IO.Io _ => die "File 2 had I/O error" 24 in 25 if i1 = i2 then 26 if Word8Vector.length i1 > 0 then recurse() 27 else OS.Process.exit OS.Process.success 28 else OS.Process.exit OS.Process.failure 29 end 30in 31 recurse() 32end 33