… | |
… | |
28 | *----------------------------------------------------------------------*/ |
28 | *----------------------------------------------------------------------*/ |
29 | |
29 | |
30 | #include "../config.h" /* NECESSARY */ |
30 | #include "../config.h" /* NECESSARY */ |
31 | #include "rxvt.h" /* NECESSARY */ |
31 | #include "rxvt.h" /* NECESSARY */ |
32 | #include "version.h" |
32 | #include "version.h" |
33 | #include "xdefaults.intpro" /* PROTOS for internal routines */ |
|
|
34 | |
33 | |
35 | /* #define DEBUG_RESOURCES */ |
34 | /* #define DEBUG_RESOURCES */ |
36 | |
35 | |
37 | static const char *const xnames[2] = { ".Xdefaults", ".Xresources" }; |
36 | static const char *const xnames[2] = { ".Xdefaults", ".Xresources" }; |
38 | |
37 | |
… | |
… | |
63 | #define SWCH(opt, flag, desc) \ |
62 | #define SWCH(opt, flag, desc) \ |
64 | { (flag), -1, NULL, (opt), NULL, (desc)} |
63 | { (flag), -1, NULL, (opt), NULL, (desc)} |
65 | |
64 | |
66 | /* convenient macros */ |
65 | /* convenient macros */ |
67 | #define optList_strlen(i) \ |
66 | #define optList_strlen(i) \ |
68 | (optList[i].flag ? 0 : (optList[i].arg ? STRLEN (optList[i].arg) : 1)) |
67 | (optList[i].flag ? 0 : (optList[i].arg ? strlen (optList[i].arg) : 1)) |
69 | #define optList_isBool(i) \ |
68 | #define optList_isBool(i) \ |
70 | (optList[i].flag & Opt_Boolean) |
69 | (optList[i].flag & Opt_Boolean) |
71 | #define optList_isReverse(i) \ |
70 | #define optList_isReverse(i) \ |
72 | (optList[i].flag & Opt_Reverse) |
71 | (optList[i].flag & Opt_Reverse) |
73 | #define optList_size() \ |
72 | #define optList_size() \ |
… | |
… | |
128 | BOOL (Rs_meta8, "meta8", NULL, Opt_meta8, NULL), |
127 | BOOL (Rs_meta8, "meta8", NULL, Opt_meta8, NULL), |
129 | #endif |
128 | #endif |
130 | #ifdef MOUSE_WHEEL |
129 | #ifdef MOUSE_WHEEL |
131 | BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, NULL), |
130 | BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, NULL), |
132 | #endif |
131 | #endif |
133 | #ifndef NO_FRILLS |
132 | #if ENABLE_FRILLS |
134 | BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, "triple click word selection"), |
133 | BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, "triple click word selection"), |
135 | BOOL (Rs_insecure, "insecure", "insecure", Opt_insecure, "enable possibly insecure escape sequences"), |
134 | BOOL (Rs_insecure, "insecure", "insecure", Opt_insecure, "enable possibly insecure escape sequences"), |
136 | #endif |
135 | #endif |
137 | #ifdef CURSOR_BLINK |
136 | #ifdef CURSOR_BLINK |
138 | BOOL (Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"), |
137 | BOOL (Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"), |
… | |
… | |
202 | #endif /* NO_CURSORCOLOR */ |
201 | #endif /* NO_CURSORCOLOR */ |
203 | STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"), |
202 | STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"), |
204 | STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"), |
203 | STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"), |
205 | STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"), |
204 | STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"), |
206 | STRG (Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save"), |
205 | STRG (Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save"), |
207 | #ifndef NO_FRILLS |
206 | #if ENABLE_FRILLS |
208 | STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"), |
207 | STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"), |
209 | STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL), |
208 | STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL), |
210 | STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL), |
209 | STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL), |
211 | STRG (Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels"), |
210 | STRG (Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels"), |
212 | BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, "borderless window"), |
211 | BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, "borderless window"), |
… | |
… | |
251 | #undef SWCH |
250 | #undef SWCH |
252 | #undef BOOL |
251 | #undef BOOL |
253 | /*}}} */ |
252 | /*}}} */ |
254 | |
253 | |
255 | static const char releasestring[] = "Rxvt v" VERSION " - released: " DATE "\n"; |
254 | static const char releasestring[] = "Rxvt v" VERSION " - released: " DATE "\n"; |
256 | static const char optionsstring[] = "Options: " |
255 | static const char optionsstring[] = "options: " |
257 | #if XFT |
256 | #if XFT |
258 | "xft," |
257 | "xft," |
259 | #endif |
258 | #endif |
260 | #if UNICODE_3 |
259 | #if UNICODE_3 |
261 | "unicode3," |
260 | "unicode3," |
… | |
… | |
341 | "8bitctrls," |
340 | "8bitctrls," |
342 | #endif |
341 | #endif |
343 | #if !defined(NO_STRINGS) |
342 | #if !defined(NO_STRINGS) |
344 | "strings," |
343 | "strings," |
345 | #endif |
344 | #endif |
346 | #if !defined(NO_FRILLS) |
345 | #if defined(ENABLE_FRILLS) |
347 | "frills," |
346 | "frills," |
348 | #endif |
347 | #endif |
349 | #if !defined(NO_LINESPACE) |
348 | #if !defined(NO_LINESPACE) |
350 | "linespace," |
349 | "linespace," |
351 | #endif |
350 | #endif |
… | |
… | |
412 | len++; /* account for space */ |
411 | len++; /* account for space */ |
413 | } |
412 | } |
414 | #ifdef DEBUG_STRICT |
413 | #ifdef DEBUG_STRICT |
415 | assert (optList[i].opt != NULL); |
414 | assert (optList[i].opt != NULL); |
416 | #endif |
415 | #endif |
417 | len += 4 + STRLEN (optList[i].opt) + (optList_isBool (i) ? 2: 0); |
416 | len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2: 0); |
418 | col += len; |
417 | col += len; |
419 | if (col > 79) |
418 | if (col > 79) |
420 | { /* assume regular width */ |
419 | { /* assume regular width */ |
421 | rxvt_log ("\n"); |
420 | rxvt_log ("\n"); |
422 | col = 1 + len; |
421 | col = 1 + len; |
… | |
… | |
439 | #ifdef DEBUG_STRICT |
438 | #ifdef DEBUG_STRICT |
440 | assert (optList[i].opt != NULL); |
439 | assert (optList[i].opt != NULL); |
441 | #endif |
440 | #endif |
442 | rxvt_log (" %s%s %-*s%s%s\n", |
441 | rxvt_log (" %s%s %-*s%s%s\n", |
443 | (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, |
442 | (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, |
444 | (INDENT - STRLEN (optList[i].opt) |
443 | (INDENT - strlen (optList[i].opt) |
445 | + (optList_isBool (i) ? 0 : 2)), |
444 | + (optList_isBool (i) ? 0 : 2)), |
446 | (optList[i].arg ? optList[i].arg : ""), |
445 | (optList[i].arg ? optList[i].arg : ""), |
447 | (optList_isBool (i) ? "turn on/off " : ""), |
446 | (optList_isBool (i) ? "turn on/off " : ""), |
448 | optList[i].desc); |
447 | optList[i].desc); |
449 | } |
448 | } |
… | |
… | |
456 | |
455 | |
457 | for (i = 0; i < optList_size (); i++) |
456 | for (i = 0; i < optList_size (); i++) |
458 | if (optList[i].kw != NULL) |
457 | if (optList[i].kw != NULL) |
459 | rxvt_log (" %s: %*s%s\n", |
458 | rxvt_log (" %s: %*s%s\n", |
460 | optList[i].kw, |
459 | optList[i].kw, |
461 | (INDENT - STRLEN (optList[i].kw)), "", /* XXX */ |
460 | (INDENT - strlen (optList[i].kw)), "", /* XXX */ |
462 | (optList_isBool (i) ? "boolean" : optList[i].arg)); |
461 | (optList_isBool (i) ? "boolean" : optList[i].arg)); |
463 | #ifdef KEYSYM_RESOURCE |
462 | #ifdef KEYSYM_RESOURCE |
464 | rxvt_log (" " "keysym.sym" ": %*s%s\n", |
463 | rxvt_log (" " "keysym.sym" ": %*s%s\n", |
465 | (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */ |
464 | (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */ |
466 | "keysym"); |
465 | "keysym"); |
… | |
… | |
509 | bad_option = 1; |
508 | bad_option = 1; |
510 | rxvt_warn ("\"%s\": malformed option.\n", opt); |
509 | rxvt_warn ("\"%s\": malformed option.\n", opt); |
511 | continue; |
510 | continue; |
512 | } |
511 | } |
513 | |
512 | |
514 | if (!STRCMP (opt, "help")) |
513 | if (!strcmp (opt, "help")) |
515 | rxvt_usage (longopt ? 2 : 1); |
514 | rxvt_usage (longopt ? 2 : 1); |
516 | if (!STRCMP (opt, "h")) |
515 | if (!strcmp (opt, "h")) |
517 | rxvt_usage (0); |
516 | rxvt_usage (0); |
518 | |
517 | |
519 | /* feature: always try to match long-options */ |
518 | /* feature: always try to match long-options */ |
520 | for (entry = 0; entry < optList_size (); entry++) |
519 | for (entry = 0; entry < optList_size (); entry++) |
521 | if ((optList[entry].kw && !STRCMP (opt, optList[entry].kw)) |
520 | if ((optList[entry].kw && !strcmp (opt, optList[entry].kw)) |
522 | || (!longopt |
521 | || (!longopt |
523 | && optList[entry].opt && !STRCMP (opt, optList[entry].opt))) |
522 | && optList[entry].opt && !strcmp (opt, optList[entry].opt))) |
524 | break; |
523 | break; |
525 | |
524 | |
526 | if (entry < optList_size ()) |
525 | if (entry < optList_size ()) |
527 | { |
526 | { |
528 | if (optList_isReverse (entry)) |
527 | if (optList_isReverse (entry)) |
… | |
… | |
545 | #ifdef DEBUG_RESOURCES |
544 | #ifdef DEBUG_RESOURCES |
546 | fprintf (stderr, "boolean (%s,%s) = %s\n", |
545 | fprintf (stderr, "boolean (%s,%s) = %s\n", |
547 | optList[entry].opt, optList[entry].kw, flag); |
546 | optList[entry].opt, optList[entry].kw, flag); |
548 | #endif |
547 | #endif |
549 | if (flag == On) |
548 | if (flag == On) |
550 | Options |= (optList[entry].flag); |
549 | options |= (optList[entry].flag); |
551 | else |
550 | else |
552 | Options &= ~ (optList[entry].flag); |
551 | options &= ~ (optList[entry].flag); |
553 | |
552 | |
554 | if (optList[entry].doff != -1) |
553 | if (optList[entry].doff != -1) |
555 | rs[optList[entry].doff] = flag; |
554 | rs[optList[entry].doff] = flag; |
556 | } |
555 | } |
557 | } |
556 | } |
558 | else |
557 | else |
559 | #ifdef KEYSYM_RESOURCE |
558 | #ifdef KEYSYM_RESOURCE |
560 | /* if (!STRNCMP (opt, "keysym.", sizeof ("keysym.") - 1)) */ |
559 | /* if (!strncmp (opt, "keysym.", sizeof ("keysym.") - 1)) */ |
561 | if (rxvt_Str_match (opt, "keysym.")) |
560 | if (rxvt_Str_match (opt, "keysym.")) |
562 | { |
561 | { |
563 | const char *str = argv[++i]; |
562 | const char *str = argv[++i]; |
564 | |
563 | |
565 | if (str != NULL) |
564 | if (str != NULL) |
… | |
… | |
634 | { |
633 | { |
635 | if (str[0] == '0' && toupper (str[1]) == 'X') |
634 | if (str[0] == '0' && toupper (str[1]) == 'X') |
636 | str += 2; |
635 | str += 2; |
637 | if (arg) |
636 | if (arg) |
638 | { |
637 | { |
639 | if (sscanf (str, (STRCHR (str, ':') ? "%x:" : "%x"), &sym) != 1) |
638 | if (sscanf (str, (strchr (str, ':') ? "%x:" : "%x"), &sym) != 1) |
640 | return -1; |
639 | return -1; |
641 | } |
640 | } |
642 | else |
641 | else |
643 | { |
642 | { |
644 | if (sscanf (str, "%x:", &sym) != 1) |
643 | if (sscanf (str, "%x:", &sym) != 1) |
645 | return -1; |
644 | return -1; |
646 | |
645 | |
647 | /* cue to ':', it's there since sscanf () worked */ |
646 | /* cue to ':', it's there since sscanf () worked */ |
648 | STRNCPY (newargstr, STRCHR (str, ':') + 1, NEWARGLIM - 1); |
647 | strncpy (newargstr, strchr (str, ':') + 1, NEWARGLIM - 1); |
649 | newargstr[NEWARGLIM - 1] = '\0'; |
648 | newargstr[NEWARGLIM - 1] = '\0'; |
650 | newarg = newargstr; |
649 | newarg = newargstr; |
651 | } |
650 | } |
652 | } |
651 | } |
653 | else |
652 | else |
654 | { |
653 | { |
655 | /* |
654 | /* |
656 | * convert keysym name to keysym number |
655 | * convert keysym name to keysym number |
657 | */ |
656 | */ |
658 | STRNCPY (newargstr, str, NEWARGLIM - 1); |
657 | strncpy (newargstr, str, NEWARGLIM - 1); |
659 | newargstr[NEWARGLIM - 1] = '\0'; |
658 | newargstr[NEWARGLIM - 1] = '\0'; |
660 | if (arg == NULL) |
659 | if (arg == NULL) |
661 | { |
660 | { |
662 | if ((newarg = STRCHR (newargstr, ':')) == NULL) |
661 | if ((newarg = strchr (newargstr, ':')) == NULL) |
663 | return -1; |
662 | return -1; |
664 | *newarg++ = '\0'; /* terminate keysym name */ |
663 | *newarg++ = '\0'; /* terminate keysym name */ |
665 | } |
664 | } |
666 | if ((sym = XStringToKeysym (newargstr)) == None) |
665 | if ((sym = XStringToKeysym (newargstr)) == None) |
667 | return -1; |
666 | return -1; |
… | |
… | |
673 | if (Keysym_map[sym] != NULL) /* already set ? */ |
672 | if (Keysym_map[sym] != NULL) /* already set ? */ |
674 | return -1; |
673 | return -1; |
675 | |
674 | |
676 | if (newarg == NULL) |
675 | if (newarg == NULL) |
677 | { |
676 | { |
678 | STRNCPY (newargstr, arg, NEWARGLIM - 1); |
677 | strncpy (newargstr, arg, NEWARGLIM - 1); |
679 | newargstr[NEWARGLIM - 1] = '\0'; |
678 | newargstr[NEWARGLIM - 1] = '\0'; |
680 | newarg = newargstr; |
679 | newarg = newargstr; |
681 | } |
680 | } |
682 | rxvt_Str_trim (newarg); |
681 | rxvt_Str_trim (newarg); |
683 | if (*newarg == '\0' || (n = rxvt_Str_escaped (newarg)) == 0) |
682 | if (*newarg == '\0' || (n = rxvt_Str_escaped (newarg)) == 0) |
684 | return -1; |
683 | return -1; |
685 | MIN_IT (n, 255); |
684 | MIN_IT (n, 255); |
686 | key_string = (char *)rxvt_malloc ((n + 1) * sizeof (char)); |
685 | key_string = (char *)rxvt_malloc ((n + 1) * sizeof (char)); |
687 | |
686 | |
688 | key_string[0] = n; |
687 | key_string[0] = n; |
689 | STRNCPY (key_string + 1, newarg, n); |
688 | strncpy (key_string + 1, newarg, n); |
690 | Keysym_map[sym] = (unsigned char *)key_string; |
689 | Keysym_map[sym] = (unsigned char *)key_string; |
691 | |
690 | |
692 | return 1; |
691 | return 1; |
693 | } |
692 | } |
694 | |
693 | |
… | |
… | |
706 | char *str, buffer[256]; |
705 | char *str, buffer[256]; |
707 | |
706 | |
708 | if (stream == NULL) |
707 | if (stream == NULL) |
709 | return; |
708 | return; |
710 | |
709 | |
711 | len = STRLEN (name); |
710 | len = strlen (name); |
712 | while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL) |
711 | while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL) |
713 | { |
712 | { |
714 | unsigned int entry, n; |
713 | unsigned int entry, n; |
715 | |
714 | |
716 | while (*str && isspace (*str)) |
715 | while (*str && isspace (*str)) |
717 | str++; /* leading whitespace */ |
716 | str++; /* leading whitespace */ |
718 | |
717 | |
719 | if ((str[len] != '*' && str[len] != '.') |
718 | if ((str[len] != '*' && str[len] != '.') |
720 | || (len && STRNCMP (str, name, len))) |
719 | || (len && strncmp (str, name, len))) |
721 | continue; |
720 | continue; |
722 | str += (len + 1); /* skip `name*' or `name.' */ |
721 | str += (len + 1); /* skip `name*' or `name.' */ |
723 | |
722 | |
724 | # ifdef KEYSYM_RESOURCE |
723 | # ifdef KEYSYM_RESOURCE |
725 | if (!parse_keysym (str, NULL)) |
724 | if (!parse_keysym (str, NULL)) |
… | |
… | |
729 | const char *kw = optList[entry].kw; |
728 | const char *kw = optList[entry].kw; |
730 | |
729 | |
731 | if (kw == NULL) |
730 | if (kw == NULL) |
732 | continue; |
731 | continue; |
733 | |
732 | |
734 | n = STRLEN (kw); |
733 | n = strlen (kw); |
735 | if (str[n] == ':' && rxvt_Str_match (str, kw)) |
734 | if (str[n] == ':' && rxvt_Str_match (str, kw)) |
736 | { |
735 | { |
737 | /* skip `keyword:' */ |
736 | /* skip `keyword:' */ |
738 | str += n + 1; |
737 | str += n + 1; |
739 | rxvt_Str_trim (str); |
738 | rxvt_Str_trim (str); |
740 | n = STRLEN (str); |
739 | n = strlen (str); |
741 | if (n && rs[optList[entry].doff] == NULL) |
740 | if (n && rs[optList[entry].doff] == NULL) |
742 | { |
741 | { |
743 | /* not already set */ |
742 | /* not already set */ |
744 | int s; |
743 | int s; |
745 | char *p = 0; |
744 | char *p = 0; |
746 | |
745 | |
747 | for (int o = 0;;) |
746 | for (int o = 0;;) |
748 | { |
747 | { |
749 | p = (char *)rxvt_realloc (p, o + n + 1); |
748 | p = (char *)rxvt_realloc (p, o + n + 1); |
750 | MEMCPY (p + o, str, n); |
749 | memcpy (p + o, str, n); |
751 | o += n; |
750 | o += n; |
752 | p[o] = 0; |
751 | p[o] = 0; |
753 | |
752 | |
754 | if (o == 0 || p[o - 1] != '\\') // continuation line |
753 | if (o == 0 || p[o - 1] != '\\') // continuation line |
755 | break; |
754 | break; |
… | |
… | |
758 | |
757 | |
759 | if ((str = fgets (buffer, sizeof (buffer), stream)) == NULL) |
758 | if ((str = fgets (buffer, sizeof (buffer), stream)) == NULL) |
760 | break; |
759 | break; |
761 | |
760 | |
762 | rxvt_Str_trim (str); |
761 | rxvt_Str_trim (str); |
763 | n = STRLEN (str); |
762 | n = strlen (str); |
764 | } |
763 | } |
765 | |
764 | |
766 | rs[optList[entry].doff] = p; |
765 | rs[optList[entry].doff] = p; |
767 | allocated.push_back (p); |
766 | allocated.push_back (p); |
768 | |
767 | |
769 | if (optList_isBool (entry)) |
768 | if (optList_isBool (entry)) |
770 | { |
769 | { |
771 | s = STRCASECMP (str, "TRUE") == 0 |
770 | s = strcasecmp (str, "TRUE") == 0 |
772 | || STRCASECMP (str, "YES") == 0 |
771 | || strcasecmp (str, "YES") == 0 |
773 | || STRCASECMP (str, "ON") == 0 |
772 | || strcasecmp (str, "ON") == 0 |
774 | || STRCASECMP (str, "1") == 0; |
773 | || strcasecmp (str, "1") == 0; |
775 | |
774 | |
776 | if (optList_isReverse (entry)) |
775 | if (optList_isReverse (entry)) |
777 | s = !s; |
776 | s = !s; |
778 | |
777 | |
779 | if (s) |
778 | if (s) |
780 | Options |= optList[entry].flag; |
779 | options |= optList[entry].flag; |
781 | else |
780 | else |
782 | Options &= ~optList[entry].flag; |
781 | options &= ~optList[entry].flag; |
783 | } |
782 | } |
784 | } |
783 | } |
785 | |
784 | |
786 | break; |
785 | break; |
787 | } |
786 | } |
… | |
… | |
853 | if ((ptr = (char *)getenv ("HOME")) == NULL) |
852 | if ((ptr = (char *)getenv ("HOME")) == NULL) |
854 | ptr = "."; |
853 | ptr = "."; |
855 | |
854 | |
856 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
855 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
857 | { |
856 | { |
858 | sprintf (fname, "%-.*s/%s", sizeof (fname) - STRLEN (xnames[i]) - 2, |
857 | sprintf (fname, "%-.*s/%s", sizeof (fname) - strlen (xnames[i]) - 2, |
859 | ptr, xnames[i]); |
858 | ptr, xnames[i]); |
860 | if ((rdb1 = XrmGetFileDatabase (fname))) |
859 | if ((rdb1 = XrmGetFileDatabase (fname))) |
861 | { |
860 | { |
862 | XrmMergeDatabases (rdb1, &database); |
861 | XrmMergeDatabases (rdb1, &database); |
863 | # ifndef HAVE_BOTH_XRESOURCE_FILES |
862 | # ifndef HAVE_BOTH_XRESOURCE_FILES |
… | |
… | |
908 | if (kw == NULL || rs[optList[entry].doff] != NULL) |
907 | if (kw == NULL || rs[optList[entry].doff] != NULL) |
909 | continue; /* previously set */ |
908 | continue; /* previously set */ |
910 | |
909 | |
911 | p = XGetDefault (display, name, kw); |
910 | p = XGetDefault (display, name, kw); |
912 | p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); |
911 | p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); |
913 | if (p == NULL || (p0 && STRCMP (p, p0) == 0)) |
912 | if (p == NULL || (p0 && strcmp (p, p0) == 0)) |
914 | { |
913 | { |
915 | p = XGetDefault (display, RESCLASS, kw); |
914 | p = XGetDefault (display, RESCLASS, kw); |
916 | #ifdef RESFALLBACK |
915 | #ifdef RESFALLBACK |
917 | if (p == NULL || (p0 && STRCMP (p, p0) == 0)) |
916 | if (p == NULL || (p0 && strcmp (p, p0) == 0)) |
918 | p = XGetDefault (display, RESFALLBACK, kw); |
917 | p = XGetDefault (display, RESFALLBACK, kw); |
919 | #endif |
918 | #endif |
920 | } |
919 | } |
921 | |
920 | |
922 | if (p == NULL && p0) |
921 | if (p == NULL && p0) |
… | |
… | |
926 | { |
925 | { |
927 | rs[optList[entry].doff] = p; |
926 | rs[optList[entry].doff] = p; |
928 | |
927 | |
929 | if (optList_isBool (entry)) |
928 | if (optList_isBool (entry)) |
930 | { |
929 | { |
931 | s = STRCASECMP (p, "TRUE") == 0 |
930 | s = strcasecmp (p, "TRUE") == 0 |
932 | || STRCASECMP (p, "YES") == 0 |
931 | || strcasecmp (p, "YES") == 0 |
933 | || STRCASECMP (p, "ON") == 0 |
932 | || strcasecmp (p, "ON") == 0 |
934 | || STRCASECMP (p, "1") == 0; |
933 | || strcasecmp (p, "1") == 0; |
935 | if (optList_isReverse (entry)) |
934 | if (optList_isReverse (entry)) |
936 | s = !s; |
935 | s = !s; |
937 | if (s) |
936 | if (s) |
938 | Options |= (optList[entry].flag); |
937 | options |= (optList[entry].flag); |
939 | else |
938 | else |
940 | Options &= ~ (optList[entry].flag); |
939 | options &= ~ (optList[entry].flag); |
941 | } |
940 | } |
942 | } |
941 | } |
943 | } |
942 | } |
944 | |
943 | |
945 | /* |
944 | /* |
… | |
… | |
973 | FILE *fd = NULL; |
972 | FILE *fd = NULL; |
974 | char *home; |
973 | char *home; |
975 | |
974 | |
976 | if ((home = getenv ("HOME")) != NULL) |
975 | if ((home = getenv ("HOME")) != NULL) |
977 | { |
976 | { |
978 | unsigned int i, len = STRLEN (home) + 2; |
977 | unsigned int i, len = strlen (home) + 2; |
979 | char *f = NULL; |
978 | char *f = NULL; |
980 | |
979 | |
981 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
980 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
982 | { |
981 | { |
983 | f = (char *)rxvt_realloc (f, (len + STRLEN (xnames[i])) * sizeof (char)); |
982 | f = (char *)rxvt_realloc (f, (len + strlen (xnames[i])) * sizeof (char)); |
984 | |
983 | |
985 | sprintf (f, "%s/%s", home, xnames[i]); |
984 | sprintf (f, "%s/%s", home, xnames[i]); |
986 | |
985 | |
987 | if ((fd = fopen (f, "r")) != NULL) |
986 | if ((fd = fopen (f, "r")) != NULL) |
988 | break; |
987 | break; |