… | |
… | |
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: " |
|
|
256 | #if XFT |
|
|
257 | "xft," |
|
|
258 | #endif |
|
|
259 | #if UNICODE_3 |
|
|
260 | "unicode3," |
|
|
261 | #endif |
|
|
262 | "encodings=eu+vn" |
|
|
263 | #if ENCODING_JP |
|
|
264 | "+jp" |
|
|
265 | #endif |
|
|
266 | #if ENCODING_JP_EXT |
|
|
267 | "+jp-ext" |
|
|
268 | #endif |
|
|
269 | #if ENCODING_KR |
|
|
270 | "+kr" |
|
|
271 | #endif |
|
|
272 | #if ENCODING_CN |
|
|
273 | "+cn" |
|
|
274 | #endif |
|
|
275 | #if ENCODING_CN_EXT |
|
|
276 | "+cn-ext" |
|
|
277 | #endif |
|
|
278 | "," |
|
|
279 | #if ENABLE_COMBINING |
|
|
280 | "combining," |
|
|
281 | #endif |
|
|
282 | #if TEXT_BLINK |
|
|
283 | "blink," |
|
|
284 | #endif |
|
|
285 | #if OFF_FOCUS_FADING |
|
|
286 | "fade," |
|
|
287 | #endif |
257 | #if defined(XPM_BACKGROUND) |
288 | #if defined(XPM_BACKGROUND) |
258 | "XPM," |
289 | "XPM," |
259 | #endif |
290 | #endif |
260 | #if defined(TRANSPARENT) |
291 | #if defined(TRANSPARENT) |
261 | "transparent," |
292 | "transparent," |
262 | #endif |
293 | #endif |
|
|
294 | #if TINTING |
|
|
295 | "tint," |
|
|
296 | #endif |
263 | #if defined(UTMP_SUPPORT) |
297 | #if defined(UTMP_SUPPORT) |
264 | "utmp," |
298 | "utmp," |
265 | #endif |
299 | #endif |
266 | #if defined(MENUBAR) |
300 | #if defined(MENUBAR) |
267 | "menubar," |
301 | "menubar," |
268 | #endif |
|
|
269 | #if !defined(NO_FRILLS) |
|
|
270 | "frills," |
|
|
271 | #endif |
|
|
272 | #if !defined(NO_LINESPACE) |
|
|
273 | "linespace," |
|
|
274 | #endif |
|
|
275 | #if defined(PREFER_24BIT) |
|
|
276 | "24bit," |
|
|
277 | #endif |
302 | #endif |
278 | #if defined(USE_XIM) |
303 | #if defined(USE_XIM) |
279 | "XIM," |
304 | "XIM," |
280 | #endif |
305 | #endif |
281 | "scrollbars=" |
306 | "scrollbars=" |
… | |
… | |
309 | "no_backspace," |
334 | "no_backspace," |
310 | #endif |
335 | #endif |
311 | #if defined(NO_DELETE_KEY) |
336 | #if defined(NO_DELETE_KEY) |
312 | "no_delete," |
337 | "no_delete," |
313 | #endif |
338 | #endif |
|
|
339 | #if EIGHT_BIT_CONTROLS |
|
|
340 | "8bitctrls," |
|
|
341 | #endif |
314 | #if !defined(NO_STRINGS) |
342 | #if !defined(NO_STRINGS) |
315 | "strings," |
343 | "strings," |
316 | #endif |
344 | #endif |
|
|
345 | #if defined(ENABLE_FRILLS) |
|
|
346 | "frills," |
|
|
347 | #endif |
|
|
348 | #if !defined(NO_LINESPACE) |
|
|
349 | "linespace," |
|
|
350 | #endif |
|
|
351 | #if defined(PREFER_24BIT) |
|
|
352 | "24bit," |
|
|
353 | #endif |
|
|
354 | #if defined(SELECTION_SCROLLING) |
|
|
355 | "selectionscrolling," |
|
|
356 | #endif |
|
|
357 | #if MOUSE_WHEEL |
|
|
358 | "wheel," |
|
|
359 | #endif |
|
|
360 | #if MOUSE_SLIP_WHEELING |
|
|
361 | "slipwheel," |
|
|
362 | #endif |
|
|
363 | #if defined(SMART_RESIZE) |
|
|
364 | "smart-resize," |
|
|
365 | #endif |
317 | #if defined(TTY_256COLOR) |
366 | #if defined(TTY_256COLOR) |
318 | "256colour," |
367 | "256colour," |
|
|
368 | #endif |
|
|
369 | #if defined(CURSOR_BLINK) |
|
|
370 | "cursorBlink," |
|
|
371 | #endif |
|
|
372 | #if defined(POINTER_BLANK) |
|
|
373 | "pointerBlank," |
319 | #endif |
374 | #endif |
320 | #if defined(NO_RESOURCES) |
375 | #if defined(NO_RESOURCES) |
321 | "NoResources" |
376 | "NoResources" |
322 | #else |
377 | #else |
323 | # if defined(USE_XGETDEFAULT) |
378 | # if defined(USE_XGETDEFAULT) |
… | |
… | |
356 | len++; /* account for space */ |
411 | len++; /* account for space */ |
357 | } |
412 | } |
358 | #ifdef DEBUG_STRICT |
413 | #ifdef DEBUG_STRICT |
359 | assert (optList[i].opt != NULL); |
414 | assert (optList[i].opt != NULL); |
360 | #endif |
415 | #endif |
361 | len += 4 + STRLEN (optList[i].opt) + (optList_isBool (i) ? 2: 0); |
416 | len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2: 0); |
362 | col += len; |
417 | col += len; |
363 | if (col > 79) |
418 | if (col > 79) |
364 | { /* assume regular width */ |
419 | { /* assume regular width */ |
365 | rxvt_log ("\n"); |
420 | rxvt_log ("\n"); |
366 | col = 1 + len; |
421 | col = 1 + len; |
… | |
… | |
383 | #ifdef DEBUG_STRICT |
438 | #ifdef DEBUG_STRICT |
384 | assert (optList[i].opt != NULL); |
439 | assert (optList[i].opt != NULL); |
385 | #endif |
440 | #endif |
386 | rxvt_log (" %s%s %-*s%s%s\n", |
441 | rxvt_log (" %s%s %-*s%s%s\n", |
387 | (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, |
442 | (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, |
388 | (INDENT - STRLEN (optList[i].opt) |
443 | (INDENT - strlen (optList[i].opt) |
389 | + (optList_isBool (i) ? 0 : 2)), |
444 | + (optList_isBool (i) ? 0 : 2)), |
390 | (optList[i].arg ? optList[i].arg : ""), |
445 | (optList[i].arg ? optList[i].arg : ""), |
391 | (optList_isBool (i) ? "turn on/off " : ""), |
446 | (optList_isBool (i) ? "turn on/off " : ""), |
392 | optList[i].desc); |
447 | optList[i].desc); |
393 | } |
448 | } |
… | |
… | |
400 | |
455 | |
401 | for (i = 0; i < optList_size (); i++) |
456 | for (i = 0; i < optList_size (); i++) |
402 | if (optList[i].kw != NULL) |
457 | if (optList[i].kw != NULL) |
403 | rxvt_log (" %s: %*s%s\n", |
458 | rxvt_log (" %s: %*s%s\n", |
404 | optList[i].kw, |
459 | optList[i].kw, |
405 | (INDENT - STRLEN (optList[i].kw)), "", /* XXX */ |
460 | (INDENT - strlen (optList[i].kw)), "", /* XXX */ |
406 | (optList_isBool (i) ? "boolean" : optList[i].arg)); |
461 | (optList_isBool (i) ? "boolean" : optList[i].arg)); |
407 | #ifdef KEYSYM_RESOURCE |
462 | #ifdef KEYSYM_RESOURCE |
408 | rxvt_log (" " "keysym.sym" ": %*s%s\n", |
463 | rxvt_log (" " "keysym.sym" ": %*s%s\n", |
409 | (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */ |
464 | (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */ |
410 | "keysym"); |
465 | "keysym"); |
… | |
… | |
453 | bad_option = 1; |
508 | bad_option = 1; |
454 | rxvt_warn ("\"%s\": malformed option.\n", opt); |
509 | rxvt_warn ("\"%s\": malformed option.\n", opt); |
455 | continue; |
510 | continue; |
456 | } |
511 | } |
457 | |
512 | |
458 | if (!STRCMP (opt, "help")) |
513 | if (!strcmp (opt, "help")) |
459 | rxvt_usage (longopt ? 2 : 1); |
514 | rxvt_usage (longopt ? 2 : 1); |
460 | if (!STRCMP (opt, "h")) |
515 | if (!strcmp (opt, "h")) |
461 | rxvt_usage (0); |
516 | rxvt_usage (0); |
462 | |
517 | |
463 | /* feature: always try to match long-options */ |
518 | /* feature: always try to match long-options */ |
464 | for (entry = 0; entry < optList_size (); entry++) |
519 | for (entry = 0; entry < optList_size (); entry++) |
465 | if ((optList[entry].kw && !STRCMP (opt, optList[entry].kw)) |
520 | if ((optList[entry].kw && !strcmp (opt, optList[entry].kw)) |
466 | || (!longopt |
521 | || (!longopt |
467 | && optList[entry].opt && !STRCMP (opt, optList[entry].opt))) |
522 | && optList[entry].opt && !strcmp (opt, optList[entry].opt))) |
468 | break; |
523 | break; |
469 | |
524 | |
470 | if (entry < optList_size ()) |
525 | if (entry < optList_size ()) |
471 | { |
526 | { |
472 | if (optList_isReverse (entry)) |
527 | if (optList_isReverse (entry)) |
… | |
… | |
489 | #ifdef DEBUG_RESOURCES |
544 | #ifdef DEBUG_RESOURCES |
490 | fprintf (stderr, "boolean (%s,%s) = %s\n", |
545 | fprintf (stderr, "boolean (%s,%s) = %s\n", |
491 | optList[entry].opt, optList[entry].kw, flag); |
546 | optList[entry].opt, optList[entry].kw, flag); |
492 | #endif |
547 | #endif |
493 | if (flag == On) |
548 | if (flag == On) |
494 | Options |= (optList[entry].flag); |
549 | options |= (optList[entry].flag); |
495 | else |
550 | else |
496 | Options &= ~ (optList[entry].flag); |
551 | options &= ~ (optList[entry].flag); |
497 | |
552 | |
498 | if (optList[entry].doff != -1) |
553 | if (optList[entry].doff != -1) |
499 | rs[optList[entry].doff] = flag; |
554 | rs[optList[entry].doff] = flag; |
500 | } |
555 | } |
501 | } |
556 | } |
502 | else |
557 | else |
503 | #ifdef KEYSYM_RESOURCE |
558 | #ifdef KEYSYM_RESOURCE |
504 | /* if (!STRNCMP (opt, "keysym.", sizeof ("keysym.") - 1)) */ |
559 | /* if (!strncmp (opt, "keysym.", sizeof ("keysym.") - 1)) */ |
505 | if (rxvt_Str_match (opt, "keysym.")) |
560 | if (rxvt_Str_match (opt, "keysym.")) |
506 | { |
561 | { |
507 | const char *str = argv[++i]; |
562 | const char *str = argv[++i]; |
508 | |
563 | |
509 | if (str != NULL) |
564 | if (str != NULL) |
… | |
… | |
578 | { |
633 | { |
579 | if (str[0] == '0' && toupper (str[1]) == 'X') |
634 | if (str[0] == '0' && toupper (str[1]) == 'X') |
580 | str += 2; |
635 | str += 2; |
581 | if (arg) |
636 | if (arg) |
582 | { |
637 | { |
583 | if (sscanf (str, (STRCHR (str, ':') ? "%x:" : "%x"), &sym) != 1) |
638 | if (sscanf (str, (strchr (str, ':') ? "%x:" : "%x"), &sym) != 1) |
584 | return -1; |
639 | return -1; |
585 | } |
640 | } |
586 | else |
641 | else |
587 | { |
642 | { |
588 | if (sscanf (str, "%x:", &sym) != 1) |
643 | if (sscanf (str, "%x:", &sym) != 1) |
589 | return -1; |
644 | return -1; |
590 | |
645 | |
591 | /* cue to ':', it's there since sscanf () worked */ |
646 | /* cue to ':', it's there since sscanf () worked */ |
592 | STRNCPY (newargstr, STRCHR (str, ':') + 1, NEWARGLIM - 1); |
647 | strncpy (newargstr, strchr (str, ':') + 1, NEWARGLIM - 1); |
593 | newargstr[NEWARGLIM - 1] = '\0'; |
648 | newargstr[NEWARGLIM - 1] = '\0'; |
594 | newarg = newargstr; |
649 | newarg = newargstr; |
595 | } |
650 | } |
596 | } |
651 | } |
597 | else |
652 | else |
598 | { |
653 | { |
599 | /* |
654 | /* |
600 | * convert keysym name to keysym number |
655 | * convert keysym name to keysym number |
601 | */ |
656 | */ |
602 | STRNCPY (newargstr, str, NEWARGLIM - 1); |
657 | strncpy (newargstr, str, NEWARGLIM - 1); |
603 | newargstr[NEWARGLIM - 1] = '\0'; |
658 | newargstr[NEWARGLIM - 1] = '\0'; |
604 | if (arg == NULL) |
659 | if (arg == NULL) |
605 | { |
660 | { |
606 | if ((newarg = STRCHR (newargstr, ':')) == NULL) |
661 | if ((newarg = strchr (newargstr, ':')) == NULL) |
607 | return -1; |
662 | return -1; |
608 | *newarg++ = '\0'; /* terminate keysym name */ |
663 | *newarg++ = '\0'; /* terminate keysym name */ |
609 | } |
664 | } |
610 | if ((sym = XStringToKeysym (newargstr)) == None) |
665 | if ((sym = XStringToKeysym (newargstr)) == None) |
611 | return -1; |
666 | return -1; |
… | |
… | |
617 | if (Keysym_map[sym] != NULL) /* already set ? */ |
672 | if (Keysym_map[sym] != NULL) /* already set ? */ |
618 | return -1; |
673 | return -1; |
619 | |
674 | |
620 | if (newarg == NULL) |
675 | if (newarg == NULL) |
621 | { |
676 | { |
622 | STRNCPY (newargstr, arg, NEWARGLIM - 1); |
677 | strncpy (newargstr, arg, NEWARGLIM - 1); |
623 | newargstr[NEWARGLIM - 1] = '\0'; |
678 | newargstr[NEWARGLIM - 1] = '\0'; |
624 | newarg = newargstr; |
679 | newarg = newargstr; |
625 | } |
680 | } |
626 | rxvt_Str_trim (newarg); |
681 | rxvt_Str_trim (newarg); |
627 | if (*newarg == '\0' || (n = rxvt_Str_escaped (newarg)) == 0) |
682 | if (*newarg == '\0' || (n = rxvt_Str_escaped (newarg)) == 0) |
628 | return -1; |
683 | return -1; |
629 | MIN_IT (n, 255); |
684 | MIN_IT (n, 255); |
630 | key_string = (char *)rxvt_malloc ((n + 1) * sizeof (char)); |
685 | key_string = (char *)rxvt_malloc ((n + 1) * sizeof (char)); |
631 | |
686 | |
632 | key_string[0] = n; |
687 | key_string[0] = n; |
633 | STRNCPY (key_string + 1, newarg, n); |
688 | strncpy (key_string + 1, newarg, n); |
634 | Keysym_map[sym] = (unsigned char *)key_string; |
689 | Keysym_map[sym] = (unsigned char *)key_string; |
635 | |
690 | |
636 | return 1; |
691 | return 1; |
637 | } |
692 | } |
638 | |
693 | |
… | |
… | |
650 | char *str, buffer[256]; |
705 | char *str, buffer[256]; |
651 | |
706 | |
652 | if (stream == NULL) |
707 | if (stream == NULL) |
653 | return; |
708 | return; |
654 | |
709 | |
655 | len = STRLEN (name); |
710 | len = strlen (name); |
656 | while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL) |
711 | while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL) |
657 | { |
712 | { |
658 | unsigned int entry, n; |
713 | unsigned int entry, n; |
659 | |
714 | |
660 | while (*str && isspace (*str)) |
715 | while (*str && isspace (*str)) |
661 | str++; /* leading whitespace */ |
716 | str++; /* leading whitespace */ |
662 | |
717 | |
663 | if ((str[len] != '*' && str[len] != '.') |
718 | if ((str[len] != '*' && str[len] != '.') |
664 | || (len && STRNCMP (str, name, len))) |
719 | || (len && strncmp (str, name, len))) |
665 | continue; |
720 | continue; |
666 | str += (len + 1); /* skip `name*' or `name.' */ |
721 | str += (len + 1); /* skip `name*' or `name.' */ |
667 | |
722 | |
668 | # ifdef KEYSYM_RESOURCE |
723 | # ifdef KEYSYM_RESOURCE |
669 | if (!parse_keysym (str, NULL)) |
724 | if (!parse_keysym (str, NULL)) |
… | |
… | |
673 | const char *kw = optList[entry].kw; |
728 | const char *kw = optList[entry].kw; |
674 | |
729 | |
675 | if (kw == NULL) |
730 | if (kw == NULL) |
676 | continue; |
731 | continue; |
677 | |
732 | |
678 | n = STRLEN (kw); |
733 | n = strlen (kw); |
679 | if (str[n] == ':' && rxvt_Str_match (str, kw)) |
734 | if (str[n] == ':' && rxvt_Str_match (str, kw)) |
680 | { |
735 | { |
681 | /* skip `keyword:' */ |
736 | /* skip `keyword:' */ |
682 | str += n + 1; |
737 | str += n + 1; |
683 | rxvt_Str_trim (str); |
738 | rxvt_Str_trim (str); |
684 | n = STRLEN (str); |
739 | n = strlen (str); |
685 | if (n && rs[optList[entry].doff] == NULL) |
740 | if (n && rs[optList[entry].doff] == NULL) |
686 | { |
741 | { |
687 | /* not already set */ |
742 | /* not already set */ |
688 | int s; |
743 | int s; |
689 | char *p = 0; |
744 | char *p = 0; |
690 | |
745 | |
691 | for (int o = 0;;) |
746 | for (int o = 0;;) |
692 | { |
747 | { |
693 | p = (char *)rxvt_realloc (p, o + n + 1); |
748 | p = (char *)rxvt_realloc (p, o + n + 1); |
694 | MEMCPY (p + o, str, n); |
749 | memcpy (p + o, str, n); |
695 | o += n; |
750 | o += n; |
696 | p[o] = 0; |
751 | p[o] = 0; |
697 | |
752 | |
698 | if (o == 0 || p[o - 1] != '\\') // continuation line |
753 | if (o == 0 || p[o - 1] != '\\') // continuation line |
699 | break; |
754 | break; |
… | |
… | |
702 | |
757 | |
703 | if ((str = fgets (buffer, sizeof (buffer), stream)) == NULL) |
758 | if ((str = fgets (buffer, sizeof (buffer), stream)) == NULL) |
704 | break; |
759 | break; |
705 | |
760 | |
706 | rxvt_Str_trim (str); |
761 | rxvt_Str_trim (str); |
707 | n = STRLEN (str); |
762 | n = strlen (str); |
708 | } |
763 | } |
709 | |
764 | |
710 | rs[optList[entry].doff] = p; |
765 | rs[optList[entry].doff] = p; |
711 | allocated.push_back (p); |
766 | allocated.push_back (p); |
712 | |
767 | |
713 | if (optList_isBool (entry)) |
768 | if (optList_isBool (entry)) |
714 | { |
769 | { |
715 | s = STRCASECMP (str, "TRUE") == 0 |
770 | s = strcasecmp (str, "TRUE") == 0 |
716 | || STRCASECMP (str, "YES") == 0 |
771 | || strcasecmp (str, "YES") == 0 |
717 | || STRCASECMP (str, "ON") == 0 |
772 | || strcasecmp (str, "ON") == 0 |
718 | || STRCASECMP (str, "1") == 0; |
773 | || strcasecmp (str, "1") == 0; |
719 | |
774 | |
720 | if (optList_isReverse (entry)) |
775 | if (optList_isReverse (entry)) |
721 | s = !s; |
776 | s = !s; |
722 | |
777 | |
723 | if (s) |
778 | if (s) |
724 | Options |= optList[entry].flag; |
779 | options |= optList[entry].flag; |
725 | else |
780 | else |
726 | Options &= ~optList[entry].flag; |
781 | options &= ~optList[entry].flag; |
727 | } |
782 | } |
728 | } |
783 | } |
729 | |
784 | |
730 | break; |
785 | break; |
731 | } |
786 | } |
… | |
… | |
797 | if ((ptr = (char *)getenv ("HOME")) == NULL) |
852 | if ((ptr = (char *)getenv ("HOME")) == NULL) |
798 | ptr = "."; |
853 | ptr = "."; |
799 | |
854 | |
800 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
855 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
801 | { |
856 | { |
802 | sprintf (fname, "%-.*s/%s", sizeof (fname) - STRLEN (xnames[i]) - 2, |
857 | sprintf (fname, "%-.*s/%s", sizeof (fname) - strlen (xnames[i]) - 2, |
803 | ptr, xnames[i]); |
858 | ptr, xnames[i]); |
804 | if ((rdb1 = XrmGetFileDatabase (fname))) |
859 | if ((rdb1 = XrmGetFileDatabase (fname))) |
805 | { |
860 | { |
806 | XrmMergeDatabases (rdb1, &database); |
861 | XrmMergeDatabases (rdb1, &database); |
807 | # ifndef HAVE_BOTH_XRESOURCE_FILES |
862 | # ifndef HAVE_BOTH_XRESOURCE_FILES |
… | |
… | |
852 | if (kw == NULL || rs[optList[entry].doff] != NULL) |
907 | if (kw == NULL || rs[optList[entry].doff] != NULL) |
853 | continue; /* previously set */ |
908 | continue; /* previously set */ |
854 | |
909 | |
855 | p = XGetDefault (display, name, kw); |
910 | p = XGetDefault (display, name, kw); |
856 | p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); |
911 | p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); |
857 | if (p == NULL || (p0 && STRCMP (p, p0) == 0)) |
912 | if (p == NULL || (p0 && strcmp (p, p0) == 0)) |
858 | { |
913 | { |
859 | p = XGetDefault (display, RESCLASS, kw); |
914 | p = XGetDefault (display, RESCLASS, kw); |
860 | #ifdef RESFALLBACK |
915 | #ifdef RESFALLBACK |
861 | if (p == NULL || (p0 && STRCMP (p, p0) == 0)) |
916 | if (p == NULL || (p0 && strcmp (p, p0) == 0)) |
862 | p = XGetDefault (display, RESFALLBACK, kw); |
917 | p = XGetDefault (display, RESFALLBACK, kw); |
863 | #endif |
918 | #endif |
864 | } |
919 | } |
865 | |
920 | |
866 | if (p == NULL && p0) |
921 | if (p == NULL && p0) |
… | |
… | |
870 | { |
925 | { |
871 | rs[optList[entry].doff] = p; |
926 | rs[optList[entry].doff] = p; |
872 | |
927 | |
873 | if (optList_isBool (entry)) |
928 | if (optList_isBool (entry)) |
874 | { |
929 | { |
875 | s = STRCASECMP (p, "TRUE") == 0 |
930 | s = strcasecmp (p, "TRUE") == 0 |
876 | || STRCASECMP (p, "YES") == 0 |
931 | || strcasecmp (p, "YES") == 0 |
877 | || STRCASECMP (p, "ON") == 0 |
932 | || strcasecmp (p, "ON") == 0 |
878 | || STRCASECMP (p, "1") == 0; |
933 | || strcasecmp (p, "1") == 0; |
879 | if (optList_isReverse (entry)) |
934 | if (optList_isReverse (entry)) |
880 | s = !s; |
935 | s = !s; |
881 | if (s) |
936 | if (s) |
882 | Options |= (optList[entry].flag); |
937 | options |= (optList[entry].flag); |
883 | else |
938 | else |
884 | Options &= ~ (optList[entry].flag); |
939 | options &= ~ (optList[entry].flag); |
885 | } |
940 | } |
886 | } |
941 | } |
887 | } |
942 | } |
888 | |
943 | |
889 | /* |
944 | /* |
… | |
… | |
917 | FILE *fd = NULL; |
972 | FILE *fd = NULL; |
918 | char *home; |
973 | char *home; |
919 | |
974 | |
920 | if ((home = getenv ("HOME")) != NULL) |
975 | if ((home = getenv ("HOME")) != NULL) |
921 | { |
976 | { |
922 | unsigned int i, len = STRLEN (home) + 2; |
977 | unsigned int i, len = strlen (home) + 2; |
923 | char *f = NULL; |
978 | char *f = NULL; |
924 | |
979 | |
925 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
980 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
926 | { |
981 | { |
927 | f = (char *)rxvt_realloc (f, (len + STRLEN (xnames[i])) * sizeof (char)); |
982 | f = (char *)rxvt_realloc (f, (len + strlen (xnames[i])) * sizeof (char)); |
928 | |
983 | |
929 | sprintf (f, "%s/%s", home, xnames[i]); |
984 | sprintf (f, "%s/%s", home, xnames[i]); |
930 | |
985 | |
931 | if ((fd = fopen (f, "r")) != NULL) |
986 | if ((fd = fopen (f, "r")) != NULL) |
932 | break; |
987 | break; |