diff options
| author | Anselm R Garbe <garbeam@gmail.com> | 2008-07-03 17:05:56 +0100 |
|---|---|---|
| committer | Anselm R Garbe <garbeam@gmail.com> | 2008-07-03 17:05:56 +0100 |
| commit | d5893f55bec202e5dbb5ca4ef1f205cec5eb22c6 (patch) | |
| tree | b9c45c838352beb4731035ba3fa34cb3f7ade1ae | |
| parent | simplified detach() (diff) | |
| download | dwm-d5893f55bec202e5dbb5ca4ef1f205cec5eb22c6.tar.gz dwm-d5893f55bec202e5dbb5ca4ef1f205cec5eb22c6.zip | |
renamed eprint die
Diffstat (limited to '')
| -rw-r--r-- | dwm.c | 38 |
1 files changed, 19 insertions, 19 deletions
| @@ -145,11 +145,11 @@ static void configurerequest(XEvent *e); | |||
| 145 | static void destroynotify(XEvent *e); | 145 | static void destroynotify(XEvent *e); |
| 146 | static void detach(Client *c); | 146 | static void detach(Client *c); |
| 147 | static void detachstack(Client *c); | 147 | static void detachstack(Client *c); |
| 148 | static void die(const char *errstr, ...); | ||
| 148 | static void drawbar(void); | 149 | static void drawbar(void); |
| 149 | static void drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]); | 150 | static void drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]); |
| 150 | static void drawtext(const char *text, ulong col[ColLast], Bool invert); | 151 | static void drawtext(const char *text, ulong col[ColLast], Bool invert); |
| 151 | static void enternotify(XEvent *e); | 152 | static void enternotify(XEvent *e); |
| 152 | static void eprint(const char *errstr, ...); | ||
| 153 | static void expose(XEvent *e); | 153 | static void expose(XEvent *e); |
| 154 | static void focus(Client *c); | 154 | static void focus(Client *c); |
| 155 | static void focusin(XEvent *e); | 155 | static void focusin(XEvent *e); |
| @@ -343,7 +343,7 @@ checkotherwm(void) { | |||
| 343 | XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask); | 343 | XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask); |
| 344 | XSync(dpy, False); | 344 | XSync(dpy, False); |
| 345 | if(otherwm) | 345 | if(otherwm) |
| 346 | eprint("dwm: another window manager is already running\n"); | 346 | die("dwm: another window manager is already running\n"); |
| 347 | XSetErrorHandler(NULL); | 347 | XSetErrorHandler(NULL); |
| 348 | xerrorxlib = XSetErrorHandler(xerror); | 348 | xerrorxlib = XSetErrorHandler(xerror); |
| 349 | XSync(dpy, False); | 349 | XSync(dpy, False); |
| @@ -474,6 +474,16 @@ detachstack(Client *c) { | |||
| 474 | } | 474 | } |
| 475 | 475 | ||
| 476 | void | 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 | drawbar(void) { | 487 | drawbar(void) { |
| 478 | int i, x; | 488 | int i, x; |
| 479 | 489 | ||
| @@ -581,16 +591,6 @@ enternotify(XEvent *e) { | |||
| 581 | } | 591 | } |
| 582 | 592 | ||
| 583 | void | 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 | expose(XEvent *e) { | 594 | expose(XEvent *e) { |
| 595 | XExposeEvent *ev = &e->xexpose; | 595 | XExposeEvent *ev = &e->xexpose; |
| 596 | 596 | ||
| @@ -667,7 +667,7 @@ getcolor(const char *colstr) { | |||
| 667 | XColor color; | 667 | XColor color; |
| 668 | 668 | ||
| 669 | if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) | 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 | return color.pixel; | 671 | return color.pixel; |
| 672 | } | 672 | } |
| 673 | 673 | ||
| @@ -793,7 +793,7 @@ initfont(const char *fontstr) { | |||
| 793 | dc.font.xfont = NULL; | 793 | dc.font.xfont = NULL; |
| 794 | if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)) | 794 | if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)) |
| 795 | && !(dc.font.xfont = XLoadQueryFont(dpy, "fixed"))) | 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 | dc.font.ascent = dc.font.xfont->ascent; | 797 | dc.font.ascent = dc.font.xfont->ascent; |
| 798 | dc.font.descent = dc.font.xfont->descent; | 798 | dc.font.descent = dc.font.xfont->descent; |
| 799 | } | 799 | } |
| @@ -877,7 +877,7 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 877 | XWindowChanges wc; | 877 | XWindowChanges wc; |
| 878 | 878 | ||
| 879 | if(!(c = calloc(1, sizeof(Client)))) | 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 | c->win = w; | 881 | c->win = w; |
| 882 | 882 | ||
| 883 | /* geometry */ | 883 | /* geometry */ |
| @@ -1216,7 +1216,7 @@ run(void) { | |||
| 1216 | if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) { | 1216 | if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) { |
| 1217 | if(errno == EINTR) | 1217 | if(errno == EINTR) |
| 1218 | continue; | 1218 | continue; |
| 1219 | eprint("select failed\n"); | 1219 | die("select failed\n"); |
| 1220 | } | 1220 | } |
| 1221 | if(FD_ISSET(STDIN_FILENO, &rd)) { | 1221 | if(FD_ISSET(STDIN_FILENO, &rd)) { |
| 1222 | switch((r = read(STDIN_FILENO, sbuf + offset, len - offset))) { | 1222 | switch((r = read(STDIN_FILENO, sbuf + offset, len - offset))) { |
| @@ -1695,15 +1695,15 @@ zoom(const Arg *arg) { | |||
| 1695 | int | 1695 | int |
| 1696 | main(int argc, char *argv[]) { | 1696 | main(int argc, char *argv[]) { |
| 1697 | if(argc == 2 && !strcmp("-v", argv[1])) | 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 | else if(argc != 1) | 1699 | else if(argc != 1) |
| 1700 | eprint("usage: dwm [-v]\n"); | 1700 | die("usage: dwm [-v]\n"); |
| 1701 | 1701 | ||
| 1702 | if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) | 1702 | if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) |
| 1703 | fprintf(stderr, "warning: no locale support\n"); | 1703 | fprintf(stderr, "warning: no locale support\n"); |
| 1704 | 1704 | ||
| 1705 | if(!(dpy = XOpenDisplay(0))) | 1705 | if(!(dpy = XOpenDisplay(0))) |
| 1706 | eprint("dwm: cannot open display\n"); | 1706 | die("dwm: cannot open display\n"); |
| 1707 | 1707 | ||
| 1708 | checkotherwm(); | 1708 | checkotherwm(); |
| 1709 | setup(); | 1709 | setup(); |
