changelog shortlog tags branches changeset file revisions annotate raw help

Mercurial > hg > ventivac / appl/lib/rabin.b

revision 115: 1c52c2978769
parent 100: a332f10eb972
child 144: 207beea1188c
     1.1--- a/appl/lib/rabin.b	Fri Aug 17 21:47:20 2007 +0200
     1.2+++ b/appl/lib/rabin.b	Fri Aug 17 21:58:58 2007 +0200
     1.3@@ -7,7 +7,7 @@
     1.4 	Iobuf, EOF, ERROR: import bufio;
     1.5 include "rabin.m";
     1.6 
     1.7-print, sprint, fprint, fildes: import sys;
     1.8+sprint: import sys;
     1.9 
    1.10 init(b: Bufio)
    1.11 {
    1.12@@ -26,15 +26,9 @@
    1.13 Rcfg.mk(prime, width, mod: int): (ref Rcfg, string)
    1.14 {
    1.15 	rcfg := ref Rcfg(prime, width, mod, array[256] of int);
    1.16-
    1.17 	power := modpower(prime, width, mod);
    1.18-if(debug) say(sprint("power=%d", power));
    1.19-
    1.20-	for(i := 0; i < 256; i++) {
    1.21+	for(i := 0; i < 256; i++)
    1.22 		rcfg.tab[i] = (i * power) % mod;
    1.23-if(debug) say(sprint("tab[%d] = %d", i, rcfg.tab[i]));
    1.24-	}
    1.25-if(debug) say(sprint("mod=%d prime=%d width=%d", rcfg.mod, rcfg.prime, rcfg.width));
    1.26 	return (rcfg, nil);
    1.27 }
    1.28 
    1.29@@ -47,8 +41,6 @@
    1.30 		return (nil, "min < width");
    1.31 	c := ref Rfile(b, rcfg, min, max, array[max+rcfg.width] of byte, 0, 0, big 0);
    1.32 
    1.33-if(debug) say(sprint("min=%d max=%d", min, max));
    1.34-
    1.35 	(prime, width, mod) := (c.rcfg.prime, c.rcfg.width, c.rcfg.mod);
    1.36 	while(c.n < width) {
    1.37 		ch := c.b.getb();
    1.38@@ -57,11 +49,9 @@
    1.39 		if(ch == EOF)
    1.40 			break;
    1.41 		c.buf[c.n] = byte ch;
    1.42-if(debug) say(sprint("i=%d prev=%d width=%d data[i]=%d prime=%d mod=%d", c.n, c.state, width, int c.buf[c.n], prime, mod));
    1.43 		c.state = (prime*c.state + ch) % mod;
    1.44 		c.n++;
    1.45 	}
    1.46-if(debug) say(sprint("initial state=%d", c.state));
    1.47 	return (c, nil);
    1.48 }
    1.49 
    1.50@@ -93,10 +83,3 @@
    1.51 		}
    1.52 	}
    1.53 }
    1.54-
    1.55-
    1.56-say(s: string)
    1.57-{
    1.58-	if(debug)
    1.59-		sys->fprint(sys->fildes(2), "%s\n", s);
    1.60-}