caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Bug somewhere...
@ 2002-10-06 22:57 Alessandro Baretta
  2002-10-06 23:06 ` Alessandro Baretta
  2002-10-07  8:03 ` Pierre Weis
  0 siblings, 2 replies; 6+ messages in thread
From: Alessandro Baretta @ 2002-10-06 22:57 UTC (permalink / raw)
  To: Ocaml

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-10-08 23:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-06 22:57 [Caml-list] Bug somewhere Alessandro Baretta
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).