My dmenu build
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

683 lines
17 KiB

  1. /* See LICENSE file for copyright and license details. */
  2. #include <ctype.h>
  3. #include <locale.h>
  4. #include <stdbool.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <strings.h>
  9. #include <time.h>
  10. #include <X11/Xlib.h>
  11. #include <X11/Xatom.h>
  12. #include <X11/Xutil.h>
  13. #ifdef XINERAMA
  14. #include <X11/extensions/Xinerama.h>
  15. #endif
  16. #include <X11/Xft/Xft.h>
  17. #include "drw.h"
  18. #include "util.h"
  19. /* macros */
  20. #define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
  21. * MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
  22. #define LENGTH(X) (sizeof X / sizeof X[0])
  23. #define TEXTNW(X,N) (drw_font_getexts_width(drw->fonts[0], (X), (N)))
  24. #define TEXTW(X) (drw_text(drw, 0, 0, 0, 0, (X), 0) + drw->fonts[0]->h)
  25. /* enums */
  26. enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
  27. struct item {
  28. char *text;
  29. struct item *left, *right;
  30. bool out;
  31. };
  32. static char text[BUFSIZ] = "";
  33. static int bh, mw, mh;
  34. static int sw, sh; /* X display screen geometry width, height */
  35. static int inputw, promptw;
  36. static size_t cursor;
  37. static struct item *items = NULL;
  38. static struct item *matches, *matchend;
  39. static struct item *prev, *curr, *next, *sel;
  40. static int mon = -1, screen;
  41. static Atom clip, utf8;
  42. static Display *dpy;
  43. static Window root, win;
  44. static XIC xic;
  45. static ClrScheme scheme[SchemeLast];
  46. static Drw *drw;
  47. #include "config.h"
  48. static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
  49. static char *(*fstrstr)(const char *, const char *) = strstr;
  50. static void
  51. appenditem(struct item *item, struct item **list, struct item **last)
  52. {
  53. if (*last)
  54. (*last)->right = item;
  55. else
  56. *list = item;
  57. item->left = *last;
  58. item->right = NULL;
  59. *last = item;
  60. }
  61. static void
  62. calcoffsets(void)
  63. {
  64. int i, n;
  65. if (lines > 0)
  66. n = lines * bh;
  67. else
  68. n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
  69. /* calculate which items will begin the next page and previous page */
  70. for (i = 0, next = curr; next; next = next->right)
  71. if ((i += (lines > 0) ? bh : MIN(TEXTW(next->text), n)) > n)
  72. break;
  73. for (i = 0, prev = curr; prev && prev->left; prev = prev->left)
  74. if ((i += (lines > 0) ? bh : MIN(TEXTW(prev->left->text), n)) > n)
  75. break;
  76. }
  77. static void
  78. cleanup(void)
  79. {
  80. XUngrabKey(dpy, AnyKey, AnyModifier, root);
  81. drw_clr_free(scheme[SchemeNorm].bg);
  82. drw_clr_free(scheme[SchemeNorm].fg);
  83. drw_clr_free(scheme[SchemeSel].fg);
  84. drw_clr_free(scheme[SchemeSel].bg);
  85. drw_clr_free(scheme[SchemeOut].fg);
  86. drw_clr_free(scheme[SchemeOut].bg);
  87. drw_free(drw);
  88. XSync(dpy, False);
  89. XCloseDisplay(dpy);
  90. }
  91. static char *
  92. cistrstr(const char *s, const char *sub)
  93. {
  94. size_t len;
  95. for (len = strlen(sub); *s; s++)
  96. if (!strncasecmp(s, sub, len))
  97. return (char *)s;
  98. return NULL;
  99. }
  100. static void
  101. drawmenu(void)
  102. {
  103. int curpos;
  104. struct item *item;
  105. int x = 0, y = 0, h = bh, w;
  106. drw_setscheme(drw, &scheme[SchemeNorm]);
  107. drw_rect(drw, 0, 0, mw, mh, 1, 1, 1);
  108. if (prompt && *prompt) {
  109. drw_setscheme(drw, &scheme[SchemeSel]);
  110. drw_text(drw, x, 0, promptw, bh, prompt, 0);
  111. x += promptw;
  112. }
  113. /* draw input field */
  114. w = (lines > 0 || !matches) ? mw - x : inputw;
  115. drw_setscheme(drw, &scheme[SchemeNorm]);
  116. drw_text(drw, x, 0, w, bh, text, 0);
  117. if ((curpos = TEXTNW(text, cursor) + bh / 2 - 2) < w) {
  118. drw_setscheme(drw, &scheme[SchemeNorm]);
  119. drw_rect(drw, x + curpos + 2, 2, 1, bh - 4, 1, 1, 0);
  120. }
  121. if (lines > 0) {
  122. /* draw vertical list */
  123. w = mw - x;
  124. for (item = curr; item != next; item = item->right) {
  125. y += h;
  126. if (item == sel)
  127. drw_setscheme(drw, &scheme[SchemeSel]);
  128. else if (item->out)
  129. drw_setscheme(drw, &scheme[SchemeOut]);
  130. else
  131. drw_setscheme(drw, &scheme[SchemeNorm]);
  132. drw_text(drw, x, y, w, bh, item->text, 0);
  133. }
  134. } else if (matches) {
  135. /* draw horizontal list */
  136. x += inputw;
  137. w = TEXTW("<");
  138. if (curr->left) {
  139. drw_setscheme(drw, &scheme[SchemeNorm]);
  140. drw_text(drw, x, 0, w, bh, "<", 0);
  141. }
  142. for (item = curr; item != next; item = item->right) {
  143. x += w;
  144. w = MIN(TEXTW(item->text), mw - x - TEXTW(">"));
  145. if (item == sel)
  146. drw_setscheme(drw, &scheme[SchemeSel]);
  147. else if (item->out)
  148. drw_setscheme(drw, &scheme[SchemeOut]);
  149. else
  150. drw_setscheme(drw, &scheme[SchemeNorm]);
  151. drw_text(drw, x, 0, w, bh, item->text, 0);
  152. }
  153. w = TEXTW(">");
  154. x = mw - w;
  155. if (next) {
  156. drw_setscheme(drw, &scheme[SchemeNorm]);
  157. drw_text(drw, x, 0, w, bh, ">", 0);
  158. }
  159. }
  160. drw_map(drw, win, 0, 0, mw, mh);
  161. }
  162. static void
  163. grabkeyboard(void)
  164. {
  165. struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
  166. int i;
  167. /* try to grab keyboard, we may have to wait for another process to ungrab */
  168. for (i = 0; i < 1000; i++) {
  169. if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True,
  170. GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
  171. return;
  172. nanosleep(&ts, NULL);
  173. }
  174. die("cannot grab keyboard\n");
  175. }
  176. static void
  177. match(void)
  178. {
  179. static char **tokv = NULL;
  180. static int tokn = 0;
  181. char buf[sizeof text], *s;
  182. int i, tokc = 0;
  183. size_t len, textsize;
  184. struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
  185. strcpy(buf, text);
  186. /* separate input text into tokens to be matched individually */
  187. for (s = strtok(buf, " "); s; tokv[tokc - 1] = s, s = strtok(NULL, " "))
  188. if (++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof *tokv)))
  189. die("cannot realloc %u bytes\n", tokn * sizeof *tokv);
  190. len = tokc ? strlen(tokv[0]) : 0;
  191. matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
  192. textsize = strlen(text) + 1;
  193. for (item = items; item && item->text; item++) {
  194. for (i = 0; i < tokc; i++)
  195. if (!fstrstr(item->text, tokv[i]))
  196. break;
  197. if (i != tokc) /* not all tokens match */
  198. continue;
  199. /* exact matches go first, then prefixes, then substrings */
  200. if (!tokc || !fstrncmp(text, item->text, textsize))
  201. appenditem(item, &matches, &matchend);
  202. else if (!fstrncmp(tokv[0], item->text, len))
  203. appenditem(item, &lprefix, &prefixend);
  204. else
  205. appenditem(item, &lsubstr, &substrend);
  206. }
  207. if (lprefix) {
  208. if (matches) {
  209. matchend->right = lprefix;
  210. lprefix->left = matchend;
  211. } else
  212. matches = lprefix;
  213. matchend = prefixend;
  214. }
  215. if (lsubstr) {
  216. if (matches) {
  217. matchend->right = lsubstr;
  218. lsubstr->left = matchend;
  219. } else
  220. matches = lsubstr;
  221. matchend = substrend;
  222. }
  223. curr = sel = matches;
  224. calcoffsets();
  225. }
  226. static void
  227. insert(const char *str, ssize_t n)
  228. {
  229. if (strlen(text) + n > sizeof text - 1)
  230. return;
  231. /* move existing text out of the way, insert new text, and update cursor */
  232. memmove(&text[cursor + n], &text[cursor], sizeof text - cursor - MAX(n, 0));
  233. if (n > 0)
  234. memcpy(&text[cursor], str, n);
  235. cursor += n;
  236. match();
  237. }
  238. static size_t
  239. nextrune(int inc)
  240. {
  241. ssize_t n;
  242. /* return location of next utf8 rune in the given direction (+1 or -1) */
  243. for (n = cursor + inc; n + inc >= 0 && (text[n] & 0xc0) == 0x80; n += inc)
  244. ;
  245. return n;
  246. }
  247. static void
  248. keypress(XKeyEvent *ev)
  249. {
  250. char buf[32];
  251. int len;
  252. KeySym ksym = NoSymbol;
  253. Status status;
  254. len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
  255. if (status == XBufferOverflow)
  256. return;
  257. if (ev->state & ControlMask)
  258. switch(ksym) {
  259. case XK_a: ksym = XK_Home; break;
  260. case XK_b: ksym = XK_Left; break;
  261. case XK_c: ksym = XK_Escape; break;
  262. case XK_d: ksym = XK_Delete; break;
  263. case XK_e: ksym = XK_End; break;
  264. case XK_f: ksym = XK_Right; break;
  265. case XK_g: ksym = XK_Escape; break;
  266. case XK_h: ksym = XK_BackSpace; break;
  267. case XK_i: ksym = XK_Tab; break;
  268. case XK_j: /* fallthrough */
  269. case XK_J: /* fallthrough */
  270. case XK_m: /* fallthrough */
  271. case XK_M: ksym = XK_Return; ev->state &= ~ControlMask; break;
  272. case XK_n: ksym = XK_Down; break;
  273. case XK_p: ksym = XK_Up; break;
  274. case XK_k: /* delete right */
  275. text[cursor] = '\0';
  276. match();
  277. break;
  278. case XK_u: /* delete left */
  279. insert(NULL, 0 - cursor);
  280. break;
  281. case XK_w: /* delete word */
  282. while (cursor > 0 && text[nextrune(-1)] == ' ')
  283. insert(NULL, nextrune(-1) - cursor);
  284. while (cursor > 0 && text[nextrune(-1)] != ' ')
  285. insert(NULL, nextrune(-1) - cursor);
  286. break;
  287. case XK_y: /* paste selection */
  288. case XK_Y:
  289. XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
  290. utf8, utf8, win, CurrentTime);
  291. return;
  292. case XK_Return:
  293. case XK_KP_Enter:
  294. break;
  295. case XK_bracketleft:
  296. cleanup();
  297. exit(1);
  298. default:
  299. return;
  300. }
  301. else if (ev->state & Mod1Mask)
  302. switch(ksym) {
  303. case XK_g: ksym = XK_Home; break;
  304. case XK_G: ksym = XK_End; break;
  305. case XK_h: ksym = XK_Up; break;
  306. case XK_j: ksym = XK_Next; break;
  307. case XK_k: ksym = XK_Prior; break;
  308. case XK_l: ksym = XK_Down; break;
  309. default:
  310. return;
  311. }
  312. switch(ksym) {
  313. default:
  314. if (!iscntrl(*buf))
  315. insert(buf, len);
  316. break;
  317. case XK_Delete:
  318. if (text[cursor] == '\0')
  319. return;
  320. cursor = nextrune(+1);
  321. /* fallthrough */
  322. case XK_BackSpace:
  323. if (cursor == 0)
  324. return;
  325. insert(NULL, nextrune(-1) - cursor);
  326. break;
  327. case XK_End:
  328. if (text[cursor] != '\0') {
  329. cursor = strlen(text);
  330. break;
  331. }
  332. if (next) {
  333. /* jump to end of list and position items in reverse */
  334. curr = matchend;
  335. calcoffsets();
  336. curr = prev;
  337. calcoffsets();
  338. while (next && (curr = curr->right))
  339. calcoffsets();
  340. }
  341. sel = matchend;
  342. break;
  343. case XK_Escape:
  344. cleanup();
  345. exit(1);
  346. case XK_Home:
  347. if (sel == matches) {
  348. cursor = 0;
  349. break;
  350. }
  351. sel = curr = matches;
  352. calcoffsets();
  353. break;
  354. case XK_Left:
  355. if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
  356. cursor = nextrune(-1);
  357. break;
  358. }
  359. if (lines > 0)
  360. return;
  361. /* fallthrough */
  362. case XK_Up:
  363. if (sel && sel->left && (sel = sel->left)->right == curr) {
  364. curr = prev;
  365. calcoffsets();
  366. }
  367. break;
  368. case XK_Next:
  369. if (!next)
  370. return;
  371. sel = curr = next;
  372. calcoffsets();
  373. break;
  374. case XK_Prior:
  375. if (!prev)
  376. return;
  377. sel = curr = prev;
  378. calcoffsets();
  379. break;
  380. case XK_Return:
  381. case XK_KP_Enter:
  382. puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
  383. if (!(ev->state & ControlMask)) {
  384. cleanup();
  385. exit(0);
  386. }
  387. if (sel)
  388. sel->out = true;
  389. break;
  390. case XK_Right:
  391. if (text[cursor] != '\0') {
  392. cursor = nextrune(+1);
  393. break;
  394. }
  395. if (lines > 0)
  396. return;
  397. /* fallthrough */
  398. case XK_Down:
  399. if (sel && sel->right && (sel = sel->right) == next) {
  400. curr = next;
  401. calcoffsets();
  402. }
  403. break;
  404. case XK_Tab:
  405. if (!sel)
  406. return;
  407. strncpy(text, sel->text, sizeof text - 1);
  408. text[sizeof text - 1] = '\0';
  409. cursor = strlen(text);
  410. match();
  411. break;
  412. }
  413. drawmenu();
  414. }
  415. static void
  416. paste(void)
  417. {
  418. char *p, *q;
  419. int di;
  420. unsigned long dl;
  421. Atom da;
  422. /* we have been given the current selection, now insert it into input */
  423. XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
  424. utf8, &da, &di, &dl, &dl, (unsigned char **)&p);
  425. insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
  426. XFree(p);
  427. drawmenu();
  428. }
  429. static void
  430. readstdin(void)
  431. {
  432. char buf[sizeof text], *p, *maxstr = NULL;
  433. size_t i, max = 0, size = 0;
  434. /* read each line from stdin and add it to the item list */
  435. for (i = 0; fgets(buf, sizeof buf, stdin); i++) {
  436. if (i + 1 >= size / sizeof *items)
  437. if (!(items = realloc(items, (size += BUFSIZ))))
  438. die("cannot realloc %u bytes:", size);
  439. if ((p = strchr(buf, '\n')))
  440. *p = '\0';
  441. if (!(items[i].text = strdup(buf)))
  442. die("cannot strdup %u bytes:", strlen(buf) + 1);
  443. items[i].out = false;
  444. if (strlen(items[i].text) > max)
  445. max = strlen(maxstr = items[i].text);
  446. }
  447. if (items)
  448. items[i].text = NULL;
  449. inputw = maxstr ? TEXTW(maxstr) : 0;
  450. lines = MIN(lines, i);
  451. }
  452. static void
  453. run(void)
  454. {
  455. XEvent ev;
  456. while (!XNextEvent(dpy, &ev)) {
  457. if (XFilterEvent(&ev, win))
  458. continue;
  459. switch(ev.type) {
  460. case Expose:
  461. if (ev.xexpose.count == 0)
  462. drw_map(drw, win, 0, 0, mw, mh);
  463. break;
  464. case KeyPress:
  465. keypress(&ev.xkey);
  466. break;
  467. case SelectionNotify:
  468. if (ev.xselection.property == utf8)
  469. paste();
  470. break;
  471. case VisibilityNotify:
  472. if (ev.xvisibility.state != VisibilityUnobscured)
  473. XRaiseWindow(dpy, win);
  474. break;
  475. }
  476. }
  477. }
  478. static void
  479. setup(void)
  480. {
  481. int x, y;
  482. XSetWindowAttributes swa;
  483. XIM xim;
  484. #ifdef XINERAMA
  485. XineramaScreenInfo *info;
  486. Window w, pw, dw, *dws;
  487. XWindowAttributes wa;
  488. int a, j, di, n, i = 0, area = 0;
  489. unsigned int du;
  490. #endif
  491. /* init appearance */
  492. scheme[SchemeNorm].bg = drw_clr_create(drw, normbgcolor);
  493. scheme[SchemeNorm].fg = drw_clr_create(drw, normfgcolor);
  494. scheme[SchemeSel].bg = drw_clr_create(drw, selbgcolor);
  495. scheme[SchemeSel].fg = drw_clr_create(drw, selfgcolor);
  496. scheme[SchemeOut].bg = drw_clr_create(drw, outbgcolor);
  497. scheme[SchemeOut].fg = drw_clr_create(drw, outfgcolor);
  498. clip = XInternAtom(dpy, "CLIPBOARD", False);
  499. utf8 = XInternAtom(dpy, "UTF8_STRING", False);
  500. /* calculate menu geometry */
  501. bh = drw->fonts[0]->h + 2;
  502. lines = MAX(lines, 0);
  503. mh = (lines + 1) * bh;
  504. #ifdef XINERAMA
  505. if ((info = XineramaQueryScreens(dpy, &n))) {
  506. XGetInputFocus(dpy, &w, &di);
  507. if (mon != -1 && mon < n)
  508. i = mon;
  509. if (!i && w != root && w != PointerRoot && w != None) {
  510. /* find top-level window containing current input focus */
  511. do {
  512. if (XQueryTree(dpy, (pw = w), &dw, &w, &dws, &du) && dws)
  513. XFree(dws);
  514. } while (w != root && w != pw);
  515. /* find xinerama screen with which the window intersects most */
  516. if (XGetWindowAttributes(dpy, pw, &wa))
  517. for (j = 0; j < n; j++)
  518. if ((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) {
  519. area = a;
  520. i = j;
  521. }
  522. }
  523. /* no focused window is on screen, so use pointer location instead */
  524. if (mon == -1 && !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du))
  525. for (i = 0; i < n; i++)
  526. if (INTERSECT(x, y, 1, 1, info[i]))
  527. break;
  528. x = info[i].x_org;
  529. y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
  530. mw = info[i].width;
  531. XFree(info);
  532. } else
  533. #endif
  534. {
  535. x = 0;
  536. y = topbar ? 0 : sh - mh;
  537. mw = sw;
  538. }
  539. promptw = (prompt && *prompt) ? TEXTW(prompt) : 0;
  540. inputw = MIN(inputw, mw/3);
  541. match();
  542. /* create menu window */
  543. swa.override_redirect = True;
  544. swa.background_pixel = scheme[SchemeNorm].bg->pix;
  545. swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
  546. win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
  547. DefaultDepth(dpy, screen), CopyFromParent,
  548. DefaultVisual(dpy, screen),
  549. CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
  550. /* open input methods */
  551. xim = XOpenIM(dpy, NULL, NULL, NULL);
  552. xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
  553. XNClientWindow, win, XNFocusWindow, win, NULL);
  554. XMapRaised(dpy, win);
  555. drw_resize(drw, mw, mh);
  556. drawmenu();
  557. }
  558. static void
  559. usage(void)
  560. {
  561. fputs("usage: dmenu [-b] [-f] [-i] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
  562. " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
  563. exit(1);
  564. }
  565. int
  566. main(int argc, char *argv[])
  567. {
  568. bool fast = false;
  569. int i;
  570. for (i = 1; i < argc; i++)
  571. /* these options take no arguments */
  572. if (!strcmp(argv[i], "-v")) { /* prints version information */
  573. puts("dmenu-"VERSION);
  574. exit(0);
  575. } else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
  576. topbar = false;
  577. else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
  578. fast = true;
  579. else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
  580. fstrncmp = strncasecmp;
  581. fstrstr = cistrstr;
  582. } else if (i + 1 == argc)
  583. usage();
  584. /* these options take one argument */
  585. else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
  586. lines = atoi(argv[++i]);
  587. else if (!strcmp(argv[i], "-m"))
  588. mon = atoi(argv[++i]);
  589. else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
  590. prompt = argv[++i];
  591. else if (!strcmp(argv[i], "-fn")) /* font or font set */
  592. fonts[0] = argv[++i];
  593. else if (!strcmp(argv[i], "-nb")) /* normal background color */
  594. normbgcolor = argv[++i];
  595. else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
  596. normfgcolor = argv[++i];
  597. else if (!strcmp(argv[i], "-sb")) /* selected background color */
  598. selbgcolor = argv[++i];
  599. else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
  600. selfgcolor = argv[++i];
  601. else
  602. usage();
  603. if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
  604. fputs("warning: no locale support\n", stderr);
  605. if (!(dpy = XOpenDisplay(NULL)))
  606. die("cannot open display\n");
  607. screen = DefaultScreen(dpy);
  608. root = RootWindow(dpy, screen);
  609. sw = DisplayWidth(dpy, screen);
  610. sh = DisplayHeight(dpy, screen);
  611. drw = drw_create(dpy, screen, root, sw, sh);
  612. drw_load_fonts(drw, fonts, LENGTH(fonts));
  613. if (!drw->fontcount)
  614. die("no fonts could be loaded.\n");
  615. drw_setscheme(drw, &scheme[SchemeNorm]);
  616. if (fast) {
  617. grabkeyboard();
  618. readstdin();
  619. } else {
  620. readstdin();
  621. grabkeyboard();
  622. }
  623. setup();
  624. run();
  625. return 1; /* unreachable */
  626. }