[xiph-commits] r3244 - oogg/trunk
shans at svn.annodex.net
shans at svn.annodex.net
Mon Oct 1 23:39:03 PDT 2007
Author: shans
Date: 2007-10-01 23:39:03 -0700 (Mon, 01 Oct 2007)
New Revision: 3244
Modified:
oogg/trunk/crc.ml
oogg/trunk/crc.mli
oogg/trunk/file.ml
Log:
rejigged crc code
added F_TRUNC to file creation
Modified: oogg/trunk/crc.ml
===================================================================
--- oogg/trunk/crc.ml 2007-09-28 01:54:04 UTC (rev 3243)
+++ oogg/trunk/crc.ml 2007-10-02 06:39:03 UTC (rev 3244)
@@ -1,3 +1,4 @@
+open Types
let crc_lookup = [|
0x00000000L;0x04c11db7L;0x09823b6eL;0x0d4326d9L;
@@ -65,14 +66,18 @@
0xafb010b1L;0xab710d06L;0xa6322bdfL;0xa2f33668L;
0xbcb4666dL;0xb8757bdaL;0xb5365d03L;0xb1f740b4L |];;
+let crc_iter crc v =
+ Int64.logxor
+ (Int64.logand (Int64.shift_left crc 8) 0xFFFFFFFFL)
+ (crc_lookup.(Int64.to_int(
+ Int64.logxor
+ (Int64.logand (Int64.shift_right crc 24) 0xFFL)
+ (Int64.of_int v)))) ;;
+
+
let crc st =
let crc = ref 0L in
- let iterfun v =
- crc := Int64.logxor
- (Int64.logand (Int64.shift_left !crc 8) 0xFFFFFFFFL)
- (crc_lookup.(Int64.to_int(
- Int64.logxor
- (Int64.logand (Int64.shift_right !crc 24) 0xFFL)
- (Int64.of_int (Char.code v))))) in
+ let iterfun v = crc := crc_iter !crc (Char.code v) in
String.iter iterfun st; Types.int64_to_oogg32 !crc;;
-
+
+
Modified: oogg/trunk/crc.mli
===================================================================
--- oogg/trunk/crc.mli 2007-09-28 01:54:04 UTC (rev 3243)
+++ oogg/trunk/crc.mli 2007-10-02 06:39:03 UTC (rev 3244)
@@ -1 +1,3 @@
-val crc : string -> Types.oogg32
+val crc : string -> Types.oogg32;;
+
+
Modified: oogg/trunk/file.ml
===================================================================
--- oogg/trunk/file.ml 2007-09-28 01:54:04 UTC (rev 3243)
+++ oogg/trunk/file.ml 2007-10-02 06:39:03 UTC (rev 3244)
@@ -13,7 +13,7 @@
let file_open ?(writable=false) name =
if writable then
- Unix.openfile name [Unix.O_RDWR ; Unix.O_CREAT] 0o644
+ Unix.openfile name [Unix.O_RDWR ; Unix.O_CREAT ; Unix.O_TRUNC] 0o644
else
Unix.openfile name [Unix.O_RDONLY] 0o644;;
More information about the commits
mailing list