changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > ventivac / changeset: allow command-line to specify module path for rabin module.

changeset 99: a1ab045f1634
parent 98: 00a4a965e43e
child 100: a332f10eb972
author: Mechiel Lukkien <mechiel@ueber.net>
date: Mon, 06 Aug 2007 17:09:06 +0200
files: appl/cmd/testrabin.b
description: allow command-line to specify module path for rabin module.
     1.1--- a/appl/cmd/testrabin.b	Mon Aug 06 17:03:33 2007 +0200
     1.2+++ b/appl/cmd/testrabin.b	Mon Aug 06 17:09:06 2007 +0200
     1.3@@ -16,6 +16,7 @@
     1.4 Rcfg, Rfile: import rabin;
     1.5 
     1.6 dflag, vflag: int;
     1.7+modfile: string;
     1.8 
     1.9 Testrabin: module {
    1.10 	init:	fn(nil: ref Draw->Context, nil: list of string);
    1.11@@ -27,10 +28,6 @@
    1.12 	arg := load Arg Arg->PATH;
    1.13 	bufio = load Bufio Bufio->PATH;
    1.14 	keyring = load Keyring Keyring->PATH;
    1.15-	rabin = load Rabin Rabin->PATH;
    1.16-	if(rabin == nil)
    1.17-		fail(sprint("loading module rabin %s: %r", Rabin->PATH));
    1.18-	rabin->init(bufio);
    1.19 
    1.20 	p := 269;
    1.21 	m := 8*1024;
    1.22@@ -38,12 +35,15 @@
    1.23 	min := 1024;
    1.24 	max := 32*1024;
    1.25 
    1.26+	modfile = Rabin->PATH;
    1.27+
    1.28 	arg->init(args);
    1.29-	arg->setusage(arg->progname()+" [-dv] [-p prime] [-n width] [-m mod] [-s min] [-S max] file");
    1.30+	arg->setusage(arg->progname()+" [-dv] [-f rabin.dis] [-p prime] [-n width] [-m mod] [-s min] [-S max] file");
    1.31 	while((c := arg->opt()) != 0)
    1.32 		case c {
    1.33 		'd' =>	dflag++;
    1.34 		'v' =>	vflag++;
    1.35+		'f' =>	modfile = arg->earg();
    1.36 		'p' =>	p = int arg->earg();
    1.37 		'n' =>	n = int arg->earg();
    1.38 		'm' =>	m = int arg->earg();
    1.39@@ -53,6 +53,11 @@
    1.40 		}
    1.41 	args = arg->argv();
    1.42 
    1.43+	rabin = load Rabin modfile;
    1.44+	if(rabin == nil)
    1.45+		fail(sprint("loading module rabin %s: %r", modfile));
    1.46+	rabin->init(bufio);
    1.47+
    1.48 	if(len args != 1)
    1.49 		arg->usage();
    1.50 	rabin->debug = dflag;