From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p2S8DQiu020061 for ; Mon, 28 Mar 2011 10:13:29 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApUCAPlBkE1RZ90xkWdsb2JhbACEQ6AgZxQBAQEBCQsLBxQDIrEFj2uBJ4NLdwSMdw X-IronPort-AV: E=Sophos;i="4.63,253,1299452400"; d="scan'208";a="95126135" Received: from mtaout03-winn.ispmail.ntl.com ([81.103.221.49]) by mail2-smtp-roc.national.inria.fr with ESMTP; 28 Mar 2011 10:13:29 +0200 Received: from aamtaout04-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20110328081328.JJRY13167.mtaout03-winn.ispmail.ntl.com@aamtaout04-winn.ispmail.ntl.com>; Mon, 28 Mar 2011 09:13:28 +0100 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout04-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20110328081328.SONM25656.aamtaout04-winn.ispmail.ntl.com@romulus.metastack.com>; Mon, 28 Mar 2011 09:13:28 +0100 Received: from remus.metastack.local ([172.16.0.1]) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id p2S8DKbr023687 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Mon, 28 Mar 2011 09:13:20 +0100 Received: from Remus.metastack.local ([fe80::547c:3c42:e1da:eda2]) by Remus.metastack.local ([fe80::547c:3c42:e1da:eda2%11]) with mapi; Mon, 28 Mar 2011 09:13:20 +0100 From: David Allsopp To: Yoriyuki Yamagata , Caml List Thread-Topic: [Caml-list] slight difference of behavior of OCaml on MinGw and Linux Thread-Index: AQHL7RpS5UlsE6cCPUKaEOF7twRzUJRCY18A Date: Mon, 28 Mar 2011 08:13:19 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Organization: MetaStack Solutions Ltd. X-Scanned-By: MIMEDefang 2.65 on 81.102.132.77 X-Cloudmark-Analysis: v=1.1 cv=R50lirqlHffDPPkwUlkuVa99MrvKdVWo//yz83qex8g= c=1 sm=0 a=dqk9uwSiTX4A:10 a=IkcTkHD0fZMA:10 a=xqWC_Br6kY4A:10 a=gIIdx2dYpB0IU4ymYdAA:9 a=sktHS-nqSpRU_ELlMzUA:7 a=oKTT2YOTZWk9xdZ7W5rsDF9P3N4A:4 a=QEXdDO2ut3YA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by walapai.inria.fr id p2S8DQiu020061 Subject: RE: [Caml-list] slight difference of behavior of OCaml on MinGw and Linux Yoriyuki Yamagata wrote: > Hi, list. > > I think I found a slight difference of behavior of > OCaml on MinGW and Linux regarding the EOF character. > On Linux, the EOF char in the middle of a file is > ignored, but on MinGW, the attempt to read EOF causes > End_of_file Exception.  Is this a supposed behavior?  I think you're simply seeing the underlying difference in handling of EOF between Unix and Windows - files in text mode on Windows are terminated by an EOF character but this is not the case on Unix. > (ok, I have found some discussion on EOF on beginners > list, but cannot find something exactly answering this problem.) > > I attached an ocaml program (which is simply a cat) and a file > which reproduce the problem.  On Linux, doing > ocaml testEoF.ml < UTF-32#LE > outputs the whole file before the exception End_of_file, but > on MinGW, the script fails in the middle of Etruscan text, > which happens to contain 0x1a character. You can make this work by calling set_binary_mode_in stdin before you start but you'll have to handle end-of-line marker differences manually in your code (in my experience of writing cross-platform text processing programs in OCaml, this is necessary anyway as if you read a file on Unix which happens to use Windows end-of-line markers then you probably aren't actually after each line ending with \r which is what you'll get) David