@@ -448,35 +448,6 @@ let parse_result ?disable_w50 f fragment conf ~source ~input_name =
448
448
| exception exn -> Error (Error. Invalid_source {exn ; input_name})
449
449
| parsed -> Ok parsed
450
450
451
- let normalize_eol ~strlocs ~line_endings s =
452
- let buf = Buffer. create (String. length s) in
453
- let add_cr n = Buffer. add_string buf (String. init n ~f: (fun _ -> '\r' )) in
454
- let rec normalize_segment ~seen_cr i stop =
455
- if i = stop then add_cr seen_cr
456
- else
457
- match s.[i] with
458
- | '\r' -> normalize_segment ~seen_cr: (seen_cr + 1 ) (i + 1 ) stop
459
- | '\n' ->
460
- Buffer. add_string buf
461
- (match line_endings with `Crlf -> " \r\n " | `Lf -> " \n " ) ;
462
- normalize_segment ~seen_cr: 0 (i + 1 ) stop
463
- | c ->
464
- add_cr seen_cr ;
465
- Buffer. add_char buf c ;
466
- normalize_segment ~seen_cr: 0 (i + 1 ) stop
467
- in
468
- let rec loop locs i =
469
- match locs with
470
- | [] ->
471
- normalize_segment ~seen_cr: 0 i (String. length s) ;
472
- Buffer. contents buf
473
- | (start , stop ) :: xs ->
474
- normalize_segment ~seen_cr: 0 i start ;
475
- Buffer. add_substring buf s ~pos: start ~len: (stop - start) ;
476
- loop xs stop
477
- in
478
- loop strlocs 0
479
-
480
451
let parse_and_format (type a b ) (fg : a Extended_ast.t )
481
452
(std_fg : b Std_ast.t ) ?output_file ~input_name ~source (conf : Conf.t ) =
482
453
Location. input_name := input_name ;
@@ -493,7 +464,7 @@ let parse_and_format (type a b) (fg : a Extended_ast.t)
493
464
format fg std_fg ?output_file ~input_name ~prev_source: source ~parsed
494
465
~std_parsed conf
495
466
in
496
- Ok (normalize_eol ~strlocs ~line_endings formatted)
467
+ Ok (Eol_compat. normalize_eol ~exclude_locs: strlocs ~line_endings formatted)
497
468
498
469
let parse_and_format = function
499
470
| Syntax. Structure -> parse_and_format Structure Structure
0 commit comments