From 29fdaf2ba9b7cd3bd1324c28d82ca39621d858f5 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 3 Dec 1996 15:51:53 +0000 Subject: [PATCH] Utiliser le mode texte pour copier les morceaux de l'entree vers la sortie (evite les \r\r\n a la fin des lignes sous Windows). git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1213 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- lex/main.ml | 10 ++++++---- lex/output.ml | 11 +++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lex/main.ml b/lex/main.ml index cd7d02e6c..3f5a6252e 100644 --- a/lex/main.ml +++ b/lex/main.ml @@ -28,9 +28,10 @@ let main () = Filename.chop_suffix source_name ".mll" ^ ".ml" else source_name ^ ".ml" in - let ic = open_in_bin source_name in + let ic_bin = open_in_bin source_name in + let ic_txt = open_in source_name in let oc = open_out dest_name in - let lexbuf = Lexing.from_channel ic in + let lexbuf = Lexing.from_channel ic_bin in let def = try Parser.lexer_definition Lexer.main lexbuf @@ -53,8 +54,9 @@ let main () = exit 2 in let (entries, transitions) = Lexgen.make_dfa def in let tables = Compact.compact_tables transitions in - Output.output_lexdef ic oc def.header tables entries def.trailer; - close_in ic; + Output.output_lexdef ic_txt oc def.header tables entries def.trailer; + close_in ic_bin; + close_in ic_txt; close_out oc let _ = Printexc.catch main (); exit 0 diff --git a/lex/output.ml b/lex/output.ml index 5ffb3b8c0..82e17af83 100644 --- a/lex/output.ml +++ b/lex/output.ml @@ -20,16 +20,11 @@ open Compact (* To copy the ML code fragments *) -let copy_buffer = String.create 1024 - let copy_chunk ic oc (Location(start,stop)) = seek_in ic start; - let n = ref (stop - start) in - while !n > 0 do - let m = input ic copy_buffer 0 (min !n 1024) in - output oc copy_buffer 0 m; - n := !n - m - done + let buffer = String.create (stop - start) in + let r = input ic buffer 0 (stop - start) in + output oc buffer 0 r (* To output an array of short ints, encoded as a string *)