renamed eprint die d5893f55
Anselm R Garbe · 2008-07-03 17:05 1 file(s) · +19 −19
dwm.c +19 −19
145 145
static void destroynotify(XEvent *e);
146 146
static void detach(Client *c);
147 147
static void detachstack(Client *c);
148 +
static void die(const char *errstr, ...);
148 149
static void drawbar(void);
149 150
static void drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]);
150 151
static void drawtext(const char *text, ulong col[ColLast], Bool invert);
151 152
static void enternotify(XEvent *e);
152 -
static void eprint(const char *errstr, ...);
153 153
static void expose(XEvent *e);
154 154
static void focus(Client *c);
155 155
static void focusin(XEvent *e);
343 343
	XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
344 344
	XSync(dpy, False);
345 345
	if(otherwm)
346 -
		eprint("dwm: another window manager is already running\n");
346 +
		die("dwm: another window manager is already running\n");
347 347
	XSetErrorHandler(NULL);
348 348
	xerrorxlib = XSetErrorHandler(xerror);
349 349
	XSync(dpy, False);
474 474
}
475 475
476 476
void
477 +
die(const char *errstr, ...) {
478 +
	va_list ap;
479 +
480 +
	va_start(ap, errstr);
481 +
	vfprintf(stderr, errstr, ap);
482 +
	va_end(ap);
483 +
	exit(EXIT_FAILURE);
484 +
}
485 +
486 +
void
477 487
drawbar(void) {
478 488
	int i, x;
479 489
581 591
}
582 592
583 593
void
584 -
eprint(const char *errstr, ...) {
585 -
	va_list ap;
586 -
587 -
	va_start(ap, errstr);
588 -
	vfprintf(stderr, errstr, ap);
589 -
	va_end(ap);
590 -
	exit(EXIT_FAILURE);
591 -
}
592 -
593 -
void
594 594
expose(XEvent *e) {
595 595
	XExposeEvent *ev = &e->xexpose;
596 596
667 667
	XColor color;
668 668
669 669
	if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
670 -
		eprint("error, cannot allocate color '%s'\n", colstr);
670 +
		die("error, cannot allocate color '%s'\n", colstr);
671 671
	return color.pixel;
672 672
}
673 673
793 793
		dc.font.xfont = NULL;
794 794
		if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))
795 795
		&& !(dc.font.xfont = XLoadQueryFont(dpy, "fixed")))
796 -
			eprint("error, cannot load font: '%s'\n", fontstr);
796 +
			die("error, cannot load font: '%s'\n", fontstr);
797 797
		dc.font.ascent = dc.font.xfont->ascent;
798 798
		dc.font.descent = dc.font.xfont->descent;
799 799
	}
877 877
	XWindowChanges wc;
878 878
879 879
	if(!(c = calloc(1, sizeof(Client))))
880 -
		eprint("fatal: could not calloc() %u bytes\n", sizeof(Client));
880 +
		die("fatal: could not calloc() %u bytes\n", sizeof(Client));
881 881
	c->win = w;
882 882
883 883
	/* geometry */
1216 1216
		if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
1217 1217
			if(errno == EINTR)
1218 1218
				continue;
1219 -
			eprint("select failed\n");
1219 +
			die("select failed\n");
1220 1220
		}
1221 1221
		if(FD_ISSET(STDIN_FILENO, &rd)) {
1222 1222
			switch((r = read(STDIN_FILENO, sbuf + offset, len - offset))) {
1695 1695
int
1696 1696
main(int argc, char *argv[]) {
1697 1697
	if(argc == 2 && !strcmp("-v", argv[1]))
1698 -
		eprint("dwm-"VERSION", © 2006-2008 dwm engineers, see LICENSE for details\n");
1698 +
		die("dwm-"VERSION", © 2006-2008 dwm engineers, see LICENSE for details\n");
1699 1699
	else if(argc != 1)
1700 -
		eprint("usage: dwm [-v]\n");
1700 +
		die("usage: dwm [-v]\n");
1701 1701
1702 1702
	if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
1703 1703
		fprintf(stderr, "warning: no locale support\n");
1704 1704
1705 1705
	if(!(dpy = XOpenDisplay(0)))
1706 -
		eprint("dwm: cannot open display\n");
1706 +
		die("dwm: cannot open display\n");
1707 1707
1708 1708
	checkotherwm();
1709 1709
	setup();