summaryrefslogtreecommitdiff
path: root/appl
diff options
context:
space:
mode:
Diffstat (limited to 'appl')
-rw-r--r--appl/lib/attrdb.b2
-rw-r--r--appl/lib/convcs/convcs.b2
-rw-r--r--appl/lib/convcs/utf8_btos.b9
-rw-r--r--appl/lib/db.b84
-rw-r--r--appl/lib/debug.b4
-rw-r--r--appl/lib/devpointer.b4
-rw-r--r--appl/lib/env.b2
-rw-r--r--appl/lib/inflate.b4
-rw-r--r--appl/lib/nametree.b1
-rw-r--r--appl/lib/pslib.b4
-rw-r--r--appl/lib/readgif.b2
-rw-r--r--appl/lib/scoretable.b2
-rw-r--r--appl/lib/ssl.b2
-rw-r--r--appl/lib/tabs.b3
-rw-r--r--appl/lib/url.b2
-rw-r--r--appl/lib/volume.b1
-rw-r--r--appl/lib/watchvars.b2
17 files changed, 57 insertions, 73 deletions
diff --git a/appl/lib/attrdb.b b/appl/lib/attrdb.b
index de9fa1b1..b411b7ef 100644
--- a/appl/lib/attrdb.b
+++ b/appl/lib/attrdb.b
@@ -307,7 +307,7 @@ flatten(ts: list of (ref Tuples, list of ref Attr), attr: string): list of ref A
{
l: list of ref Attr;
for(; ts != nil; ts = tl ts){
- (line, a) := hd ts;
+ (line, nil) := hd ts;
t := line.find(attr);
for(; t != nil; t = tl t)
l = hd t :: l;
diff --git a/appl/lib/convcs/convcs.b b/appl/lib/convcs/convcs.b
index 23208224..8e3b31f3 100644
--- a/appl/lib/convcs/convcs.b
+++ b/appl/lib/convcs/convcs.b
@@ -142,7 +142,7 @@ aliases(cs : string) : (string, list of string)
recs := cfg->lookup(name);
if (recs == nil)
continue; # shouldn't happen!
- (val, rec) := hd recs;
+ (val, nil) := hd recs;
if (val != cs)
continue;
al = name :: al;
diff --git a/appl/lib/convcs/utf8_btos.b b/appl/lib/convcs/utf8_btos.b
index 7ed10ddd..307ef863 100644
--- a/appl/lib/convcs/utf8_btos.b
+++ b/appl/lib/convcs/utf8_btos.b
@@ -23,12 +23,11 @@ btos(nil : Convcs->State, b : array of byte, n : int) : (Convcs->State, string,
str = string b[:nbytes];
} else {
for (; nbytes < len b && len str < n;) {
- (ch, l, s) := sys->byte2char(b, nbytes);
- if (l > 0) {
- str[len str] = ch;
- nbytes += l;
- } else
+ (ch, l, nil) := sys->byte2char(b, nbytes);
+ if (l <= 0)
break;
+ str[len str] = ch;
+ nbytes += l;
}
}
return (nil, str, nbytes);
diff --git a/appl/lib/db.b b/appl/lib/db.b
index 6271b925..804c5a82 100644
--- a/appl/lib/db.b
+++ b/appl/lib/db.b
@@ -1,9 +1,9 @@
implement DB;
include "sys.m";
- sys : Sys;
+ sys: Sys;
-include "draw.m";
+include "dial.m";
include "keyring.m";
@@ -25,30 +25,28 @@ connect(addr: string, alg: string): (ref Sys->FD, string)
{
if (sys == nil)
sys = load Sys Sys->PATH;
-#
-# Should check to see if addr == /dev/sysname. If so, probably should
-# change addr to localhost, since some underlying platform code might
-# choke if handed its own address.
-#
- (ok, c) := sys->dial(addr, nil);
- if(ok < 0)
- return (nil, sys->sprint("DB init: dial %s: %r\n", addr));
+
+ dial := load Dial Dial->PATH;
+ if(dial == nil)
+ return (nil, sys->sprint("load %s: %r", Dial->PATH));
+
+ addr = dial->netmkaddr(addr, "net", "6669"); # infdb
+
+ conn := dial->dial(addr, nil);
+ if(conn == nil)
+ return (nil, sys->sprint("can't dial %s: %r", addr));
+
(n, addrparts) := sys->tokenize(addr, "!");
if(n >= 2)
- addr = hd addrparts + "!" + hd tl addrparts;
+ addr = hd addrparts + "!" + hd tl addrparts; # ignore service for key search
kr := load Keyring Keyring->PATH;
user := user();
kd := "/usr/" + user + "/keyring/";
cert := kd + addr;
- (ok, nil) = sys->stat(cert);
- if(ok < 0){
+ if(sys->stat(cert).t0 < 0)
cert = kd + "default";
- # (ok, nil) = sys->stat(cert);
- # if(ok<0)
- # sys->fprint(stderr, "Warning: no certificate found in %s; use getauthinfo\n", kd);
- }
ai := kr->readauthinfo(cert);
@@ -69,7 +67,7 @@ connect(addr: string, alg: string): (ref Sys->FD, string)
fd: ref Sys->FD;
- (fd, err) = au->client(alg, ai, c.dfd);
+ (fd, err) = au->client(alg, ai, conn.dfd);
if(fd == nil)
return (nil, sys->sprint("DB init: authentication failed: %s", err));
@@ -98,7 +96,7 @@ dbopen(fd: ref Sys->FD, username, password, dbname: string): (ref DB_Handle, lis
DB_Handle.SQLOpen(oldh: self ref DB_Handle): (int, ref DB_Handle)
{
dbh := ref *oldh;
- (mtype, strm, rc, data) := sendReq(dbh, 'O', array of byte string dbh.sqlconn);
+ (mtype, nil, nil, data) := sendReq(dbh, 'O', array of byte string dbh.sqlconn);
if(mtype == 'h')
return (-1, nil);
dbh.sqlstream = int string data;
@@ -107,7 +105,7 @@ DB_Handle.SQLOpen(oldh: self ref DB_Handle): (int, ref DB_Handle)
DB_Handle.SQLClose(dbh: self ref DB_Handle): int
{
- (mtype, strm, rc, data) := sendReq(dbh, 'K', array[0] of byte);
+ (mtype, nil, nil, nil) := sendReq(dbh, 'K', array[0] of byte);
if(mtype == 'h')
return -1;
dbh.sqlstream = -1;
@@ -116,7 +114,7 @@ DB_Handle.SQLClose(dbh: self ref DB_Handle): int
DB_Handle.SQL(dbh: self ref DB_Handle, command: string): (int, list of string)
{
- (mtype, strm, rc, data) := sendReq(dbh, 'W', array of byte command);
+ (mtype, nil, nil, data) := sendReq(dbh, 'W', array of byte command);
if(mtype == 'h')
return (-1, "Probable SQL format error" :: string data :: nil);
return (0, nil);
@@ -124,7 +122,7 @@ DB_Handle.SQL(dbh: self ref DB_Handle, command: string): (int, list of string)
DB_Handle.columns(dbh: self ref DB_Handle): int
{
- (mtype, strm, rc, data) := sendReq(dbh, 'C', array[0] of byte);
+ (mtype, nil, nil, data) := sendReq(dbh, 'C', array[0] of byte);
if(mtype == 'h')
return 0;
return int string data;
@@ -132,7 +130,7 @@ DB_Handle.columns(dbh: self ref DB_Handle): int
DB_Handle.nextRow(dbh: self ref DB_Handle): int
{
- (mtype, strm, rc, data) := sendReq(dbh, 'N', array[0] of byte);
+ (mtype, nil, nil, data) := sendReq(dbh, 'N', array[0] of byte);
if(mtype == 'h')
return 0;
return int string data;
@@ -140,7 +138,7 @@ DB_Handle.nextRow(dbh: self ref DB_Handle): int
DB_Handle.read(dbh: self ref DB_Handle, columnI: int): (int, array of byte)
{
- (mtype, strm, rc, data) := sendReq(dbh, 'R', array of byte string columnI);
+ (mtype, nil, nil, data) := sendReq(dbh, 'R', array of byte string columnI);
if(mtype == 'h')
return (-1, data);
return (len data, data);
@@ -155,7 +153,7 @@ DB_Handle.write(dbh: self ref DB_Handle, paramI: int, val: array of byte)
for(i := 0; i < 4; i++)
outbuf[i] = param[i];
outbuf[4:] = val;
- (mtype, strm, rc, data) := sendReq(dbh, 'P', outbuf);
+ (mtype, nil, nil, nil) := sendReq(dbh, 'P', outbuf);
if(mtype == 'h')
return -1;
return len val;
@@ -163,7 +161,7 @@ DB_Handle.write(dbh: self ref DB_Handle, paramI: int, val: array of byte)
DB_Handle.columnTitle(handle: self ref DB_Handle, columnI: int): string
{
- (mtype, strm, rc, data) := sendReq(handle, 'T', array of byte string columnI);
+ (mtype, nil, nil, data) := sendReq(handle, 'T', array of byte string columnI);
if(mtype == 'h')
return nil;
return string data;
@@ -171,7 +169,7 @@ DB_Handle.columnTitle(handle: self ref DB_Handle, columnI: int): string
DB_Handle.errmsg(dbh: self ref DB_Handle): string
{
- (mtype, strm, rc, data) := sendReq(dbh, 'H', array[0] of byte);
+ (nil, nil, nil, data) := sendReq(dbh, 'H', array[0] of byte);
return string data;
}
@@ -192,15 +190,15 @@ sendReq(dbh: ref DB_Handle, mtype: int, data: array of byte) : (int, int, int, a
return ('h', dbh.sqlstream, 0, array of byte "header write failure");
}
hbuf := array[RES_HEADER_SIZE+3] of byte;
- if((n := sys->read(dbh.datafd, hbuf, RES_HEADER_SIZE)) !=
- RES_HEADER_SIZE) {
- # Is this an error? Try another read.
- if(n < 0 ||
- (m := sys->read(dbh.datafd, hbuf[n:], RES_HEADER_SIZE-n)) !=
- RES_HEADER_SIZE-n) {
- unlock(dbh);
- return ('h', dbh.sqlstream, 0, array of byte "read error");
- }
+ if((n := sys->readn(dbh.datafd, hbuf, RES_HEADER_SIZE)) != RES_HEADER_SIZE) {
+ unlock(dbh);
+ if(n < 0)
+ why := sys->aprint("read error: %r");
+ else if(n == 0)
+ why = sys->aprint("lost connection");
+ else
+ why = sys->aprint("read error: short read");
+ return ('h', dbh.sqlstream, 0, why);
}
rheader := string hbuf[0:22];
rtype := rheader[0];
@@ -228,17 +226,7 @@ sendReq(dbh: ref DB_Handle, mtype: int, data: array of byte) : (int, int, int, a
makelock(): chan of int
{
- ch := chan of int;
- spawn holdlock(ch);
- return ch;
-}
-
-holdlock(c: chan of int)
-{
- for(;;){
- i := <-c;
- c <-= i;
- }
+ return chan[1] of int;
}
lock(h: ref DB_Handle)
@@ -257,7 +245,7 @@ user(): string
fd := sys->open("/dev/user", sys->OREAD);
if(fd == nil)
return "";
- buf := array[128] of byte;
+ buf := array[Sys->NAMEMAX] of byte;
n := sys->read(fd, buf, len buf);
if(n < 0)
return "";
diff --git a/appl/lib/debug.b b/appl/lib/debug.b
index 09273dc7..5e479274 100644
--- a/appl/lib/debug.b
+++ b/appl/lib/debug.b
@@ -552,7 +552,7 @@ Exp.expand(e: self ref Exp): array of ref Exp
k[1] = ref Exp("tl", hex(array of byte tloff), e.pc, e.m, e.p, ref Id(nil, "tl", H, H, t));
return k;
Tarray =>
- (s, err) := pdata(e.p, e.offset, "A");
+ (s, nil) := pdata(e.p, e.offset, "A");
if(s == "nil")
return nil;
(sn, sa) := str->splitl(s, ".");
@@ -622,7 +622,7 @@ Exp.expand(e: self ref Exp): array of ref Exp
return k;
}
Tchan =>
- (s, err) := pdata(e.p, e.offset, "c");
+ (s, nil) := pdata(e.p, e.offset, "c");
if(s == "nil")
return nil;
(sn, sa) := str->splitl(s, ".");
diff --git a/appl/lib/devpointer.b b/appl/lib/devpointer.b
index 137f29f6..36492164 100644
--- a/appl/lib/devpointer.b
+++ b/appl/lib/devpointer.b
@@ -27,7 +27,7 @@ reader(file: string, posn: chan of ref Pointer, pid: chan of (int, string))
if(pid != nil)
pid <-= (sys->pctl(0, nil), nil);
b:= array[Size] of byte;
- while((n := sys->read(dfd, b, len b)) == Size)
+ while(sys->read(dfd, b, len b) == Size)
posn <-= bytes2ptr(b);
}
@@ -64,7 +64,7 @@ srv(c: chan of ref Pointer, f: ref Sys->FileIO)
if(p == nil)
exit;
ptrq.put(p);
- (nil, n, nil, rc) := <-r =>
+ (nil, nil, nil, rc) := <-r =>
if(rc != nil){
alt{
rc <-= (ptr2bytes(ptrq.get()), nil) =>;
diff --git a/appl/lib/env.b b/appl/lib/env.b
index b2fa064c..76ff1cf8 100644
--- a/appl/lib/env.b
+++ b/appl/lib/env.b
@@ -56,7 +56,7 @@ getall(): list of (string, string)
readdir := load Readdir Readdir->PATH;
if (readdir == nil)
return nil;
- (a, n) := readdir->init(ENVDIR,
+ (a, nil) := readdir->init(ENVDIR,
Readdir->NONE | Readdir->COMPACT | Readdir->DESCENDING);
vl: list of (string, string);
for (i := 0; i < len a; i++)
diff --git a/appl/lib/inflate.b b/appl/lib/inflate.b
index 3d8a6d22..0f4d6ba7 100644
--- a/appl/lib/inflate.b
+++ b/appl/lib/inflate.b
@@ -302,8 +302,8 @@ header(s: ref State)
mtime |= (getb(s) << 16);
mtime |= (getb(s) << 24);
s.c <-= ref Rq.Info("mtime " + string mtime);
- xfl := getb(s);
- os := getb(s);
+ getb(s); # xfl
+ getb(s); # os
# skip optional "extra field"
if(flags & GZFEXTRA) {
diff --git a/appl/lib/nametree.b b/appl/lib/nametree.b
index b9975567..e253bb23 100644
--- a/appl/lib/nametree.b
+++ b/appl/lib/nametree.b
@@ -59,7 +59,6 @@ Tree.getpath(t: self ref Tree, q: big): string
fsproc(c: chan of ref Styxservers->Navop, fsc: chan of ref Treeop)
{
tab := array[23] of ref Fholder;
- starttime := 0;
for (;;) alt {
grq := <-c =>
diff --git a/appl/lib/pslib.b b/appl/lib/pslib.b
index a929fc8a..b02d6b73 100644
--- a/appl/lib/pslib.b
+++ b/appl/lib/pslib.b
@@ -272,7 +272,7 @@ printimage(ioutb: ref Iobuf, line: Lineinfo, imag: Iteminfo): (string,string)
line.height));
return (class,msg);
"label" =>
- (im,im2,err) := tk->getimage(t,imag.buf);
+ (im,nil,nil) := tk->getimage(t,imag.buf);
if (im!=nil){
bps := im.depth;
ioutb.puts(sys->sprint("%d %d %d %d %d %d %d %d doimage\n",
@@ -358,7 +358,7 @@ parseTkline(ioutb: ref Iobuf, input: string): string
PS:=792-18-18; # page size in points
TM:=792-18; # top margin in points
LM:=18; # left margin 1/4 in. in
- BM:=18; # bottom margin 1/4 in. in
+# BM:=18; # bottom margin 1/4 in. in
x : int;
(x,input)=str->toint(input,10);
thisline.xorg=(x*PTPI)/PXPI;
diff --git a/appl/lib/readgif.b b/appl/lib/readgif.b
index 3c3bb486..2b3cc31f 100644
--- a/appl/lib/readgif.b
+++ b/appl/lib/readgif.b
@@ -222,7 +222,7 @@ skipextension(h: ref Header): string
hsize := 0;
hasdata := 0;
- case XX := h.fd.getb(){
+ case h.fd.getb(){
Bufio->ERROR or Bufio->EOF =>
return sys->sprint(readerr);
16r01 => # Plain Text Extension
diff --git a/appl/lib/scoretable.b b/appl/lib/scoretable.b
index a466763b..322e119b 100644
--- a/appl/lib/scoretable.b
+++ b/appl/lib/scoretable.b
@@ -22,7 +22,7 @@ username: string;
MAXSCORES: con 10;
-init(port: int, user, name: string, sfile: string): (int, string)
+init(nil: int, user, nil: string, sfile: string): (int, string)
{
if (sys == nil) {
sys = load Sys Sys->PATH;
diff --git a/appl/lib/ssl.b b/appl/lib/ssl.b
index 2828e269..46f305c2 100644
--- a/appl/lib/ssl.b
+++ b/appl/lib/ssl.b
@@ -69,7 +69,7 @@ secret(c: ref Sys->Connection, secretin, secretout: array of byte): string
algs(): (list of string, list of string)
{
- (c, err) := sslclone();
+ (c, nil) := sslclone();
if(c == nil)
return (nil, nil);
c.dfd = nil;
diff --git a/appl/lib/tabs.b b/appl/lib/tabs.b
index d4314272..d2754320 100644
--- a/appl/lib/tabs.b
+++ b/appl/lib/tabs.b
@@ -42,7 +42,6 @@ mktabs(t: ref Tk->Toplevel, dot: string, tabs: array of (string, string), dflt:
c := chan of string;
tk->namechan(t, c, dot[1:]);
xpos := 2*TABSXdelta;
- top := 10;
ypos := TABSYheight - 3;
back := cmd(t, dot+" cget -background");
dark := "#999999";
@@ -153,7 +152,7 @@ tabsctl(t: ref Tk->Toplevel,
(lab, widg) = tabs[id];
pos := tk->cmd(t, dot+" coords tag" + string id);
if(len pos >= 1 && pos[0] != '!'){
- (p, nli) := parsept(pos);
+ (p, nil) := parsept(pos);
cmd(t, dot+" coords tag"+string id+" "+string(p.x-1)+" "+string(p.y-1));
}
cmd(t, dot+" raise tag"+string id);
diff --git a/appl/lib/url.b b/appl/lib/url.b
index 415018c2..c7af3b1c 100644
--- a/appl/lib/url.b
+++ b/appl/lib/url.b
@@ -195,7 +195,7 @@ split(s, c: string) : (string, string)
canonize(s: string): string
{
(base, file) := S->splitr(s, "/");
- (n,path) := sys->tokenize(base, "/");
+ (nil, path) := sys->tokenize(base, "/");
revpath : list of string = nil;
for(p := path; p != nil; p = tl p) {
if(hd p == "..") {
diff --git a/appl/lib/volume.b b/appl/lib/volume.b
index 8615d1e3..da1f0289 100644
--- a/appl/lib/volume.b
+++ b/appl/lib/volume.b
@@ -93,7 +93,6 @@ volumectl(ctxt: ref Context, ch: chan of int, var: string)
}
}
- n := 0;
for(;;) {
key = <- ch;
case key {
diff --git a/appl/lib/watchvars.b b/appl/lib/watchvars.b
index ad6c6947..d171f211 100644
--- a/appl/lib/watchvars.b
+++ b/appl/lib/watchvars.b
@@ -17,7 +17,7 @@ Watchvar[T].get(e: self Watchvar): T
Watchvar[T].set(e: self Watchvar, v: T)
{
- (ov, ic) := <-e.c;
+ (nil, ic) := <-e.c;
ic <-= v;
e.c <-= (v, chan[1] of T);
}