History

gui-x11: cleanup error handling code, just call panic()

cinap_lenrek committed 9 years ago

Commit 72775a71 parent bdf96eb1 file · +14 −32Browse files

Unified · Split

gui-x11/x11.c+14−32
@@ -12,8 +12,6 @@ · 11 unmodified lines
1212
1313 #include <termios.h>
1414
15−#define argv0 "drawterm"
16−
1715 typedef struct Cursor Cursor;
1816
1917 #undef long
@@ -327,7 +325,6 @@ xinitscreen(void) · 307 unmodified lines
327325 Memimage *gscreen;
328326 int i, xsize, ysize;
329327 char *argv[2];
330− char *disp_val;
331328 Window rootwin;
332329 Rectangle r;
333330 XWMHints hints;
@@ -346,11 +343,8 @@ xinitscreen(void) · 12 unmodified lines
346343 xdrawable = 0;
347344
348345 xdisplay = XOpenDisplay(NULL);
349− if(xdisplay == 0){
350− iprint("xinitscreen: XOpenDisplay: %r [DISPLAY=%s]\n",
351− getenv("DISPLAY"));
352− exit(0);
353− }
346+ if(xdisplay == 0)
347+ panic("XOpenDisplay: %r [DISPLAY=%s]", getenv("DISPLAY"));
354348
355349 XSetErrorHandler(shutup);
356350 XSetIOErrorHandler(panicshutup);
@@ -373,13 +367,13 @@ xinitscreen(void) · 16 unmodified lines
373367 else if(XMatchVisualInfo(xdisplay, rootscreennum, 8, PseudoColor, &xvi)
374368 || XMatchVisualInfo(xdisplay, rootscreennum, 8, StaticColor, &xvi)){
375369 if(xscreendepth > 8)
376− panic("drawterm: can't deal with colormapped depth %d screens\n", xscreendepth);
370+ panic("can't deal with colormapped depth %d screens", xscreendepth);
377371 xvis = xvi.visual;
378372 xscreendepth = 8;
379373 }
380374 else{
381375 if(xscreendepth != 8)
382− panic("drawterm: can't deal with depth %d screens\n", xscreendepth);
376+ panic("can't deal with depth %d screens", xscreendepth);
383377 xvis = DefaultVisual(xdisplay, rootscreennum);
384378 }
385379
@@ -418,7 +412,7 @@ xinitscreen(void) · 32 unmodified lines
418412 }
419413 }
420414 if(xscreenchan == 0)
421− panic("drawterm: unknown screen pixel format\n");
415+ panic("unknown screen pixel format");
422416
423417 screen = DefaultScreenOfDisplay(xdisplay);
424418 xcmap = DefaultColormapOfScreen(screen);
@@ -489,23 +483,13 @@ xinitscreen(void) · 64 unmodified lines
489483 xgccopy = creategc(xscreenid);
490484
491485 xkmcon = XOpenDisplay(NULL);
492− if(xkmcon == 0){
493− disp_val = getenv("DISPLAY");
494− if(disp_val == 0)
495− disp_val = "not set";
496− iprint("drawterm: open %r, DISPLAY is %s\n", disp_val);
497− exit(0);
498− }
486+ if(xkmcon == 0)
487+ panic("XOpenDisplay: %r [DISPLAY=%s]", getenv("DISPLAY"));
499488 XkbSetDetectableAutoRepeat(xkmcon, True, NULL);
500489
501490 xsnarfcon = XOpenDisplay(NULL);
502− if(xsnarfcon == 0){
503− disp_val = getenv("DISPLAY");
504− if(disp_val == 0)
505− disp_val = "not set";
506− iprint("drawterm: open %r, DISPLAY is %s\n", disp_val);
507− exit(0);
508− }
491+ if(xsnarfcon == 0)
492+ panic("XOpenDisplay: %r [DISPLAY=%s]", getenv("DISPLAY"));
509493
510494 clipboard = XInternAtom(xkmcon, "CLIPBOARD", False);
511495 utf8string = XInternAtom(xkmcon, "UTF8_STRING", False);
@@ -607,7 +591,7 @@ initmap(Window w) · 95 unmodified lines
607591 c = map[19];
608592 /* find out index into colormap for our RGB */
609593 if(!XAllocColor(xdisplay, xcmap, &c))
610− panic("drawterm: screen-x11 can't alloc color");
594+ panic("screen-x11 can't alloc color");
611595
612596 p = c.pixel;
613597 pp = rgb2cmap((p>>16)&0xff,(p>>8)&0xff,p&0xff);
@@ -642,10 +626,8 @@ initmap(Window w) · 28 unmodified lines
642626 else {
643627 for(i = 0; i < 128; i++) {
644628 c = map7[i];
645− if(!XAllocColor(xdisplay, xcmap, &c)) {
646− iprint("drawterm: can't alloc colors in default map, don't use -7\n");
647− exit(0);
648− }
629+ if(!XAllocColor(xdisplay, xcmap, &c))
630+ panic("can't alloc colors in default map, don't use -7");
649631 plan9tox11[map7to8[i][0]] = c.pixel;
650632 plan9tox11[map7to8[i][1]] = c.pixel;
651633 x11toplan9[c.pixel] = map7to8[i][0];
@@ -653,7 +635,7 @@ initmap(Window w) · 1 unmodified line
653635 }
654636 }
655637 else
656− panic("drawterm: unsupported visual class %d\n", xvis->class);
638+ panic("unsupported visual class %d", xvis->class);
657639 }
658640
659641 static void
@@ -1163,7 +1145,7 @@ if(0) iprint("xselect target=%d requestor=%d property=%d selection=%d\n", · 503 unmodified lines
11631145 }else if(strcmp(name, "text/plain") == 0 || strcmp(name, "text/plain;charset=UTF-8") == 0){
11641146 goto text;
11651147 }else
1166− iprint("%s: cannot handle selection request for '%s' (%d)\n", argv0, name, (int)xe->target);
1148+ iprint("cannot handle selection request for '%s' (%d)\n", name, (int)xe->target);
11671149 }
11681150 r.xselection.property = None;
11691151 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t