1
0

renamed eprint die

This commit is contained in:
Anselm R Garbe 2008-07-03 17:05:56 +01:00
parent f529d41ca1
commit d5893f55be

38
dwm.c
View File

@ -145,11 +145,11 @@ static void configurerequest(XEvent *e);
static void destroynotify(XEvent *e); static void destroynotify(XEvent *e);
static void detach(Client *c); static void detach(Client *c);
static void detachstack(Client *c); static void detachstack(Client *c);
static void die(const char *errstr, ...);
static void drawbar(void); static void drawbar(void);
static void drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]); static void drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]);
static void drawtext(const char *text, ulong col[ColLast], Bool invert); static void drawtext(const char *text, ulong col[ColLast], Bool invert);
static void enternotify(XEvent *e); static void enternotify(XEvent *e);
static void eprint(const char *errstr, ...);
static void expose(XEvent *e); static void expose(XEvent *e);
static void focus(Client *c); static void focus(Client *c);
static void focusin(XEvent *e); static void focusin(XEvent *e);
@ -343,7 +343,7 @@ checkotherwm(void) {
XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask); XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
XSync(dpy, False); XSync(dpy, False);
if(otherwm) if(otherwm)
eprint("dwm: another window manager is already running\n"); die("dwm: another window manager is already running\n");
XSetErrorHandler(NULL); XSetErrorHandler(NULL);
xerrorxlib = XSetErrorHandler(xerror); xerrorxlib = XSetErrorHandler(xerror);
XSync(dpy, False); XSync(dpy, False);
@ -473,6 +473,16 @@ detachstack(Client *c) {
*tc = c->snext; *tc = c->snext;
} }
void
die(const char *errstr, ...) {
va_list ap;
va_start(ap, errstr);
vfprintf(stderr, errstr, ap);
va_end(ap);
exit(EXIT_FAILURE);
}
void void
drawbar(void) { drawbar(void) {
int i, x; int i, x;
@ -580,16 +590,6 @@ enternotify(XEvent *e) {
focus(NULL); focus(NULL);
} }
void
eprint(const char *errstr, ...) {
va_list ap;
va_start(ap, errstr);
vfprintf(stderr, errstr, ap);
va_end(ap);
exit(EXIT_FAILURE);
}
void void
expose(XEvent *e) { expose(XEvent *e) {
XExposeEvent *ev = &e->xexpose; XExposeEvent *ev = &e->xexpose;
@ -667,7 +667,7 @@ getcolor(const char *colstr) {
XColor color; XColor color;
if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
eprint("error, cannot allocate color '%s'\n", colstr); die("error, cannot allocate color '%s'\n", colstr);
return color.pixel; return color.pixel;
} }
@ -793,7 +793,7 @@ initfont(const char *fontstr) {
dc.font.xfont = NULL; dc.font.xfont = NULL;
if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)) if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))
&& !(dc.font.xfont = XLoadQueryFont(dpy, "fixed"))) && !(dc.font.xfont = XLoadQueryFont(dpy, "fixed")))
eprint("error, cannot load font: '%s'\n", fontstr); die("error, cannot load font: '%s'\n", fontstr);
dc.font.ascent = dc.font.xfont->ascent; dc.font.ascent = dc.font.xfont->ascent;
dc.font.descent = dc.font.xfont->descent; dc.font.descent = dc.font.xfont->descent;
} }
@ -877,7 +877,7 @@ manage(Window w, XWindowAttributes *wa) {
XWindowChanges wc; XWindowChanges wc;
if(!(c = calloc(1, sizeof(Client)))) if(!(c = calloc(1, sizeof(Client))))
eprint("fatal: could not calloc() %u bytes\n", sizeof(Client)); die("fatal: could not calloc() %u bytes\n", sizeof(Client));
c->win = w; c->win = w;
/* geometry */ /* geometry */
@ -1216,7 +1216,7 @@ run(void) {
if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) { if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
if(errno == EINTR) if(errno == EINTR)
continue; continue;
eprint("select failed\n"); die("select failed\n");
} }
if(FD_ISSET(STDIN_FILENO, &rd)) { if(FD_ISSET(STDIN_FILENO, &rd)) {
switch((r = read(STDIN_FILENO, sbuf + offset, len - offset))) { switch((r = read(STDIN_FILENO, sbuf + offset, len - offset))) {
@ -1695,15 +1695,15 @@ zoom(const Arg *arg) {
int int
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
if(argc == 2 && !strcmp("-v", argv[1])) if(argc == 2 && !strcmp("-v", argv[1]))
eprint("dwm-"VERSION", © 2006-2008 dwm engineers, see LICENSE for details\n"); die("dwm-"VERSION", © 2006-2008 dwm engineers, see LICENSE for details\n");
else if(argc != 1) else if(argc != 1)
eprint("usage: dwm [-v]\n"); die("usage: dwm [-v]\n");
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fprintf(stderr, "warning: no locale support\n"); fprintf(stderr, "warning: no locale support\n");
if(!(dpy = XOpenDisplay(0))) if(!(dpy = XOpenDisplay(0)))
eprint("dwm: cannot open display\n"); die("dwm: cannot open display\n");
checkotherwm(); checkotherwm();
setup(); setup();