X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fgeneral.c;h=2424cc60ea24fd4089d8d434f6c3fd48a1c44303;hb=445b1925e3d2e239740d7765e5892d0671174e8e;hp=7ec80a84688446b8831edb30499de5bdf5f165d4;hpb=31509b0d5654baf2e2c3438cae90c30e3dd00c17;p=i3%2Fi3status diff --git a/src/general.c b/src/general.c index 7ec80a8..2424cc6 100644 --- a/src/general.c +++ b/src/general.c @@ -1,4 +1,4 @@ -// vim:ts=8:expandtab +// vim:ts=4:sw=4:expandtab #include #include #include @@ -6,6 +6,7 @@ #include #include #include +#include #include "i3status.h" @@ -14,18 +15,18 @@ * */ bool slurp(const char *filename, char *destination, int size) { - int fd; + int fd; - if ((fd = open(filename, O_RDONLY)) == -1) - return false; + if ((fd = open(filename, O_RDONLY)) == -1) + return false; - /* We need one byte for the trailing 0 byte */ - int n = read(fd, destination, size-1); - if (n != -1) - destination[n] = '\0'; - (void)close(fd); + /* We need one byte for the trailing 0 byte */ + int n = read(fd, destination, size - 1); + if (n != -1) + destination[n] = '\0'; + (void)close(fd); - return true; + return true; } /* @@ -34,15 +35,15 @@ bool slurp(const char *filename, char *destination, int size) { * */ char *skip_character(char *input, char character, int amount) { - char *walk; - size_t len = strlen(input); - int blanks = 0; + char *walk; + size_t len = strlen(input); + int blanks = 0; - for (walk = input; ((size_t)(walk - input) < len) && (blanks < amount); walk++) - if (*walk == character) - blanks++; + for (walk = input; ((size_t)(walk - input) < len) && (blanks < amount); walk++) + if (*walk == character) + blanks++; - return (walk == input ? walk : walk-1); + return (walk == input ? walk : walk - 1); } /* @@ -50,12 +51,10 @@ char *skip_character(char *input, char character, int amount) { * */ void die(const char *fmt, ...) { - char buffer[512]; - va_list ap; - va_start(ap, fmt); - (void)vsnprintf(buffer, sizeof(buffer), fmt, ap); - va_end(ap); - - fprintf(stderr, "%s", buffer); - exit(EXIT_FAILURE); + va_list ap; + va_start(ap, fmt); + (void)vfprintf(stderr, fmt, ap); + va_end(ap); + + exit(EXIT_FAILURE); }