helpful errors

This commit is contained in:
Connor Lane Smith
2011-05-06 21:13:02 +01:00
parent 210b303941
commit cd3b4915c3
2 changed files with 8 additions and 3 deletions

7
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");