fix typos in time calculation
the results of the time calculation were garbled -- and apparently negative on my system when testing, so the test passed when it shouldn't have.
This commit is contained in:
parent
5d7e9bee3c
commit
2de164c51d
9 changed files with 115 additions and 41 deletions
|
@ -363,6 +363,7 @@ regalloc(Node *n, Node *tn, Node *o)
|
|||
if(reg[i] == 0 && !resvreg[i])
|
||||
goto out;
|
||||
diag(tn, "out of float registers");
|
||||
abort();
|
||||
goto out;
|
||||
}
|
||||
diag(tn, "unknown type in regalloc: %T", tn->type);
|
||||
|
|
|
@ -26,15 +26,21 @@ findarg(char *flags, Rune r)
|
|||
char*
|
||||
argname(char *p)
|
||||
{
|
||||
char *s;
|
||||
Rune r;
|
||||
int n;
|
||||
|
||||
s = p;
|
||||
if(*p == ' ')
|
||||
p++;
|
||||
while(1){
|
||||
n = chartorune(&r, p);
|
||||
if(!isalpharune(r) && !isdigitrune(r))
|
||||
break;
|
||||
p += n;
|
||||
}
|
||||
if(*s == ' ')
|
||||
return s;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ ispaste(Tokenrow *rtr, Token **ap, Token **an, int *ntok)
|
|||
void
|
||||
substargs(Nlist *np, Tokenrow *rtr, Tokenrow **atr)
|
||||
{
|
||||
Tokenrow ttr;
|
||||
Tokenrow ttr, rp, rn;
|
||||
Token *tp, *ap, *an, *pp, *pn;
|
||||
int ntok, argno, hs;
|
||||
|
||||
|
@ -369,19 +369,25 @@ substargs(Nlist *np, Tokenrow *rtr, Tokenrow **atr)
|
|||
insertrow(rtr, ntok, stringify(atr[argno]));
|
||||
} else if (ispaste(rtr, &ap, &an, &ntok)) { /* first token, just do the next one */
|
||||
pp = ap;
|
||||
rp.tp = nil;
|
||||
pn = an;
|
||||
rn.tp = nil;
|
||||
if (ap && (argno = lookuparg(np, ap)) >= 0){
|
||||
pp = nil;
|
||||
if(atr[argno]->tp != atr[argno]->lp)
|
||||
pp = atr[argno]->lp - 1;
|
||||
rp = *atr[argno];
|
||||
if(rp.tp != rp.lp)
|
||||
pp = --rp.lp;
|
||||
}
|
||||
if (an && (argno = lookuparg(np, an)) >= 0) {
|
||||
pn = nil;
|
||||
if(atr[argno]->tp != atr[argno]->lp)
|
||||
pn = atr[argno]->lp - 1;
|
||||
rn = *atr[argno];
|
||||
if(rn.tp != rn.lp)
|
||||
pn = rn.bp++;
|
||||
}
|
||||
glue(&ttr, pp, pn);
|
||||
insertrow(rtr, 0, &rp);
|
||||
insertrow(rtr, ntok, &ttr);
|
||||
insertrow(rtr, 0, &rn);
|
||||
free(ttr.bp);
|
||||
} else if (rtr->tp->type==NAME) {
|
||||
if((argno = lookuparg(np, rtr->tp)) >= 0) {
|
||||
|
|
|
@ -21,6 +21,9 @@ CAT3(blah)
|
|||
#define FOO CAT(BAR, 3)
|
||||
FOO
|
||||
|
||||
/* Expected: a bc d */
|
||||
CAT(a b, c d)
|
||||
|
||||
/*
|
||||
* CURRENTLY BROKEN:
|
||||
* __VA_ARGS__ requires at least one item.
|
||||
|
@ -58,4 +61,4 @@ g(x+(3,4)-w) | h 5) & m
|
|||
* It should treat no args as a single empty arg list.
|
||||
p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
|
||||
char c[2][6] = { str(hello), str() };
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -550,7 +550,7 @@ rclunk(void)
|
|||
/*
|
||||
* wipe out a dos directory entry
|
||||
*/
|
||||
static void
|
||||
static int
|
||||
doremove(Xfs *xf, Dosptr *dp)
|
||||
{
|
||||
Iosect *p;
|
||||
|
@ -565,6 +565,8 @@ doremove(Xfs *xf, Dosptr *dp)
|
|||
}
|
||||
if(prevdo < 0 && dp->prevaddr != -1){
|
||||
p = getsect(xf, dp->prevaddr);
|
||||
if(p == nil)
|
||||
return -1;
|
||||
for(prevdo = ((Dosbpb*)xf->ptr)->sectsize-DOSDIRSIZE; prevdo >= 0; prevdo -= DOSDIRSIZE){
|
||||
if(p->iobuf[prevdo+11] != 0xf)
|
||||
break;
|
||||
|
@ -572,7 +574,8 @@ doremove(Xfs *xf, Dosptr *dp)
|
|||
p->flags |= BMOD;
|
||||
}
|
||||
putsect(p);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -601,8 +604,7 @@ rremove(void)
|
|||
* or it's a read only file in the root directory
|
||||
*/
|
||||
parp = getsect(f->xf, dp->paddr);
|
||||
if(parp == nil
|
||||
|| getfile(f) < 0){
|
||||
if(parp == nil || getfile(f) < 0){
|
||||
errno = Eio;
|
||||
goto out;
|
||||
}
|
||||
|
@ -617,7 +619,10 @@ rremove(void)
|
|||
errno = Eio;
|
||||
goto out;
|
||||
}
|
||||
doremove(f->xf, f->ptr);
|
||||
if(doremove(f->xf, f->ptr) == -1){
|
||||
errno = Eio;
|
||||
goto out;
|
||||
}
|
||||
if(!isroot(dp->paddr)){
|
||||
puttime(pard, 0);
|
||||
parp->flags |= BMOD;
|
||||
|
|
|
@ -1000,6 +1000,8 @@ writefile(Xfile *f, void *vbuf, vlong offset, long count)
|
|||
c = count;
|
||||
if(c == bp->sectsize){
|
||||
p = getosect(xf, addr);
|
||||
if(p == nil)
|
||||
return -1;
|
||||
p->flags = 0;
|
||||
}else{
|
||||
p = getsect(xf, addr);
|
||||
|
@ -1632,7 +1634,8 @@ makecontig(Xfile *f, int nextra)
|
|||
if(rp == nil)
|
||||
return -1;
|
||||
wp = getosect(xf, ws);
|
||||
assert(wp != nil);
|
||||
if(wp == nil)
|
||||
return -1;
|
||||
memmove(wp->iobuf, rp->iobuf, bp->sectsize);
|
||||
wp->flags = BMOD;
|
||||
putsect(rp);
|
||||
|
@ -1702,6 +1705,8 @@ falloc(Xfs *xf)
|
|||
k = clust2sect(bp, n);
|
||||
for(i=0; i<bp->clustsize; i++){
|
||||
p = getosect(xf, k+i);
|
||||
if(p == nil)
|
||||
return -1;
|
||||
memset(p->iobuf, 0, bp->sectsize);
|
||||
p->flags = BMOD;
|
||||
putsect(p);
|
||||
|
|
|
@ -39,8 +39,11 @@ getiosect(Xfs *xf, vlong addr, int rflag)
|
|||
int toff;
|
||||
Iosect *p;
|
||||
|
||||
if(addr < 0)
|
||||
if(addr < 0){
|
||||
chat("invalid address\n");
|
||||
errno = Eio;
|
||||
return nil;
|
||||
}
|
||||
toff = addr % Sect2trk;
|
||||
taddr = addr - toff;
|
||||
t = getiotrack(xf, taddr);
|
||||
|
@ -53,8 +56,10 @@ getiosect(Xfs *xf, vlong addr, int rflag)
|
|||
}
|
||||
t->ref++;
|
||||
p = t->tp->p[toff];
|
||||
if(p == 0){
|
||||
if(p == nil){
|
||||
p = newsect();
|
||||
if(p == nil)
|
||||
return nil;
|
||||
t->tp->p[toff] = p;
|
||||
p->flags = t->flags&BSTALE;
|
||||
p->lock.key = 0;
|
||||
|
@ -196,10 +201,10 @@ twrite(Iotrack *t)
|
|||
t->flags &= ~BSTALE;
|
||||
}
|
||||
if(devwrite(t->xf, t->addr, t->tp->buf, Trksize) < 0){
|
||||
chat("error]");
|
||||
chat("error]\n");
|
||||
return -1;
|
||||
}
|
||||
chat(" done]");
|
||||
chat(" done]\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -304,6 +309,8 @@ newsect(void)
|
|||
else
|
||||
p = malloc(sizeof(Iosect));
|
||||
unmlock(&freelock);
|
||||
if(p == nil)
|
||||
return nil;
|
||||
p->next = 0;
|
||||
return p;
|
||||
}
|
||||
|
|
|
@ -35,59 +35,77 @@ gather(void)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
matchmsg(Plumbmsg *m, Plumbmsg *pat)
|
||||
{
|
||||
Plumbattr *a;
|
||||
char *v;
|
||||
|
||||
if(pat->src && strcmp(m->src, pat->src) != 0)
|
||||
return 0;
|
||||
if(pat->dst && strcmp(m->dst, pat->dst) != 0)
|
||||
return 0;
|
||||
if(pat->wdir && strcmp(m->wdir, pat->wdir) != 0)
|
||||
return 0;
|
||||
if(pat->type && strcmp(m->type, pat->type) != 0)
|
||||
return 0;
|
||||
for(a = m->attr; a != nil; a = a->next){
|
||||
v = plumblookup(pat->attr, a->name);
|
||||
if(v != nil && strcmp(a->value, v) != 0)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char buf[1024], *p;
|
||||
char buf[1024], *p, *readport;
|
||||
int fd, i, input;
|
||||
Plumbmsg *rmsg;
|
||||
Plumbattr *a;
|
||||
|
||||
input = 0;
|
||||
m.src = "plumb";
|
||||
readport = nil;
|
||||
m.src = nil;
|
||||
m.dst = nil;
|
||||
m.wdir = getwd(buf, sizeof buf);
|
||||
m.wdir = nil;
|
||||
m.type = "text";
|
||||
m.attr = nil;
|
||||
ARGBEGIN{
|
||||
case 'a':
|
||||
p = ARGF();
|
||||
if(p == nil)
|
||||
usage();
|
||||
p = EARGF(usage());
|
||||
m.attr = plumbaddattr(m.attr, plumbunpackattr(p));
|
||||
break;
|
||||
case 'd':
|
||||
m.dst = ARGF();
|
||||
if(m.dst == nil)
|
||||
usage();
|
||||
m.dst = EARGF(usage());
|
||||
break;
|
||||
case 'i':
|
||||
input++;
|
||||
break;
|
||||
case 't':
|
||||
case 'k': /* for backwards compatibility */
|
||||
m.type = ARGF();
|
||||
if(m.type == nil)
|
||||
usage();
|
||||
m.type = EARGF(usage());
|
||||
break;
|
||||
case 'p':
|
||||
plumbfile = ARGF();
|
||||
if(plumbfile == nil)
|
||||
usage();
|
||||
plumbfile = EARGF(usage());
|
||||
break;
|
||||
case 's':
|
||||
m.src = ARGF();
|
||||
if(m.src == nil)
|
||||
usage();
|
||||
m.src = EARGF(usage());
|
||||
break;
|
||||
case 'w':
|
||||
m.wdir = ARGF();
|
||||
if(m.wdir == nil)
|
||||
usage();
|
||||
m.wdir = EARGF(usage());
|
||||
break;
|
||||
case 'r':
|
||||
readport = EARGF(usage());
|
||||
break;
|
||||
}ARGEND
|
||||
|
||||
if((input && argc>0) || (!input && argc<1))
|
||||
if((input && argc>0) || (!input && argc<1) && readport == nil)
|
||||
usage();
|
||||
if(plumbfile != nil)
|
||||
if(readport != nil)
|
||||
fd = plumbopen(readport, OREAD);
|
||||
else if(plumbfile != nil)
|
||||
fd = open(plumbfile, OWRITE);
|
||||
else
|
||||
fd = plumbopen("send", OWRITE);
|
||||
|
@ -95,6 +113,30 @@ main(int argc, char *argv[])
|
|||
fprint(2, "plumb: can't open plumb file: %r\n");
|
||||
exits("open");
|
||||
}
|
||||
if(readport != nil){
|
||||
again:
|
||||
rmsg = plumbrecv(fd);
|
||||
if(rmsg == nil){
|
||||
fprint(2, "plumb: receive failed: %r\n");
|
||||
exits("recv");
|
||||
}
|
||||
print("got message, matching\n");
|
||||
if(!matchmsg(rmsg, &m))
|
||||
goto again;
|
||||
print("src %s\n", rmsg->src);
|
||||
print("dst %s\n", rmsg->dst);
|
||||
print("wdir %s\n", rmsg->wdir);
|
||||
print("type %s\n", rmsg->type);
|
||||
print("data %.*s\n", rmsg->ndata, rmsg->data);
|
||||
for(a = rmsg->attr; a; a = a->next)
|
||||
print("attr %s=%s\n", a->name, a->value);
|
||||
plumbfree(rmsg);
|
||||
exits(nil);
|
||||
}
|
||||
if(m.src == nil)
|
||||
m.src = "plumb";
|
||||
if(m.wdir == nil)
|
||||
m.wdir = getwd(buf, sizeof buf);
|
||||
if(input){
|
||||
gather();
|
||||
if(plumblookup(m.attr, "action") == nil)
|
||||
|
|
|
@ -258,7 +258,7 @@ flselect(Flayer *l)
|
|||
|
||||
if(l->visible!=All)
|
||||
flupfront(l);
|
||||
dt = l->click = mousep->msec;
|
||||
dt = mousep->msec - l->click;
|
||||
dx = abs(mousep->xy.x - clickpt.x);
|
||||
dy = abs(mousep->xy.y - clickpt.y);
|
||||
|
||||
|
@ -279,7 +279,6 @@ flsetselect(Flayer *l, long p0, long p1)
|
|||
{
|
||||
ulong fp0, fp1;
|
||||
|
||||
l->click = 0;
|
||||
if(l->visible==None || !flprepare(l)){
|
||||
l->p0 = p0, l->p1 = p1;
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue