aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac.c
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2005-04-16 03:03:02 +0000
committerYAMAMOTO Mitsuharu2005-04-16 03:03:02 +0000
commite8d8317c364bd7e3cca41478eb4f68b19da09cf5 (patch)
treefee3a02b630ce40bb377ca192b7e885d362c09a1 /src/mac.c
parent5f400376f0092ad45c9792671ab55343f604a4bb (diff)
downloademacs-e8d8317c364bd7e3cca41478eb4f68b19da09cf5.tar.gz
emacs-e8d8317c364bd7e3cca41478eb4f68b19da09cf5.zip
Include charset.h and coding.h.
[TARGET_API_MAC_CARBON] (Qutf_8): Remove extern. [TARGET_API_MAC_CARBON] (cfstring_create_with_string): New function. [TARGET_API_MAC_CARBON] (Fmac_get_preference): Use it.
Diffstat (limited to 'src/mac.c')
-rw-r--r--src/mac.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/mac.c b/src/mac.c
index a11b097264c..68e3bdfa065 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -31,6 +31,8 @@ Boston, MA 02111-1307, USA. */
31#include "sysselect.h" 31#include "sysselect.h"
32#include "systime.h" 32#include "systime.h"
33#include "blockinput.h" 33#include "blockinput.h"
34#include "charset.h"
35#include "coding.h"
34 36
35#include "macterm.h" 37#include "macterm.h"
36 38
@@ -265,7 +267,6 @@ posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen)
265#if TARGET_API_MAC_CARBON 267#if TARGET_API_MAC_CARBON
266static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata; 268static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata;
267static Lisp_Object Qarray, Qdictionary; 269static Lisp_Object Qarray, Qdictionary;
268extern Lisp_Object Qutf_8;
269#define DECODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 0) 270#define DECODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 0)
270 271
271struct cfdict_context 272struct cfdict_context
@@ -274,7 +275,7 @@ struct cfdict_context
274 int with_tag, hash_bound; 275 int with_tag, hash_bound;
275}; 276};
276 277
277/* C string to CFString. */ 278/* C string to CFString. */
278 279
279CFStringRef 280CFStringRef
280cfstring_create_with_utf8_cstring (c_str) 281cfstring_create_with_utf8_cstring (c_str)
@@ -291,6 +292,37 @@ cfstring_create_with_utf8_cstring (c_str)
291} 292}
292 293
293 294
295/* Lisp string to CFString. */
296
297CFStringRef
298cfstring_create_with_string (s)
299 Lisp_Object s;
300{
301 CFStringRef string = NULL;
302
303 if (STRING_MULTIBYTE (s))
304 {
305 char *p, *end = SDATA (s) + SBYTES (s);
306
307 for (p = SDATA (s); p < end; p++)
308 if (!isascii (*p))
309 {
310 s = ENCODE_UTF_8 (s);
311 break;
312 }
313 string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
314 kCFStringEncodingUTF8, false);
315 }
316
317 if (string == NULL)
318 /* Failed to interpret as UTF 8. Fall back on Mac Roman. */
319 string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
320 kCFStringEncodingMacRoman, false);
321
322 return string;
323}
324
325
294/* From CFData to a lisp string. Always returns a unibyte string. */ 326/* From CFData to a lisp string. Always returns a unibyte string. */
295 327
296Lisp_Object 328Lisp_Object
@@ -3711,11 +3743,11 @@ otherwise. */)
3711 app_id = kCFPreferencesCurrentApplication; 3743 app_id = kCFPreferencesCurrentApplication;
3712 if (!NILP (application)) 3744 if (!NILP (application))
3713 { 3745 {
3714 app_id = cfstring_create_with_utf8_cstring (SDATA (application)); 3746 app_id = cfstring_create_with_string (application);
3715 if (app_id == NULL) 3747 if (app_id == NULL)
3716 goto out; 3748 goto out;
3717 } 3749 }
3718 key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key))); 3750 key_str = cfstring_create_with_string (XCAR (key));
3719 if (key_str == NULL) 3751 if (key_str == NULL)
3720 goto out; 3752 goto out;
3721 app_plist = CFPreferencesCopyAppValue (key_str, app_id); 3753 app_plist = CFPreferencesCopyAppValue (key_str, app_id);
@@ -3728,7 +3760,7 @@ otherwise. */)
3728 { 3760 {
3729 if (CFGetTypeID (plist) != CFDictionaryGetTypeID ()) 3761 if (CFGetTypeID (plist) != CFDictionaryGetTypeID ())
3730 break; 3762 break;
3731 key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key))); 3763 key_str = cfstring_create_with_string (XCAR (key));
3732 if (key_str == NULL) 3764 if (key_str == NULL)
3733 goto out; 3765 goto out;
3734 plist = CFDictionaryGetValue (plist, key_str); 3766 plist = CFDictionaryGetValue (plist, key_str);