Merge pull request #35 from freestyl3r/master

Silence the warning about not checking fgets return value
This commit is contained in:
Giuseppe 2014-02-05 12:42:30 +00:00
commit 38183db9a1

24
bar.c
View File

@ -155,41 +155,39 @@ parse (char *text)
xcb_fill_rect (clear_gc, 0, 0, bar_width, BAR_HEIGHT); xcb_fill_rect (clear_gc, 0, 0, bar_width, BAR_HEIGHT);
for (;;) { for (;;) {
if (*p == '\0') if (*p == '\0' || *p == '\n')
return;
if (*p == '\n')
return; return;
if (*p == '\\' && p++ && *p != '\\' && strchr (control_characters, *p)) { if (*p == '\\' && p++ && *p != '\\' && strchr (control_characters, *p)) {
switch (*p++) { switch (*p++) {
case 'f': case 'f':
xcb_set_fg (isdigit(*p) ? (*p)-'0' : 11); xcb_set_fg (isdigit(*p) ? *p-'0' : 11);
p++; p++;
break; break;
case 'b': case 'b':
xcb_set_bg (isdigit(*p) ? (*p)-'0' : 10); xcb_set_bg (isdigit(*p) ? *p-'0' : 10);
p++; p++;
break; break;
case 'u': case 'u':
xcb_set_ud (isdigit(*p) ? (*p)-'0' : 10); xcb_set_ud (isdigit(*p) ? *p-'0' : 10);
p++; p++;
break; break;
#if XINERAMA #if XINERAMA
case 's': case 's':
if ((*p) == 'r') { if (*p == 'r') {
screen = &screens[num_screens - 1]; screen = &screens[num_screens - 1];
} else if ((*p) == 'l') { } else if (*p == 'l') {
screen = &screens[0]; screen = &screens[0];
} else if ((*p) == 'n') { } else if (*p == 'n') {
if (screen == &screens[num_screens - 1]) if (screen == &screens[num_screens - 1])
break; break;
screen++; screen++;
} else if ((*p) == 'p') { } else if (*p == 'p') {
if (screen == screens) if (screen == screens)
break; break;
screen--; screen--;
} else if (isdigit(*p)) { } else if (isdigit(*p)) {
int index = (*p)-'0'; int index = *p-'0';
if (index < num_screens) { if (index < num_screens) {
screen = &screens[index]; screen = &screens[index];
} else { } else {
@ -568,7 +566,9 @@ main (int argc, char **argv)
else break; /* ...bail out */ else break; /* ...bail out */
} }
if (pollin[0].revents & POLLIN) { /* New input, process it */ if (pollin[0].revents & POLLIN) { /* New input, process it */
fgets (input, sizeof(input), stdin); if (fgets (input, sizeof(input), stdin) == NULL)
break; /* EOF received */
parse (input); parse (input);
redraw = 1; redraw = 1;
} }