]> git.armaanb.net Git - dmenu.git/commitdiff
helpful errors
authorConnor Lane Smith <cls@lubutu.com>
Fri, 6 May 2011 20:13:02 +0000 (21:13 +0100)
committerConnor Lane Smith <cls@lubutu.com>
Fri, 6 May 2011 20:13:02 +0000 (21:13 +0100)
dmenu.c
draw.c

diff --git a/dmenu.c b/dmenu.c
index d8ef88f132866a4c3c7f67a7670218abe15aa9ce..5be73f73bbc3b95c205c5453eeaf6131d9253be6 100644 (file)
--- a/dmenu.c
+++ b/dmenu.c
@@ -440,9 +440,9 @@ readstdin(void) {
                if((p = strchr(buf, '\n')))
                        *p = '\0';
                if(!(item = calloc(1, sizeof *item)))
-                       eprintf("cannot malloc %u bytes\n", sizeof *item);
+                       eprintf("cannot malloc %u bytes:", sizeof *item);
                if(!(item->text = strdup(buf)))
-                       eprintf("cannot strdup %u bytes\n", strlen(buf)+1);
+                       eprintf("cannot strdup %u bytes:", strlen(buf)+1);
                inputw = MAX(inputw, textw(dc, item->text));
        }
 }
diff --git a/draw.c b/draw.c
index 80a50743cad683237b2ffa8b27891395ea9cce41..83ced4b78fed48c50c7e0e94b2fb579c6ac03fe8 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -68,6 +68,11 @@ eprintf(const char *fmt, ...) {
        va_start(ap, fmt);
        vfprintf(stderr, fmt, ap);
        va_end(ap);
+
+       if(fmt[strlen(fmt)-1] == ':') {
+               fputc(' ', stderr);
+               perror(NULL);
+       }
        exit(EXIT_FAILURE);
 }
 
@@ -101,7 +106,7 @@ initdc(void) {
        if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
                weprintf("no locale support\n");
        if(!(dc = calloc(1, sizeof *dc)))
-               eprintf("cannot malloc %u bytes\n", sizeof *dc);
+               eprintf("cannot malloc %u bytes:", sizeof *dc);
        if(!(dc->dpy = XOpenDisplay(NULL)))
                eprintf("cannot open display\n");