applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading. 61a1910f
arg@mig29 · 2006-11-26 14:26 5 file(s) · +16 −14
client.c +2 −2
361 361
	if(!name.nitems)
362 362
		return;
363 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 365
	else {
366 366
		if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
367 367
				&& n > 0 && *list)
368 368
		{
369 -
			strncpy(c->name, *list, sizeof(c->name));
369 +
			strncpy(c->name, *list, sizeof c->name);
370 370
			XFreeStringList(list);
371 371
		}
372 372
	}
draw.c +2 −2
43 43
		return;
44 44
	w = 0;
45 45
	olen = len = strlen(text);
46 -
	if(len >= sizeof(buf))
47 -
		len = sizeof(buf) - 1;
46 +
	if(len >= sizeof buf)
47 +
		len = sizeof buf - 1;
48 48
	memcpy(buf, text, len);
49 49
	buf[len] = 0;
50 50
	h = dc.font.ascent + dc.font.descent;
event.c +2 −2
244 244
245 245
static void
246 246
keypress(XEvent *e) {
247 -
	static unsigned int len = sizeof(key) / sizeof(key[0]);
247 +
	static unsigned int len = sizeof key / sizeof key[0];
248 248
	unsigned int i;
249 249
	KeySym keysym;
250 250
	XKeyEvent *ev = &e->xkey;
355 355
356 356
void
357 357
grabkeys(void) {
358 -
	static unsigned int len = sizeof(key) / sizeof(key[0]);
358 +
	static unsigned int len = sizeof key / sizeof key[0];
359 359
	unsigned int i;
360 360
	KeyCode code;
361 361
main.c +8 −6
227 227
228 228
int
229 229
main(int argc, char *argv[]) {
230 +
	char *p;
230 231
	int r, xfd;
231 232
	fd_set rd;
232 233
270 271
		if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
271 272
			if(errno == EINTR)
272 273
				continue;
273 -
			else
274 -
				eprint("select failed\n");
274 +
			eprint("select failed\n");
275 275
		}
276 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 278
			case -1:
279 -
				strncpy(stext, strerror(errno), sizeof(stext));
280 -
				stext[sizeof(stext) - 1] = '\0';
279 +
				strncpy(stext, strerror(errno), sizeof stext - 1);
281 280
				readin = False;
282 281
				break;
283 282
			case 0:
284 -
				strncpy(stext, "EOF", sizeof(stext));
283 +
				strncpy(stext, "EOF", sizeof stext);
285 284
				readin = False;
286 285
				break;
287 286
			default:
288 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 292
			drawstatus();
291 293
		}
tag.c +2 −2
50 50
51 51
	if(rreg)
52 52
		return;
53 -
	len = sizeof(rule) / sizeof(rule[0]);
53 +
	len = sizeof rule / sizeof rule[0];
54 54
	rreg = emallocz(len * sizeof(RReg));
55 55
	for(i = 0; i < len; i++) {
56 56
		if(rule[i].clpattern) {
83 83
			c->tags[i] = trans->tags[i];
84 84
	}
85 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 87
				ch.res_class ? ch.res_class : "",
88 88
				ch.res_name ? ch.res_name : "", c->name);
89 89
		for(i = 0; !matched && i < len; i++)