Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Bug somewhere...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alessandro Baretta <alex@b...>
Subject: [Caml-list] Bug somewhere...
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