… | |
… | |
69 | (optList[i].flag == 0) |
69 | (optList[i].flag == 0) |
70 | #define optList_isBool(i) \ |
70 | #define optList_isBool(i) \ |
71 | (optList[i].flag & Optflag_Boolean) |
71 | (optList[i].flag & Optflag_Boolean) |
72 | #define optList_isReverse(i) \ |
72 | #define optList_isReverse(i) \ |
73 | (optList[i].flag & Optflag_Reverse) |
73 | (optList[i].flag & Optflag_Reverse) |
74 | #define optList_size \ |
|
|
75 | (sizeof (optList) / sizeof (optList[0])) |
|
|
76 | |
74 | |
77 | static const struct |
75 | static const struct |
78 | { |
76 | { |
79 | const uint8_t index; /* Option index */ |
77 | const uint8_t index; /* Option index */ |
80 | const uint8_t flag; /* Option flag */ |
78 | const uint8_t flag; /* Option flag */ |
… | |
… | |
399 | switch (type) |
397 | switch (type) |
400 | { |
398 | { |
401 | case 0: /* brief listing */ |
399 | case 0: /* brief listing */ |
402 | rxvt_log (" [-help] [--help]\n"); |
400 | rxvt_log (" [-help] [--help]\n"); |
403 | |
401 | |
404 | for (col = 1, i = 0; i < optList_size; i++) |
402 | for (col = 1, i = 0; i < ARRAY_LENGTH(optList); i++) |
405 | if (optList[i].desc != NULL) |
403 | if (optList[i].desc != NULL) |
406 | { |
404 | { |
407 | int len = 0; |
405 | int len = 0; |
408 | |
406 | |
409 | if (optList[i].arg) |
407 | if (optList[i].arg) |
… | |
… | |
427 | break; |
425 | break; |
428 | |
426 | |
429 | case 1: /* full command-line listing */ |
427 | case 1: /* full command-line listing */ |
430 | rxvt_log (" [options] [-e command args]\n\nwhere options include:\n"); |
428 | rxvt_log (" [options] [-e command args]\n\nwhere options include:\n"); |
431 | |
429 | |
432 | for (i = 0; i < optList_size; i++) |
430 | for (i = 0; i < ARRAY_LENGTH(optList); i++) |
433 | if (optList[i].desc != NULL) |
431 | if (optList[i].desc != NULL) |
434 | { |
432 | { |
435 | assert (optList[i].opt != NULL); |
433 | assert (optList[i].opt != NULL); |
436 | rxvt_log (" %s%s %-*s%s%s\n", |
434 | rxvt_log (" %s%s %-*s%s%s\n", |
437 | (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, |
435 | (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, |
… | |
… | |
446 | |
444 | |
447 | case 2: /* full resource listing */ |
445 | case 2: /* full resource listing */ |
448 | rxvt_log (" [options] [-e command args]\n\n" |
446 | rxvt_log (" [options] [-e command args]\n\n" |
449 | "where resources (long-options) include:\n"); |
447 | "where resources (long-options) include:\n"); |
450 | |
448 | |
451 | for (i = 0; i < optList_size; i++) |
449 | for (i = 0; i < ARRAY_LENGTH(optList); i++) |
452 | if (optList[i].kw != NULL) |
450 | if (optList[i].kw != NULL) |
453 | rxvt_log (" %s: %*s%s\n", |
451 | rxvt_log (" %s: %*s%s\n", |
454 | optList[i].kw, |
452 | optList[i].kw, |
455 | (INDENT - strlen (optList[i].kw)), "", /* XXX */ |
453 | (INDENT - strlen (optList[i].kw)), "", /* XXX */ |
456 | (optList_isBool (i) ? "boolean" : optList[i].arg)); |
454 | (optList_isBool (i) ? "boolean" : optList[i].arg)); |
… | |
… | |
510 | |
508 | |
511 | if (!strcmp (opt, "h")) |
509 | if (!strcmp (opt, "h")) |
512 | rxvt_usage (0); |
510 | rxvt_usage (0); |
513 | |
511 | |
514 | /* feature: always try to match long-options */ |
512 | /* feature: always try to match long-options */ |
515 | for (entry = 0; entry < optList_size; entry++) |
513 | for (entry = 0; entry < ARRAY_LENGTH(optList); entry++) |
516 | if ((optList[entry].kw && !strcmp (opt, optList[entry].kw)) |
514 | if ((optList[entry].kw && !strcmp (opt, optList[entry].kw)) |
517 | || (!longopt |
515 | || (!longopt |
518 | && optList[entry].opt && !strcmp (opt, optList[entry].opt))) |
516 | && optList[entry].opt && !strcmp (opt, optList[entry].opt))) |
519 | break; |
517 | break; |
520 | |
518 | |
521 | if (entry < optList_size) |
519 | if (entry < ARRAY_LENGTH(optList)) |
522 | { |
520 | { |
523 | if (optList_isReverse (entry)) |
521 | if (optList_isReverse (entry)) |
524 | flag = !flag; |
522 | flag = !flag; |
525 | |
523 | |
526 | if (optList_isString (entry)) |
524 | if (optList_isString (entry)) |
… | |
… | |
667 | // parse modifiers |
665 | // parse modifiers |
668 | while (str < key) |
666 | while (str < key) |
669 | { |
667 | { |
670 | unsigned int i; |
668 | unsigned int i; |
671 | |
669 | |
672 | for (i=0; i < sizeof (keysym_vocabulary) / sizeof (keysym_vocabulary_t); ++i) |
670 | for (i=0; i < ARRAY_LENGTH(keysym_vocabulary); ++i) |
673 | { |
671 | { |
674 | if (strncmp (str, keysym_vocabulary [i].name, keysym_vocabulary [i].len) == 0) |
672 | if (strncmp (str, keysym_vocabulary [i].name, keysym_vocabulary [i].len) == 0) |
675 | { |
673 | { |
676 | state |= keysym_vocabulary[i].value; |
674 | state |= keysym_vocabulary[i].value; |
677 | str += keysym_vocabulary[i].len; |
675 | str += keysym_vocabulary[i].len; |
678 | break; |
676 | break; |
679 | } |
677 | } |
680 | } |
678 | } |
681 | |
679 | |
682 | if (i >= sizeof (keysym_vocabulary) / sizeof (keysym_vocabulary_t)) |
680 | if (i >= ARRAY_LENGTH(keysym_vocabulary)) |
683 | return -1; |
681 | return -1; |
684 | |
682 | |
685 | if (*str == '-') |
683 | if (*str == '-') |
686 | ++str; |
684 | ++str; |
687 | } |
685 | } |
… | |
… | |
747 | XrmMergeDatabases (option_db, &database); |
745 | XrmMergeDatabases (option_db, &database); |
748 | option_db = NULL; |
746 | option_db = NULL; |
749 | /* |
747 | /* |
750 | * Query resources for options that affect us |
748 | * Query resources for options that affect us |
751 | */ |
749 | */ |
752 | for (int entry = 0; entry < optList_size; entry++) |
750 | for (int entry = 0; entry < ARRAY_LENGTH(optList); entry++) |
753 | { |
751 | { |
754 | int s; |
752 | int s; |
755 | const char *kw = optList[entry].kw; |
753 | const char *kw = optList[entry].kw; |
756 | |
754 | |
757 | if (kw == NULL || rs[optList[entry].doff] != NULL) |
755 | if (kw == NULL || rs[optList[entry].doff] != NULL) |