ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/xdefaults.C
(Generate patch)

Comparing rxvt-unicode/src/xdefaults.C (file contents):
Revision 1.15 by pcg, Wed Mar 3 04:07:52 2004 UTC vs.
Revision 1.17 by pcg, Sun Mar 14 17:33:08 2004 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: xdefaults.c 2 * File: xdefaults.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: xdefaults.C,v 1.15 2004/03/03 04:07:52 pcg Exp $ 4 * $Id: xdefaults.C,v 1.17 2004/03/14 17:33:08 pcg Exp $
5 * 5 *
6 * All portions of code are copyright by their respective author/s. 6 * All portions of code are copyright by their respective author/s.
7 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> 7 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
8 * - original version 8 * - original version
9 * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca> 9 * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca>
240 RSTRG (Rs_scrollBar_align, "scrollBar_align", "mode"), 240 RSTRG (Rs_scrollBar_align, "scrollBar_align", "mode"),
241#endif 241#endif
242#ifdef PRINTPIPE 242#ifdef PRINTPIPE
243 RSTRG (Rs_print_pipe, "print-pipe", "string"), 243 RSTRG (Rs_print_pipe, "print-pipe", "string"),
244#endif 244#endif
245#if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
246 RSTRG (Rs_bigfont_key, "bigfont_key", "keysym"),
247 RSTRG (Rs_smallfont_key, "smallfont_key", "keysym"),
248#endif
249 STRG (Rs_modifier, "modifier", "mod", "modifier", 245 STRG (Rs_modifier, "modifier", "mod", "modifier",
250 "meta modifier = alt|meta|hyper|super|mod1|...|mod5"), 246 "meta modifier = alt|meta|hyper|super|mod1|...|mod5"),
251 INFO ("xrm", "string", "X resource"), 247 INFO ("xrm", "string", "X resource"),
252#ifdef CUTCHAR_RESOURCE 248#ifdef CUTCHAR_RESOURCE
253 RSTRG (Rs_cutchars, "cutchars", "string"), 249 RSTRG (Rs_cutchars, "cutchars", "string"),
254#endif /* CUTCHAR_RESOURCE */ 250#endif /* CUTCHAR_RESOURCE */
255#ifdef ACS_ASCII
256 RSTRG (Rs_acs_chars, "acsChars", "string"),
257#endif /* ACS_ASCII */
258 RSTRG (Rs_answerbackstring, "answerbackString", "string"), 251 RSTRG (Rs_answerbackstring, "answerbackString", "string"),
259 INFO ("e", "command arg ...", "command to execute") 252 INFO ("e", "command arg ...", "command to execute")
260 }; 253 };
261 254
262#undef INFO 255#undef INFO
670 * the matching algorithm used for memory-save fake resources 663 * the matching algorithm used for memory-save fake resources
671 */ 664 */
672void 665void
673rxvt_term::get_xdefaults (FILE *stream, const char *name) 666rxvt_term::get_xdefaults (FILE *stream, const char *name)
674{ 667{
675 unsigned int len; 668 unsigned int len;
676 char *str, buffer[256]; 669 char *str, buffer[256];
677 670
678 if (stream == NULL) 671 if (stream == NULL)
679 return; 672 return;
680 len = STRLEN (name); 673 len = STRLEN (name);
681 while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL) 674 while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL)
701 continue; 694 continue;
702 n = STRLEN (kw); 695 n = STRLEN (kw);
703 if (str[n] == ':' && rxvt_Str_match (str, kw)) 696 if (str[n] == ':' && rxvt_Str_match (str, kw))
704 { 697 {
705 /* skip `keyword:' */ 698 /* skip `keyword:' */
706 str += (n + 1); 699 str += n + 1;
707 rxvt_Str_trim (str); 700 rxvt_Str_trim (str);
708 n = STRLEN (str); 701 n = STRLEN (str);
709 if (n && rs[optList[entry].doff] == NULL) 702 if (n && rs[optList[entry].doff] == NULL)
710 { 703 {
711 /* not already set */ 704 /* not already set */
712 int s; 705 int s;
713 char *p = (char *)rxvt_malloc ((n + 1) * sizeof (char)); 706 char *p = 0;
714 707
708 for (int o = 0;;)
709 {
710 p = (char *)rxvt_realloc (p, o + n + 1);
715 STRCPY (p, str); 711 MEMCPY (p + o, str, n);
712 o += n;
713 p[o] = 0;
714
715 if (o == 0 || p[o - 1] != '\\') // continuation line
716 break;
717
718 o--; // eat "\"
719
720 if ((str = fgets (buffer, sizeof (buffer), stream)) == NULL)
721 break;
722
723 rxvt_Str_trim (str);
724 n = STRLEN (str);
725 }
726
716 rs[optList[entry].doff] = p; 727 rs[optList[entry].doff] = p;
717 if (optList_isBool (entry)) 728 if (optList_isBool (entry))
718 { 729 {
719 s = STRCASECMP (str, "TRUE") == 0 730 s = STRCASECMP (str, "TRUE") == 0
720 || STRCASECMP (str, "YES") == 0 731 || STRCASECMP (str, "YES") == 0
960# ifdef RESFALLBACK 971# ifdef RESFALLBACK
961 get_xdefaults (fd, RESFALLBACK); 972 get_xdefaults (fd, RESFALLBACK);
962# endif 973# endif
963 974
964# if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR) 975# if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR)
965
966 { 976 {
967 FILE *ad = NULL; 977 FILE *ad = NULL;
968 978
969# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) 979# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
970 if (localepath == NULL || (ad = fopen (localepath, "r")) == NULL) 980 if (localepath == NULL || (ad = fopen (localepath, "r")) == NULL)
971# endif 981# endif
972 ad = fopen (XAPPLOADDIR "/" RESCLASS, "r"); 982 ad = fopen (XAPPLOADDIR "/" RESCLASS, "r");
993 free (localepath); 1003 free (localepath);
994# endif 1004# endif
995# endif 1005# endif
996 1006
997#endif /* NO_RESOURCES */ 1007#endif /* NO_RESOURCES */
998
999 /*
1000 * even without resources, at least do this setup for command-line
1001 * options and command-line long options
1002 */
1003
1004#if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
1005 KeySym sym;
1006
1007 if (rs[Rs_bigfont_key]
1008 && ((sym = XStringToKeysym (rs[Rs_bigfont_key])) != 0))
1009 ks_bigfont = sym;
1010 if (rs[Rs_smallfont_key]
1011 && ((sym = XStringToKeysym (rs[Rs_smallfont_key])) != 0))
1012 ks_smallfont = sym;
1013#endif
1014} 1008}
1015 1009
1016/*}}} */ 1010/*}}} */
1017/*----------------------- end-of-file (C source) -----------------------*/ 1011/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines