From: David Allsopp <dra-news@metastack.com>
To: Yoriyuki Yamagata <yoriyuki.y@gmail.com>, Caml List <caml-list@inria.fr>
Subject: RE: [Caml-list] slight difference of behavior of OCaml on MinGw and Linux
Date: Mon, 28 Mar 2011 08:13:19 +0000 [thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D972A7048F@Remus.metastack.local> (raw)
In-Reply-To: <AANLkTimDaAs+BRAPFwtVm9WVJBNDUSy1Kmqpv8k14PkS@mail.gmail.com>
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
prev parent reply other threads:[~2011-03-28 8:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-28 7:32 Yoriyuki Yamagata
2011-03-28 8:13 ` David Allsopp [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E51C5B015DBD1348A1D85763337FB6D972A7048F@Remus.metastack.local \
--to=dra-news@metastack.com \
--cc=caml-list@inria.fr \
--cc=yoriyuki.y@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox