···1717 match c with
1818 '\n' ->
1919 incr lines; count Outside_word
2020+ | '\r' ->
2121+ (* Ignore \r to cater for CRLF vs LF checkouts *)
2222+ decr chars; count Outside_word
2023 | ' ' | '\t' ->
2124 count Outside_word
2225 | _ ->
···2932 ()
30333134let count_file name =
3232- let ic = open_in name in
3535+ let ic = open_in_bin name in
3336 count_channel ic;
3437 close_in ic
3538
···5757 gsub("1 match found in /(.*):$", "1 match found in \"XXXX\":")
58585959 # Remove trailing blanks
6060- gsub(/[ \t]+$/, "")
6060+ gsub(/[ \t\r]+$/, "")
61616262 if ($0 != "")
6363 print $0
···66}
7788let ws = [' ''\t']
99-let nl = '\n'
99+let eol = '\r'? '\n'
1010+let to_eol = [^'\n']* eol
1011let constr = ['A'-'Z']['a'-'z''A'-'Z''0'-'9''_']*
1112let int = ['0'-'9']+
1213let mnemo = ['a'-'z']['a'-'z''-']*['a'-'z']
13141415rule seek_let_number_function = parse
1515-| ws* "let" ws+ "number" ws* "=" ws* "function" ws* '\n'
1616+| ws* "let" ws+ "number" ws* "=" ws* "function" ws* eol
1617 { () }
1717-| [^'\n']* '\n'
1818+| to_eol
1819 { seek_let_number_function lexbuf }
19202021and constructors = parse
2121-| ws* '|' ws* (constr as c) (ws* '_')? ws* "->" ws* (int as n) [^'\n']* '\n'
2222+| ws* '|' ws* (constr as c) (ws* '_')? ws* "->" ws* (int as n) to_eol
2223 { (c, int_of_string n) :: constructors lexbuf }
2323-| ws* ";;" ws* '\n'
2424+| ws* ";;" ws* eol
2425 { [] }
25262627and mnemonics = parse
2727-| ws* (int as n) ws+ '[' (mnemo as s) ']' [^'\n']* '\n'
2828+| ws* (int as n) ws+ '[' (mnemo as s) ']' to_eol
2829 { (s, int_of_string n) :: mnemonics lexbuf }
2929-| [^'\n']* '\n'
3030+| to_eol
3031 { mnemonics lexbuf }
3132| eof
3233 { [] }
···3738let ocamlrun = Sys.getenv "ocamlrun"
38393940let constructors =
4040- let ic = open_in Filename.(concat ocamlsrcdir (concat "utils" "warnings.ml")) in
4141+ let ic =
4242+ open_in_bin Filename.(concat ocamlsrcdir (concat "utils" "warnings.ml"))
4343+ in
4144 Fun.protect ~finally:(fun () -> close_in_noerr ic)
4245 (fun () ->
4346 let lexbuf = Lexing.from_channel ic in
···5356 ocamlrun [concat ocamlsrcdir "ocamlc"; "-warn-help"])
5457 in
5558 assert (n = 0);
5656- let ic = open_in stdout in
5959+ let ic = open_in_bin stdout in
5760 Fun.protect ~finally:(fun () -> close_in_noerr ic)
5861 (fun () ->
5962 let lexbuf = Lexing.from_channel ic in
···7477 | true, false -> ()
7578 | false, true -> ()
7679 | false, false ->
7777- Printf.printf "Could not find constructor corresponding to mnemonic %S (%d)\n%!" s n
8080+ Printf.printf
8181+ "Could not find constructor corresponding to mnemonic %S (%d)\n%!" s n
7882 | true, true ->
7979- Printf.printf "Found constructor for deprecated warnings %S (%d)\n%!" s n
8383+ Printf.printf
8484+ "Found constructor for deprecated warnings %S (%d)\n%!" s n
8085 ) mnemonics
81868287let _ =
+9-1
tools/ocamltex.ml
···587587 | a :: q -> String.concat ~sep:"\n " ((toplevel_prompt^a)::q)
588588589589let process_file file =
590590- let ic = try open_in file with _ -> failwith "Cannot read input file" in
590590+ let ic = try open_in_bin file with _ -> failwith "Cannot read input file" in
591591+ let input_line ic =
592592+ let line = input_line ic in
593593+ let last = String.length line - 1 in
594594+ if last >= 0 && line.[last] = '\r' then
595595+ String.sub line 0 last
596596+ else
597597+ line
598598+ in
591599 let phrase_start = ref 1 and phrase_stop = ref 1 in
592600 let incr_phrase_start () =
593601 incr phrase_start;