From: Alessandro Baretta <alex@baretta.com>
To: Ocaml <caml-list@inria.fr>
Subject: [Caml-list] Bug somewhere...
Date: Mon, 07 Oct 2002 00:57:37 +0200 [thread overview]
Message-ID: <3DA0BFE1.9050302@baretta.com> (raw)
It's either on my brain or in the Scanf module, the former
possibility being definitely more likely.
I have written a very simple program to compute md5
checksums of a codes taken from a text file. Here it is:
let scan_line () = Scanf.scanf "%[^\n\r]\n" (fun a -> a)
let digest s = String.uppercase
(Digest.to_hex(Digest.string s))
let digest_line s = print_endline (s ^ "#" ^ (digest s))
let _ = try while true do digest_line (scan_line ()) done
with End_of_file -> ()
Seems very reasonable...
Here's the input file:
(2002) DMD.CSB.1GL.001.01
(2002) DMD.CSB.1GL.001.02
(2002) DMD.CSB.1GL.001.03
(2002) DMD.CSB.1GL.001.04
(2002) DMD.CSB.1GL.001.05
(2002) DMD.CSB.1GL.001.06
(2002) DMD.CSB.1GL.001.07
(2002) DMD.CSB.1GL.001.08
(2002) DMD.CSB.1GL.001.09
(2002) DMD.CSB.1GL.001.10
(2002) DMD.CSB.1GL.001.11
(2002) DMD.CSB.1GL.001.12
(2002) DMD.CSB.1GL.001.13
(2002) DMD.CSB.1GL.001.14
(2002) DMD.CSB.1GL.001.15
(2002) DMD.CSB.1GL.001.16
(2002) DMD.CSB.1GL.001.17
(2002) DMD.CSB.1GL.001.18
(2002) DMD.CSB.1GL.001.19
(2002) DMD.CSB.1GL.001.20
Now here's the output file:
(2002) DMD.CSB.1GL.001.01#EA486F3F11C1D1E5BE6DDC2A444BC4E1
2002) DMD.CSB.1GL.001.02#4A3E838023756A5EE01C39D5DD02FC07
2002) DMD.CSB.1GL.001.03#605ED19A81C3B7748494038FEE93671A
2002) DMD.CSB.1GL.001.04#F475498E61CC896FA42B3869858B9B69
2002) DMD.CSB.1GL.001.05#60246106058EA46F7C5904F9A7D69FD7
2002) DMD.CSB.1GL.001.06#3FDF89041B44A8A3F5334B500A8B48A0
2002) DMD.CSB.1GL.001.07#657A508D402845454D5EAF0A2BC8380B
2002) DMD.CSB.1GL.001.08#230BDE6A530043CCB01434A6E19DB10E
2002) DMD.CSB.1GL.001.09#39CA6A302A6DE081DFC3BD24C8D4C38E
2002) DMD.CSB.1GL.001.10#BFBAE55D0808B5A8729E23459E45A617
2002) DMD.CSB.1GL.001.11#001F0B9F7F5EEDE05C8BA5A85F7D0F45
2002) DMD.CSB.1GL.001.12#77AB75131372E7FB723B280E084733B0
2002) DMD.CSB.1GL.001.13#1E605246D240D6B5735CDE40FF4614CC
2002) DMD.CSB.1GL.001.14#40970C955978A228AA308AB1B1169800
2002) DMD.CSB.1GL.001.15#7DED9C18A5700389CE670C9E8474C757
2002) DMD.CSB.1GL.001.16#8D396925D7867AF0BF2169B692EAECFF
2002) DMD.CSB.1GL.001.17#DEE78191DEF1E6BA7144AA14E29B8EE6
2002) DMD.CSB.1GL.001.18#F6E082FFD976B0A6721AC056C40C526E
2002) DMD.CSB.1GL.001.19#34F915DBF5B258C7BD4200C753C42BD1
2002) DMD.CSB.1GL.001.20#D310054DE7CF959F5946FABAF561FBEF
The '(' is only present on the first line, indicating--so it
seems--that scanf is eating-away one more character than it
should every time.
Do I need brain surgery or is there really a problem with scanf?
Alex
-------------------
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
next reply other threads:[~2002-10-06 22:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-06 22:57 Alessandro Baretta [this message]
2002-10-06 23:06 ` Alessandro Baretta
2002-10-08 20:07 ` Pierre Weis
2002-10-08 21:26 ` Eric C. Cooper
2002-10-08 23:31 ` Alessandro Baretta
2002-10-07 8:03 ` Pierre Weis
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=3DA0BFE1.9050302@baretta.com \
--to=alex@baretta.com \
--cc=caml-list@inria.fr \
/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