diff options
author | Petter Rodhelind <petter.rodhelind@gmail.com> | 2019-09-22 20:32:58 +0200 |
---|---|---|
committer | Petter Rodhelind <petter.rodhelind@gmail.com> | 2019-09-22 20:32:58 +0200 |
commit | c0c9d8f883dfd3a7f5a74499d91bb95884b15873 (patch) | |
tree | 65a9c5875c4ba78f70bd650602e75d1b832b4eeb /src | |
parent | 618fef785e57e971f26fc984df1adb5807a521fe (diff) | |
parent | 715807d706cd13bc583588477a84090fbf02e057 (diff) | |
download | plan9port-c0c9d8f883dfd3a7f5a74499d91bb95884b15873.tar.gz plan9port-c0c9d8f883dfd3a7f5a74499d91bb95884b15873.tar.bz2 plan9port-c0c9d8f883dfd3a7f5a74499d91bb95884b15873.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/auxstats/Linux.c | 30 | ||||
-rw-r--r-- | src/cmd/hoc/hoc.y | 4 | ||||
-rw-r--r-- | src/cmd/plumb/rules.c | 6 | ||||
-rw-r--r-- | src/cmd/upas/nfs/imap.c | 2 |
4 files changed, 14 insertions, 28 deletions
diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c index 09ca18f3..64c86a26 100644 --- a/src/cmd/auxstats/Linux.c +++ b/src/cmd/auxstats/Linux.c @@ -26,36 +26,22 @@ void (*statfn[])(int) = void xapm(int first) { - static int fd = -1, fdb = -1; - int i, last = -1, curr = -1; + static int fd = -1; + int curr = -1; if(first){ - fd = open("/proc/acpi/battery/BAT0/info", OREAD); - fdb = open("/proc/acpi/battery/BAT0/state", OREAD); + fd = open("/sys/class/power_supply/BAT0/capacity", OREAD); return; } - if(fd == -1 || fdb == -1) + if(fd == -1) return; readfile(fd); - for(i=0; i<nline; i++){ - tokens(i); - if(ntok < 3) - continue; - if(strcmp(tok[0], "last") == 0 && strcmp(tok[1], "full") == 0) - last = atoi(tok[3]); - } - readfile(fdb); - for(i = 0; i < nline; i++) { - tokens(i); - if(ntok < 3) - continue; - if(strcmp(tok[0], "remaining") == 0 && strcmp(tok[1], "capacity:") == 0) - curr = atoi(tok[2]); - } + tokens(0); + curr = atoi(tok[0]); - if(curr != -1 && last != -1) - Bprint(&bout, "battery =%d 100\n", (int)(((float)curr/(float)last)*100.0)); + if(curr != -1) + Bprint(&bout, "battery =%d 100\n", curr); } diff --git a/src/cmd/hoc/hoc.y b/src/cmd/hoc/hoc.y index 9c5a02f1..f634e82d 100644 --- a/src/cmd/hoc/hoc.y +++ b/src/cmd/hoc/hoc.y @@ -215,8 +215,8 @@ yylex(void) /* hoc6 */ return STRING; } switch (c) { - case '+': return follow('+', INC, follow('=', ADDEQ, '+')); - case '-': return follow('-', DEC, follow('=', SUBEQ, '-')); + case '+': return follow('+', INC, '+') == INC ? INC : follow('=', ADDEQ, '+'); + case '-': return follow('-', DEC, '-') == DEC ? DEC : follow('=', SUBEQ, '-'); case '*': return follow('=', MULEQ, '*'); case '/': return follow('=', DIVEQ, '/'); case '%': return follow('=', MODEQ, '%'); diff --git a/src/cmd/plumb/rules.c b/src/cmd/plumb/rules.c index 4da4bb23..6e9b2c63 100644 --- a/src/cmd/plumb/rules.c +++ b/src/cmd/plumb/rules.c @@ -736,8 +736,8 @@ morerules(uchar *text, int done) */ endofrule = nil; for(s=text; *s!='\0'; s++) - if(*s=='\n' && *++s=='\n') - endofrule = s+1; + if(*s=='\n' && *(s+1)=='\n') + endofrule = s+2; if(endofrule == nil) return text; input->end = endofrule; @@ -772,7 +772,7 @@ writerules(char *s, int n) tmp = stringof(s, n); text = (uchar*)concat((char*)text, tmp); free(tmp); - text = morerules(text, s==nil); + text = morerules(text, n==0); } if(s == nil){ free(text); diff --git a/src/cmd/upas/nfs/imap.c b/src/cmd/upas/nfs/imap.c index 8d43fe79..ef76487b 100644 --- a/src/cmd/upas/nfs/imap.c +++ b/src/cmd/upas/nfs/imap.c @@ -1468,6 +1468,7 @@ haveuid: if(isatom(sx->sx[i], msgtab[j].name)) msgtab[j].fn(msg, sx->sx[i], sx->sx[i+1]); } + msgplumb(msg, 0); } static void @@ -1549,7 +1550,6 @@ xmsgenvelope(Msg *msg, Sx *k, Sx *v) USED(k); hdrfree(msg->part[0]->hdr); msg->part[0]->hdr = parseenvelope(v); - msgplumb(msg, 0); } static struct { |