+2011-12-10 Jan Djärv <jan.h.d@swipnet.se>
+
+ * nsfns.m (ns_get_defaults_value): New function (Bug#10103).
+ (Fns_get_resource, x_get_string_resource): Call ns_get_defaults_value.
+
+ * nsterm.h (ns_get_defaults_value): Declare.
+
+ * nsterm.m (ns_default): Call ns_get_defaults_value.
+
2011-12-09 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (try_scrolling): Don't set scroll_down_p if dy is zero.
return ret ? fname : Qnil;
}
+const char *
+ns_get_defaults_value (const char *key)
+{
+ NSObject *obj = [[NSUserDefaults standardUserDefaults]
+ objectForKey: [NSString stringWithUTF8String: key]];
+
+ if (!obj) return NULL;
+
+ return [[NSString stringWithFormat: @"%@", obj] UTF8String];
+}
+
DEFUN ("ns-get-resource", Fns_get_resource, Sns_get_resource, 2, 2, 0,
doc: /* Return the value of the property NAME of OWNER from the defaults database.
CHECK_STRING (name);
/*fprintf (stderr, "ns-get-resource checking resource '%s'\n", SDATA (name)); */
- value =[[[NSUserDefaults standardUserDefaults]
- objectForKey: [NSString stringWithUTF8String: SDATA (name)]]
- UTF8String];
+ value = ns_get_defaults_value (SDATA (name));
if (value)
return build_string (value);
/* --quick was passed, so this is a no-op. */
return NULL;
- res = [[[NSUserDefaults standardUserDefaults] objectForKey:
- [NSString stringWithUTF8String: toCheck]] UTF8String];
+ res = ns_get_defaults_value (toCheck);
return !res ? NULL :
(!strncasecmp (res, "YES", 3) ? "true" :
(!strncasecmp (res, "NO", 2) ? "false" : res));
extern void ns_retain_object (void *obj);
extern void *ns_alloc_autorelease_pool ();
extern void ns_release_autorelease_pool ();
+extern const char *ns_get_defaults_value ();
/* in nsmenu */
extern void update_frame_tool_bar (FRAME_PTR f);
Check a parameter value in user's preferences
-------------------------------------------------------------------------- */
{
- const char *value;
+ const char *value = ns_get_defaults_value (parameter);
- if ( (value =[[[NSUserDefaults standardUserDefaults]
- stringForKey: [NSString stringWithUTF8String: parameter]]
- UTF8String]) )
+ if (value)
{
double f;
char *pos;