From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA29326; Fri, 9 Aug 2002 14:45:41 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA29250 for ; Fri, 9 Aug 2002 14:45:40 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g79CjYr23164; Fri, 9 Aug 2002 14:45:34 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA28927; Fri, 9 Aug 2002 14:45:33 +0200 (MET DST) Date: Fri, 9 Aug 2002 14:45:33 +0200 From: Xavier Leroy To: Oleg Cc: caml-list@inria.fr Subject: Re: [Caml-list] undo_input_line Message-ID: <20020809144533.A29080@pauillac.inria.fr> References: <200208080713.DAA00472@dewberry.cc.columbia.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <200208080713.DAA00472@dewberry.cc.columbia.edu>; from oleg_inconnu@myrealbox.com on Thu, Aug 08, 2002 at 03:14:08AM -0400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Does `let s = input_line ic` always increment `pos_in ic` by > `String.length s + 1` ? Only if "ic" is in binary mode. In text mode, conversions may happen during reading (e.g. under Windows, removal of the final \r) that invalidate this claim. > So, if I define a function > let undo_input_line ic s = > seek_in ic (pos_in ic - String.length s - 1);; > will it always work as expected, or will this depend on I/O mode (binary vs > text) and file format (DOS vs UNIX)? To "undo" an input, I'd recommend doing "let p = pos_in ic" before the read, performing the read, and doing "seek_in ic p" to undo the read. This will be a lot more robust. - Xavier Leroy ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners