summaryrefslogtreecommitdiff
path: root/appl/lib
diff options
context:
space:
mode:
Diffstat (limited to 'appl/lib')
-rw-r--r--appl/lib/chanfill.b34
-rw-r--r--appl/lib/dis.b2
-rw-r--r--appl/lib/mkfile3
-rw-r--r--appl/lib/newns.b16
-rw-r--r--appl/lib/pop3.b14
-rw-r--r--appl/lib/sets.b2
-rw-r--r--appl/lib/sets32.b2
-rw-r--r--appl/lib/venti.b6
-rw-r--r--appl/lib/w3c/mkfile2
-rw-r--r--appl/lib/w3c/xpointers.b2
-rw-r--r--appl/lib/xml.b21
11 files changed, 55 insertions, 49 deletions
diff --git a/appl/lib/chanfill.b b/appl/lib/chanfill.b
index 7e7d2685..6f326ea6 100644
--- a/appl/lib/chanfill.b
+++ b/appl/lib/chanfill.b
@@ -32,25 +32,21 @@ init(data: array of byte, f: int, c: Sys->Rwrite, r: ref Sys->FileIO, b: Bufio):
fill(b: ref Iobuf): int
{
for (;;) {
- alt {
- (nil, data, f, c) := <-fio.write =>
- if (f != fid) {
- if (c != nil)
- c <-= (0, "file busy");
- continue;
- }
- if (c == nil)
- return Bufio->EOF;
- c <-= (len data, nil);
- i := len data;
- if (i == 0)
- continue;
- b.buffer[b.size:] = data;
- b.size += i;
- b.filpos += big i;
- return i;
- * =>
- return Bufio->EOF;
+ (nil, data, f, c) := <-fio.write;
+ if (f != fid) {
+ if (c != nil)
+ c <-= (0, "file busy");
+ continue;
}
+ if (c == nil)
+ return Bufio->EOF;
+ c <-= (len data, nil);
+ i := len data;
+ if (i == 0)
+ continue;
+ b.buffer[b.size:] = data;
+ b.size += i;
+ b.filpos += big i;
+ return i;
}
}
diff --git a/appl/lib/dis.b b/appl/lib/dis.b
index f64fd162..c907df61 100644
--- a/appl/lib/dis.b
+++ b/appl/lib/dis.b
@@ -318,7 +318,7 @@ loadobj(disfile: string): (ref Mod, string)
reals := array[n] of real;
for(i = 0; i < n; i++)
reals[i] = math->bits64real(getl());
- dat = ref Data.Reals(op, n, offset, nil);
+ dat = ref Data.Reals(op, n, offset, reals);
} else {
disptr += 8*n; # skip it
dat = ref Data.Reals(op, n, offset, nil);
diff --git a/appl/lib/mkfile b/appl/lib/mkfile
index 210e2f74..f414732d 100644
--- a/appl/lib/mkfile
+++ b/appl/lib/mkfile
@@ -25,6 +25,7 @@ TARG=\
cfgfile.dis\
chanfill.dis\
crc.dis\
+ csv.dis\
daytime.dis\
db.dis\
dbm.dis\
@@ -221,3 +222,5 @@ dhcpclient.dis: $ROOT/module/dhcp.m
ubfa.dis: $ROOT/module/ubfa.m
secstore.dis: $ROOT/module/secstore.m
ida.dis: $ROOT/module/ida.m
+rfc822.dis: $ROOT/module/rfc822.m
+csv.dis: $ROOT/module/csv.m
diff --git a/appl/lib/newns.b b/appl/lib/newns.b
index 7bca18dc..c0868b3c 100644
--- a/appl/lib/newns.b
+++ b/appl/lib/newns.b
@@ -39,6 +39,9 @@ include "factotum.m";
include "arg.m";
arg: Arg;
+include "string.m";
+ str: String;
+
newns(user: string, file: string): string
{
sys = load Sys Sys->PATH;
@@ -63,6 +66,8 @@ newns(user: string, file: string): string
if(err != nil)
return "Auth->init: "+err;
+ str = load String String->PATH; # no check, because we'll live without it
+
if(file == nil){
file = "namespace";
if(sys->stat(file).t0 < 0)
@@ -87,8 +92,11 @@ nsfile(b: ref Iobuf, facfd: ref Sys->FD): string
{
e := "";
while((l := b.gets('\n')) != nil){
- (n, slist) := sys->tokenize(l, " \t\n\r"); # should use str->unquote?
- if(n <= 0)
+ if(str != nil)
+ slist := str->unquoted(l);
+ else
+ (nil, slist) = sys->tokenize(l, " \t\n\r"); # old way, in absence of String
+ if(slist == nil)
continue;
e = nsop(expand(slist), facfd);
if(e != "")
@@ -264,7 +272,7 @@ mount(argv: list of string, facfd: ref Sys->FD): string
return ig(r, sys->sprint("cannot load %s: %r", Factotum->PATH));
factotum->init();
afd := sys->fauth(fd, spec);
- ai := factotum->proxy(afd, facfd, "proto=p9any role=client");
+ ai := factotum->proxy(afd, facfd, "proto=p9any role=client"); # TO DO: something with ai
if(sys->mount(fd, afd, dir, r.flags, spec) < 0)
return ig(r, sys->sprint("mount %q %q: %r", addr, dir));
return nil;
@@ -343,7 +351,7 @@ import9(argv: list of string, facfd: ref Sys->FD): string
}
# TO DO: new style: impo aan|nofilter clear|ssl|tls\n
afd := sys->fauth(fd, "");
- ai := factotum->proxy(afd, facfd, "proto=p9any role=client");
+ ai := factotum->proxy(afd, facfd, "proto=p9any role=client"); # TO DO: something with ai
if(sys->mount(fd, afd, dir, r.flags, "") < 0)
return ig(r, sys->sprint("import %q %q: %r", addr, dir));
return nil;
diff --git a/appl/lib/pop3.b b/appl/lib/pop3.b
index 18e90525..4081b279 100644
--- a/appl/lib/pop3.b
+++ b/appl/lib/pop3.b
@@ -30,12 +30,9 @@ open(user, password, server : string): (int, string)
}
if (conn)
return (-1, "connection is already open");
- if (server == nil) {
- server = defaultserver();
- if (server == nil)
- return (-1, "no default mail server");
- }
- (ok, c) := sys->dial ("tcp!" + server + "!110", nil);
+ if (server == nil)
+ server = "$pop3";
+ (ok, c) := sys->dial ("net!" + server + "!110", nil);
if (ok < 0)
return (-1, "dialup failed");
ibuf = bufio->fopen(c.dfd, Bufio->OREAD);
@@ -256,11 +253,6 @@ mcmd(s : string) : (int, string)
return (-1, r);
}
-defaultserver() : string
-{
- return "$pop3";
-}
-
rev1(l1 : list of int) : list of int
{
l2 : list of int;
diff --git a/appl/lib/sets.b b/appl/lib/sets.b
index 22f25d7b..a770f31c 100644
--- a/appl/lib/sets.b
+++ b/appl/lib/sets.b
@@ -296,7 +296,7 @@ op(o: int, a, b: int): int
2r1010 => return a;
2r1011 => return a | ~b;
2r1100 => return b;
- 2r1101 => return ~(a | b);
+ 2r1101 => return ~a | b;
2r1110 => return a | b;
2r1111 => return ~0;
}
diff --git a/appl/lib/sets32.b b/appl/lib/sets32.b
index 01edea46..5deddbbe 100644
--- a/appl/lib/sets32.b
+++ b/appl/lib/sets32.b
@@ -218,7 +218,7 @@ op(o: int, a, b: int): int
2r1010 => return a;
2r1011 => return a | ~b;
2r1100 => return b;
- 2r1101 => return ~(a | b);
+ 2r1101 => return ~a | b;
2r1110 => return a | b;
2r1111 => return ~0;
}
diff --git a/appl/lib/venti.b b/appl/lib/venti.b
index ec9ec24e..d150f6f8 100644
--- a/appl/lib/venti.b
+++ b/appl/lib/venti.b
@@ -653,8 +653,8 @@ g48(f: array of byte, i: int): big
g64(f: array of byte, i: int): big
{
- b0 := (((((int f[i+3] << 8) | int f[i+2]) << 8) | int f[i+1]) << 8) | int f[i];
- b1 := (((((int f[i+7] << 8) | int f[i+6]) << 8) | int f[i+5]) << 8) | int f[i+4];
- return (big b1 << 32) | (big b0 & 16rFFFFFFFF);
+ b0 := (((((int f[i+0] << 8) | int f[i+1]) << 8) | int f[i+2]) << 8) | int f[i+3];
+ b1 := (((((int f[i+4] << 8) | int f[i+5]) << 8) | int f[i+6]) << 8) | int f[i+7];
+ return (big b0 << 32) | (big b1 & 16rFFFFFFFF);
}
diff --git a/appl/lib/w3c/mkfile b/appl/lib/w3c/mkfile
index 90f4d043..34901e32 100644
--- a/appl/lib/w3c/mkfile
+++ b/appl/lib/w3c/mkfile
@@ -2,6 +2,7 @@
TARG=\
css.dis\
+ uris.dis\
xpointers.dis\
MODULES=
@@ -10,6 +11,7 @@ SYSMODULES= \
sys.m\
bufio.m\
css.m\
+ uris.m\
xpointers.m\
DISBIN=$ROOT/dis/lib/w3c
diff --git a/appl/lib/w3c/xpointers.b b/appl/lib/w3c/xpointers.b
index 0d7c231a..de208d54 100644
--- a/appl/lib/w3c/xpointers.b
+++ b/appl/lib/w3c/xpointers.b
@@ -1,7 +1,7 @@
implement Xpointers;
#
-# Copyright © 2005 Vita Nuova Holdings Oimited
+# Copyright © 2005 Vita Nuova Holdings Limited
#
include "sys.m";
diff --git a/appl/lib/xml.b b/appl/lib/xml.b
index 5e10608d..f93cad8a 100644
--- a/appl/lib/xml.b
+++ b/appl/lib/xml.b
@@ -94,16 +94,22 @@ blankparser: Parser;
open(srcfile: string, warning: chan of (Locator, string), preelem: string): (ref Parser, string)
{
- x := ref blankparser;
- x.in = bufio->open(srcfile, Bufio->OREAD);
- if (x.in == nil)
+ fd := bufio->open(srcfile, Bufio->OREAD);
+ if(fd == nil)
return (nil, sys->sprint("cannot open %s: %r", srcfile));
- # ignore utf16 intialisation character (yuck)
+ return fopen(fd, srcfile, warning, preelem);
+}
+
+fopen(fd: ref Bufio->Iobuf, name: string, warning: chan of (Locator, string), preelem: string): (ref Parser, string)
+{
+ x := ref blankparser;
+ x.in = fd;
+ # ignore utf16 initialisation character (yuck)
c := x.in.getc();
if (c != 16rfffe && c != 16rfeff)
x.in.ungetc();
x.estack = nil;
- x.loc = Locator(1, srcfile, "");
+ x.loc = Locator(1, name, "");
x.warning = warning;
x.preelem = preelem;
return (x, "");
@@ -235,9 +241,8 @@ getparcel(x: ref Parser): ref Parcel
if (p == nil)
p = ref Parcel.EOF;
return p;
- }
- exception e{
- "sax:*" =>
+ }exception e{
+ "sax:*" =>
return ref Parcel.Error(x.loc, x.errormsg);
}
}