X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=draw.c;h=d35d4c2deda588b0241a97ba229463f7714ddaeb;hb=86019c58555b5d9514cfe2eba14248588a812f16;hp=85c1279a3b40dd73e501914119216bdaa198154c;hpb=a0a99d10e1a019f74a8b2af4d5f8b47348e08a75;p=dmenu.git diff --git a/draw.c b/draw.c index 85c1279..d35d4c2 100644 --- a/draw.c +++ b/draw.c @@ -7,11 +7,9 @@ #include #include "draw.h" -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define FG(dc, col) ((col)[(dc)->invert ? ColBG : ColFG]) -#define BG(dc, col) ((col)[(dc)->invert ? ColFG : ColBG]) -#define DEFFONT "fixed" +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define DEFFONT "fixed" static Bool loadfont(DC *dc, const char *fontstr); @@ -70,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); } @@ -102,16 +105,13 @@ initdc(void) { if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) weprintf("no locale support\n"); - if(!(dc = malloc(sizeof *dc))) - eprintf("cannot malloc %u bytes\n", sizeof *dc); + if(!(dc = calloc(1, sizeof *dc))) + eprintf("cannot malloc %u bytes:", sizeof *dc); if(!(dc->dpy = XOpenDisplay(NULL))) eprintf("cannot open display\n"); dc->gc = XCreateGC(dc->dpy, DefaultRootWindow(dc->dpy), 0, NULL); XSetLineAttributes(dc->dpy, dc->gc, 1, LineSolid, CapButt, JoinMiter); - dc->font.xfont = NULL; - dc->font.set = NULL; - dc->canvas = None; return dc; } @@ -189,7 +189,7 @@ void weprintf(const char *fmt, ...) { va_list ap; - fprintf(stderr, "%s: warning: ", progname); + fprintf(stderr, "%s: ", progname); va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap);