applied Ritesh's patch to stext handling with some minor modifications
This commit is contained in:
parent
667da18b31
commit
cb4951dd54
25
dwm.c
25
dwm.c
@ -1287,6 +1287,7 @@ restack(void) {
|
|||||||
void
|
void
|
||||||
run(void) {
|
run(void) {
|
||||||
char *p;
|
char *p;
|
||||||
|
char buf[sizeof stext];
|
||||||
fd_set rd;
|
fd_set rd;
|
||||||
int r, xfd;
|
int r, xfd;
|
||||||
unsigned int len, offset;
|
unsigned int len, offset;
|
||||||
@ -1298,7 +1299,7 @@ run(void) {
|
|||||||
readin = True;
|
readin = True;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
len = sizeof stext - 1;
|
len = sizeof stext - 1;
|
||||||
stext[len] = '\0'; /* 0-terminator is never touched */
|
buf[len] = stext[len] = '\0'; /* 0-terminator is never touched */
|
||||||
while(running) {
|
while(running) {
|
||||||
FD_ZERO(&rd);
|
FD_ZERO(&rd);
|
||||||
if(readin)
|
if(readin)
|
||||||
@ -1310,7 +1311,7 @@ run(void) {
|
|||||||
eprint("select failed\n");
|
eprint("select failed\n");
|
||||||
}
|
}
|
||||||
if(FD_ISSET(STDIN_FILENO, &rd)) {
|
if(FD_ISSET(STDIN_FILENO, &rd)) {
|
||||||
switch((r = read(STDIN_FILENO, stext + offset, len - offset))) {
|
switch((r = read(STDIN_FILENO, buf + offset, len - offset))) {
|
||||||
case -1:
|
case -1:
|
||||||
strncpy(stext, strerror(errno), len);
|
strncpy(stext, strerror(errno), len);
|
||||||
readin = False;
|
readin = False;
|
||||||
@ -1320,14 +1321,18 @@ run(void) {
|
|||||||
readin = False;
|
readin = False;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
stext[offset + r] = '\0';
|
for(p = buf + offset; r > 0; p++, r--, offset++)
|
||||||
for(p = stext; *p && *p != '\n'; p++);
|
if(*p == '\n' || *p == '\0') {
|
||||||
if(*p == '\n') {
|
*p = '\0';
|
||||||
*p = '\0';
|
strncpy(stext, buf, len);
|
||||||
offset = 0;
|
p += r - 1; /* p is buf + offset + r - 1 */
|
||||||
}
|
for(r = 0; *(p - r) && *(p - r) != '\n'; r++);
|
||||||
else
|
offset = r;
|
||||||
offset = (offset + r < len - 1) ? offset + r : 0;
|
if(r)
|
||||||
|
memmove(buf, p - r + 1, r);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
drawbar();
|
drawbar();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user