repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: e3c5b8730bb5dfc35081d8ae872e2259a7061f7e: path_to: revision_to:
commit e3c5b8730bb5dfc35081d8ae872e2259a7061f7e Author: Emanuele GiaquintaDate: Thu May 24 16:19:26 2012 +0000 Factor the code to parse a boolean resource and to find all the resources matching a given prefix into new methods. diff --git a/src/rxvt.h b/src/rxvt.h
--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -1571,6 +1571,15 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen
const char *x_resource (const char *name);
void extract_resources ();
void extract_keysym_resources ();
+ void find_resources (const char *n_prefix, const char *c_prefix, int mode,
+ Bool (*proc)(XrmDatabase *, XrmBindingList, XrmQuarkList, XrmRepresentation *, XrmValue *, XPointer));
+ bool parse_bool_resource (const char *str)
+ {
+ return (!strcasecmp (str, "TRUE")
+ || !strcasecmp (str, "YES")
+ || !strcasecmp (str, "ON")
+ || !strcasecmp (str, "1"));
+ }
};
#endif /* _RXVT_H_ */
diff --git a/src/xdefaults.C b/src/xdefaults.C
--- a/src/xdefaults.C
+++ b/src/xdefaults.C
@@ -762,7 +762,6 @@ rxvt_term::extract_resources ()
*/
for (int entry = 0; entry < ecb_array_length (optList); entry++)
{
- int s;
const char *kw = optList[entry].kw;
if (kw == NULL || rs[optList[entry].doff] != NULL)
@@ -778,10 +777,7 @@ rxvt_term::extract_resources ()
if (optList_isBool (entry))
{
- s = strcasecmp (p, "TRUE") == 0
- || strcasecmp (p, "YES") == 0
- || strcasecmp (p, "ON") == 0
- || strcasecmp (p, "1") == 0;
+ bool s = parse_bool_resource (p);
if (optList_isReverse (entry))
s = !s;
@@ -796,33 +792,39 @@ rxvt_term::extract_resources ()
void
rxvt_term::extract_keysym_resources ()
{
-#ifndef NO_RESOURCES
+#if !defined NO_RESOURCES && defined KEYSYM_RESOURCE
+ find_resources ("keysym", "Keysym", XrmEnumOneLevel, rxvt_define_key);
+#endif
+}
+
+#if !defined NO_RESOURCES && defined KEYSYM_RESOURCE
+void
+rxvt_term::find_resources (const char *n_prefix, const char *c_prefix, int mode,
+ Bool (*proc)(XrmDatabase *, XrmBindingList, XrmQuarkList, XrmRepresentation *, XrmValue *, XPointer))
+{
/*
* [R5 or later]: enumerate the resource database
*/
-# ifdef KEYSYM_RESOURCE
XrmDatabase database = XrmGetDatabase (dpy);
XrmName name_prefix[3];
XrmClass class_prefix[3];
name_prefix[0] = XrmStringToName (rs[Rs_name]);
- name_prefix[1] = XrmStringToName ("keysym");
+ name_prefix[1] = XrmStringToName (n_prefix);
name_prefix[2] = NULLQUARK;
class_prefix[0] = XrmStringToName (RESCLASS);
- class_prefix[1] = XrmStringToName ("Keysym");
+ class_prefix[1] = XrmStringToName (c_prefix);
class_prefix[2] = NULLQUARK;
/* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
XrmEnumerateDatabase (database, name_prefix, class_prefix,
- XrmEnumOneLevel, rxvt_define_key, NULL);
+ mode, proc, NULL);
# ifdef RESFALLBACK
name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK);
/* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
XrmEnumerateDatabase (database, name_prefix, class_prefix,
- XrmEnumOneLevel, rxvt_define_key, NULL);
+ mode, proc, NULL);
# endif
-# endif
-
-#endif /* NO_RESOURCES */
}
+#endif
/*----------------------- end-of-file (C source) -----------------------*/
-----END OF PAGE-----