mirror of git://git.suckless.org/dwm
applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading.
This commit is contained in:
parent
27ef73507b
commit
61a1910f91
4
client.c
4
client.c
|
@ -361,12 +361,12 @@ updatetitle(Client *c) {
|
||||||
if(!name.nitems)
|
if(!name.nitems)
|
||||||
return;
|
return;
|
||||||
if(name.encoding == XA_STRING)
|
if(name.encoding == XA_STRING)
|
||||||
strncpy(c->name, (char *)name.value, sizeof(c->name));
|
strncpy(c->name, (char *)name.value, sizeof c->name);
|
||||||
else {
|
else {
|
||||||
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
||||||
&& n > 0 && *list)
|
&& n > 0 && *list)
|
||||||
{
|
{
|
||||||
strncpy(c->name, *list, sizeof(c->name));
|
strncpy(c->name, *list, sizeof c->name);
|
||||||
XFreeStringList(list);
|
XFreeStringList(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
draw.c
4
draw.c
|
@ -43,8 +43,8 @@ drawtext(const char *text, unsigned long col[ColLast], Bool ldot, Bool rdot) {
|
||||||
return;
|
return;
|
||||||
w = 0;
|
w = 0;
|
||||||
olen = len = strlen(text);
|
olen = len = strlen(text);
|
||||||
if(len >= sizeof(buf))
|
if(len >= sizeof buf)
|
||||||
len = sizeof(buf) - 1;
|
len = sizeof buf - 1;
|
||||||
memcpy(buf, text, len);
|
memcpy(buf, text, len);
|
||||||
buf[len] = 0;
|
buf[len] = 0;
|
||||||
h = dc.font.ascent + dc.font.descent;
|
h = dc.font.ascent + dc.font.descent;
|
||||||
|
|
4
event.c
4
event.c
|
@ -244,7 +244,7 @@ expose(XEvent *e) {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
keypress(XEvent *e) {
|
keypress(XEvent *e) {
|
||||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
static unsigned int len = sizeof key / sizeof key[0];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
XKeyEvent *ev = &e->xkey;
|
XKeyEvent *ev = &e->xkey;
|
||||||
|
@ -355,7 +355,7 @@ void (*handler[LASTEvent]) (XEvent *) = {
|
||||||
|
|
||||||
void
|
void
|
||||||
grabkeys(void) {
|
grabkeys(void) {
|
||||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
static unsigned int len = sizeof key / sizeof key[0];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
KeyCode code;
|
KeyCode code;
|
||||||
|
|
||||||
|
|
14
main.c
14
main.c
|
@ -227,6 +227,7 @@ xerror(Display *dpy, XErrorEvent *ee) {
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[]) {
|
main(int argc, char *argv[]) {
|
||||||
|
char *p;
|
||||||
int r, xfd;
|
int r, xfd;
|
||||||
fd_set rd;
|
fd_set rd;
|
||||||
|
|
||||||
|
@ -270,22 +271,23 @@ main(int argc, char *argv[]) {
|
||||||
if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
|
if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
|
||||||
if(errno == EINTR)
|
if(errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
else
|
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, sizeof(stext) - 1)) {
|
switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
|
||||||
case -1:
|
case -1:
|
||||||
strncpy(stext, strerror(errno), sizeof(stext));
|
strncpy(stext, strerror(errno), sizeof stext - 1);
|
||||||
stext[sizeof(stext) - 1] = '\0';
|
|
||||||
readin = False;
|
readin = False;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
strncpy(stext, "EOF", sizeof(stext));
|
strncpy(stext, "EOF", sizeof stext);
|
||||||
readin = False;
|
readin = False;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
stext[r - (stext[r - 1] == '\n' ? 1 : 0)] = '\0';
|
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();
|
drawstatus();
|
||||||
}
|
}
|
||||||
|
|
4
tag.c
4
tag.c
|
@ -50,7 +50,7 @@ initrregs(void) {
|
||||||
|
|
||||||
if(rreg)
|
if(rreg)
|
||||||
return;
|
return;
|
||||||
len = sizeof(rule) / sizeof(rule[0]);
|
len = sizeof rule / sizeof rule[0];
|
||||||
rreg = emallocz(len * sizeof(RReg));
|
rreg = emallocz(len * sizeof(RReg));
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
if(rule[i].clpattern) {
|
if(rule[i].clpattern) {
|
||||||
|
@ -83,7 +83,7 @@ settags(Client *c, Client *trans) {
|
||||||
c->tags[i] = trans->tags[i];
|
c->tags[i] = trans->tags[i];
|
||||||
}
|
}
|
||||||
else if(XGetClassHint(dpy, c->win, &ch)) {
|
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_class ? ch.res_class : "",
|
||||||
ch.res_name ? ch.res_name : "", c->name);
|
ch.res_name ? ch.res_name : "", c->name);
|
||||||
for(i = 0; !matched && i < len; i++)
|
for(i = 0; !matched && i < len; i++)
|
||||||
|
|
Loading…
Reference in New Issue