applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
arg@mig29 unknown
Sun, 26 Nov 2006 14:26:53 +0100
M
client.c
→
client.c
@@ -361,12 +361,12 @@ XGetWMName(dpy, c->win, &name);
if(!name.nitems) return; if(name.encoding == XA_STRING) - strncpy(c->name, (char *)name.value, sizeof(c->name)); + strncpy(c->name, (char *)name.value, sizeof c->name); else { if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) { - strncpy(c->name, *list, sizeof(c->name)); + strncpy(c->name, *list, sizeof c->name); XFreeStringList(list); } }
M
event.c
→
event.c
@@ -244,7 +244,7 @@ }
static void keypress(XEvent *e) { - static unsigned int len = sizeof(key) / sizeof(key[0]); + static unsigned int len = sizeof key / sizeof key[0]; unsigned int i; KeySym keysym; XKeyEvent *ev = &e->xkey;@@ -355,7 +355,7 @@ };
void grabkeys(void) { - static unsigned int len = sizeof(key) / sizeof(key[0]); + static unsigned int len = sizeof key / sizeof key[0]; unsigned int i; KeyCode code;
M
main.c
→
main.c
@@ -227,6 +227,7 @@ }
int main(int argc, char *argv[]) { + char *p; int r, xfd; fd_set rd;@@ -270,22 +271,23 @@ FD_SET(xfd, &rd);
if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) { if(errno == EINTR) continue; - else - eprint("select failed\n"); + eprint("select failed\n"); } if(FD_ISSET(STDIN_FILENO, &rd)) { - switch(r = read(STDIN_FILENO, stext, sizeof(stext) - 1)) { + switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) { case -1: - strncpy(stext, strerror(errno), sizeof(stext)); - stext[sizeof(stext) - 1] = '\0'; + strncpy(stext, strerror(errno), sizeof stext - 1); readin = False; break; case 0: - strncpy(stext, "EOF", sizeof(stext)); + strncpy(stext, "EOF", sizeof stext); readin = False; break; default: stext[r - (stext[r - 1] == '\n' ? 1 : 0)] = '\0'; + for(p = stext + strlen(stext) - 1; p > stext && *p != '\n'; --p); + if(p > stext) + strncpy(stext, p + 1, sizeof stext); } drawstatus(); }
M
tag.c
→
tag.c
@@ -50,7 +50,7 @@ regex_t *reg;
if(rreg) return; - len = sizeof(rule) / sizeof(rule[0]); + len = sizeof rule / sizeof rule[0]; rreg = emallocz(len * sizeof(RReg)); for(i = 0; i < len; i++) { if(rule[i].clpattern) {@@ -83,7 +83,7 @@ for(i = 0; i < ntags; i++)
c->tags[i] = trans->tags[i]; } else if(XGetClassHint(dpy, c->win, &ch)) { - snprintf(prop, sizeof(prop), "%s:%s:%s", + snprintf(prop, sizeof prop, "%s:%s:%s", ch.res_class ? ch.res_class : "", ch.res_name ? ch.res_name : "", c->name); for(i = 0; !matched && i < len; i++)