summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarg@mig29 <unknown>2006-11-26 14:26:53 +0100
committerarg@mig29 <unknown>2006-11-26 14:26:53 +0100
commit61a1910f91fe6aba428193087d6c3ff21374ee5e (patch)
treec6406dfd44df07e2e54309f29aef093b798d3d2d
parentapplied Jukka's stdinread patch (diff)
downloaddwm-61a1910f91fe6aba428193087d6c3ff21374ee5e.tar.gz
dwm-61a1910f91fe6aba428193087d6c3ff21374ee5e.zip
applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
-rw-r--r--client.c4
-rw-r--r--draw.c4
-rw-r--r--event.c4
-rw-r--r--main.c14
-rw-r--r--tag.c4
5 files changed, 16 insertions, 14 deletions
diff --git a/client.c b/client.c
index 220d2a0..74cadb5 100644
--- a/client.c
+++ b/client.c
@@ -361,12 +361,12 @@ updatetitle(Client *c) {
361 if(!name.nitems) 361 if(!name.nitems)
362 return; 362 return;
363 if(name.encoding == XA_STRING) 363 if(name.encoding == XA_STRING)
364 strncpy(c->name, (char *)name.value, sizeof(c->name)); 364 strncpy(c->name, (char *)name.value, sizeof c->name);
365 else { 365 else {
366 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success 366 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
367 && n > 0 && *list) 367 && n > 0 && *list)
368 { 368 {
369 strncpy(c->name, *list, sizeof(c->name)); 369 strncpy(c->name, *list, sizeof c->name);
370 XFreeStringList(list); 370 XFreeStringList(list);
371 } 371 }
372 } 372 }
diff --git a/draw.c b/draw.c
index 4441a88..671062c 100644
--- a/draw.c
+++ b/draw.c
@@ -43,8 +43,8 @@ drawtext(const char *text, unsigned long col[ColLast], Bool ldot, Bool rdot) {
43 return; 43 return;
44 w = 0; 44 w = 0;
45 olen = len = strlen(text); 45 olen = len = strlen(text);
46 if(len >= sizeof(buf)) 46 if(len >= sizeof buf)
47 len = sizeof(buf) - 1; 47 len = sizeof buf - 1;
48 memcpy(buf, text, len); 48 memcpy(buf, text, len);
49 buf[len] = 0; 49 buf[len] = 0;
50 h = dc.font.ascent + dc.font.descent; 50 h = dc.font.ascent + dc.font.descent;
diff --git a/event.c b/event.c
index 23dcf55..edfcc52 100644
--- a/event.c
+++ b/event.c
@@ -244,7 +244,7 @@ expose(XEvent *e) {
244 244
245static void 245static void
246keypress(XEvent *e) { 246keypress(XEvent *e) {
247 static unsigned int len = sizeof(key) / sizeof(key[0]); 247 static unsigned int len = sizeof key / sizeof key[0];
248 unsigned int i; 248 unsigned int i;
249 KeySym keysym; 249 KeySym keysym;
250 XKeyEvent *ev = &e->xkey; 250 XKeyEvent *ev = &e->xkey;
@@ -355,7 +355,7 @@ void (*handler[LASTEvent]) (XEvent *) = {
355 355
356void 356void
357grabkeys(void) { 357grabkeys(void) {
358 static unsigned int len = sizeof(key) / sizeof(key[0]); 358 static unsigned int len = sizeof key / sizeof key[0];
359 unsigned int i; 359 unsigned int i;
360 KeyCode code; 360 KeyCode code;
361 361
diff --git a/main.c b/main.c
index 86cd3f9..f196df7 100644
--- a/main.c
+++ b/main.c
@@ -227,6 +227,7 @@ xerror(Display *dpy, XErrorEvent *ee) {
227 227
228int 228int
229main(int argc, char *argv[]) { 229main(int argc, char *argv[]) {
230 char *p;
230 int r, xfd; 231 int r, xfd;
231 fd_set rd; 232 fd_set rd;
232 233
@@ -270,22 +271,23 @@ main(int argc, char *argv[]) {
270 if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) { 271 if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
271 if(errno == EINTR) 272 if(errno == EINTR)
272 continue; 273 continue;
273 else 274 eprint("select failed\n");
274 eprint("select failed\n");
275 } 275 }
276 if(FD_ISSET(STDIN_FILENO, &rd)) { 276 if(FD_ISSET(STDIN_FILENO, &rd)) {
277 switch(r = read(STDIN_FILENO, stext, sizeof(stext) - 1)) { 277 switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
278 case -1: 278 case -1:
279 strncpy(stext, strerror(errno), sizeof(stext)); 279 strncpy(stext, strerror(errno), sizeof stext - 1);
280 stext[sizeof(stext) - 1] = '\0';
281 readin = False; 280 readin = False;
282 break; 281 break;
283 case 0: 282 case 0:
284 strncpy(stext, "EOF", sizeof(stext)); 283 strncpy(stext, "EOF", sizeof stext);
285 readin = False; 284 readin = False;
286 break; 285 break;
287 default: 286 default:
288 stext[r - (stext[r - 1] == '\n' ? 1 : 0)] = '\0'; 287 stext[r - (stext[r - 1] == '\n' ? 1 : 0)] = '\0';
288 for(p = stext + strlen(stext) - 1; p > stext && *p != '\n'; --p);
289 if(p > stext)
290 strncpy(stext, p + 1, sizeof stext);
289 } 291 }
290 drawstatus(); 292 drawstatus();
291 } 293 }
diff --git a/tag.c b/tag.c
index fd08853..b1a2eb9 100644
--- a/tag.c
+++ b/tag.c
@@ -50,7 +50,7 @@ initrregs(void) {
50 50
51 if(rreg) 51 if(rreg)
52 return; 52 return;
53 len = sizeof(rule) / sizeof(rule[0]); 53 len = sizeof rule / sizeof rule[0];
54 rreg = emallocz(len * sizeof(RReg)); 54 rreg = emallocz(len * sizeof(RReg));
55 for(i = 0; i < len; i++) { 55 for(i = 0; i < len; i++) {
56 if(rule[i].clpattern) { 56 if(rule[i].clpattern) {
@@ -83,7 +83,7 @@ settags(Client *c, Client *trans) {
83 c->tags[i] = trans->tags[i]; 83 c->tags[i] = trans->tags[i];
84 } 84 }
85 else if(XGetClassHint(dpy, c->win, &ch)) { 85 else if(XGetClassHint(dpy, c->win, &ch)) {
86 snprintf(prop, sizeof(prop), "%s:%s:%s", 86 snprintf(prop, sizeof prop, "%s:%s:%s",
87 ch.res_class ? ch.res_class : "", 87 ch.res_class ? ch.res_class : "",
88 ch.res_name ? ch.res_name : "", c->name); 88 ch.res_name ? ch.res_name : "", c->name);
89 for(i = 0; !matched && i < len; i++) 89 for(i = 0; !matched && i < len; i++)