diff options
| author | Steven Tamm | 2004-12-03 17:00:11 +0000 |
|---|---|---|
| committer | Steven Tamm | 2004-12-03 17:00:11 +0000 |
| commit | d8f96db8dacbda24147aeab0af1c74f5ddbec8bb (patch) | |
| tree | 8366e98883775a322f0c52ae59441ef2ccc6569f /src | |
| parent | 4e4b7d76d13bcf88958964be7ca722130b086cd0 (diff) | |
| download | emacs-d8f96db8dacbda24147aeab0af1c74f5ddbec8bb.tar.gz emacs-d8f96db8dacbda24147aeab0af1c74f5ddbec8bb.zip | |
* macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
* image.c (image_load_quartz2d): Use
cfstring_create_with_utf8_cstring
* macmenu.c (add_menu_item): Use
cfstring_create_with_utf8_cstring
* macfns.c (x_set_name, x_set_title): Use
cfstring_create_with_utf8_cstring
(Fx_file_dialog): Use cfstring_create_with_utf8_cstring and use
constant CFRefs instead of creating them each time for labels.
* mac.c (cfstring_create_with_utf8_cstring): Added to prevent
crashes with invalid characters.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/image.c | 3 | ||||
| -rw-r--r-- | src/mac.c | 16 | ||||
| -rw-r--r-- | src/macfns.c | 31 | ||||
| -rw-r--r-- | src/macmenu.c | 13 | ||||
| -rw-r--r-- | src/macterm.h | 4 |
6 files changed, 46 insertions, 35 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f6ebe27ebfb..5d3e621a568 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2004-12-03 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * macterm.h (cfstring_create_with_utf8_cstring): Added prototype. | ||
| 4 | * image.c (image_load_quartz2d): Use | ||
| 5 | cfstring_create_with_utf8_cstring | ||
| 6 | * macmenu.c (add_menu_item): Use | ||
| 7 | cfstring_create_with_utf8_cstring | ||
| 8 | * macfns.c (x_set_name, x_set_title): Use | ||
| 9 | cfstring_create_with_utf8_cstring | ||
| 10 | (Fx_file_dialog): Use cfstring_create_with_utf8_cstring and use | ||
| 11 | constant CFRefs instead of creating them each time for labels. | ||
| 12 | * mac.c (cfstring_create_with_utf8_cstring): Added to prevent | ||
| 13 | crashes with invalid characters. | ||
| 14 | |||
| 1 | 2004-12-02 Richard M. Stallman <rms@gnu.org> | 15 | 2004-12-02 Richard M. Stallman <rms@gnu.org> |
| 2 | 16 | ||
| 3 | * config.in (RE_TRANSLATE_P): If make_number is not a macro, | 17 | * config.in (RE_TRANSLATE_P): If make_number is not a macro, |
diff --git a/src/image.c b/src/image.c index 4ab672ca58e..d1925cf36e4 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -2416,8 +2416,7 @@ image_load_quartz2d (f, img, png_p) | |||
| 2416 | UNGCPRO; | 2416 | UNGCPRO; |
| 2417 | return 0; | 2417 | return 0; |
| 2418 | } | 2418 | } |
| 2419 | path = CFStringCreateWithCString (NULL, SDATA (file), | 2419 | path = cfstring_create_with_utf8_cstring (SDATA (file)); |
| 2420 | kCFStringEncodingUTF8); | ||
| 2421 | url = CFURLCreateWithFileSystemPath (NULL, path, | 2420 | url = CFURLCreateWithFileSystemPath (NULL, path, |
| 2422 | kCFURLPOSIXPathStyle, 0); | 2421 | kCFURLPOSIXPathStyle, 0); |
| 2423 | CFRelease (path); | 2422 | CFRelease (path); |
| @@ -262,6 +262,22 @@ posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen) | |||
| 262 | return 1; | 262 | return 1; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | #if TARGET_API_MAC_CARBON | ||
| 266 | CFStringRef | ||
| 267 | cfstring_create_with_utf8_cstring (c_str) | ||
| 268 | const char *c_str; | ||
| 269 | { | ||
| 270 | CFStringRef str; | ||
| 271 | |||
| 272 | str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingUTF8); | ||
| 273 | if (str == NULL) | ||
| 274 | /* Failed to interpret as UTF 8. Fall back on Mac Roman. */ | ||
| 275 | str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingMacRoman); | ||
| 276 | |||
| 277 | return str; | ||
| 278 | } | ||
| 279 | #endif | ||
| 280 | |||
| 265 | #ifndef MAC_OSX | 281 | #ifndef MAC_OSX |
| 266 | 282 | ||
| 267 | /* The following functions with "sys_" prefix are stubs to Unix | 283 | /* The following functions with "sys_" prefix are stubs to Unix |
diff --git a/src/macfns.c b/src/macfns.c index 9220bdd2798..fdfe7a52416 100644 --- a/src/macfns.c +++ b/src/macfns.c | |||
| @@ -1932,8 +1932,7 @@ x_set_name (f, name, explicit) | |||
| 1932 | { | 1932 | { |
| 1933 | #if TARGET_API_MAC_CARBON | 1933 | #if TARGET_API_MAC_CARBON |
| 1934 | CFStringRef windowTitle = | 1934 | CFStringRef windowTitle = |
| 1935 | CFStringCreateWithCString (NULL, SDATA (name), | 1935 | cfstring_create_with_utf8_cstring (SDATA (name)); |
| 1936 | kCFStringEncodingUTF8); | ||
| 1937 | 1936 | ||
| 1938 | SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle); | 1937 | SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle); |
| 1939 | CFRelease (windowTitle); | 1938 | CFRelease (windowTitle); |
| @@ -2015,8 +2014,7 @@ x_set_title (f, name, old_name) | |||
| 2015 | { | 2014 | { |
| 2016 | #if TARGET_API_MAC_CARBON | 2015 | #if TARGET_API_MAC_CARBON |
| 2017 | CFStringRef windowTitle = | 2016 | CFStringRef windowTitle = |
| 2018 | CFStringCreateWithCString (NULL, SDATA (name), | 2017 | cfstring_create_with_utf8_cstring (SDATA (name)); |
| 2019 | kCFStringEncodingUTF8); | ||
| 2020 | 2018 | ||
| 2021 | SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle); | 2019 | SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle); |
| 2022 | CFRelease (windowTitle); | 2020 | CFRelease (windowTitle); |
| @@ -4246,8 +4244,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) | |||
| 4246 | NavDialogRef dialogRef; | 4244 | NavDialogRef dialogRef; |
| 4247 | NavTypeListHandle fileTypes = NULL; | 4245 | NavTypeListHandle fileTypes = NULL; |
| 4248 | NavUserAction userAction; | 4246 | NavUserAction userAction; |
| 4249 | CFStringRef message=NULL, client=NULL, saveName = NULL, ok = NULL; | 4247 | CFStringRef message=NULL, saveName = NULL; |
| 4250 | CFStringRef title = NULL; | ||
| 4251 | 4248 | ||
| 4252 | BLOCK_INPUT; | 4249 | BLOCK_INPUT; |
| 4253 | /* No need for a callback function because we are modal */ | 4250 | /* No need for a callback function because we are modal */ |
| @@ -4259,15 +4256,11 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) | |||
| 4259 | options.optionFlags |= kNavSelectAllReadableItem; | 4256 | options.optionFlags |= kNavSelectAllReadableItem; |
| 4260 | if (!NILP(prompt)) | 4257 | if (!NILP(prompt)) |
| 4261 | { | 4258 | { |
| 4262 | message = CFStringCreateWithCStringNoCopy(NULL, SDATA(prompt), | 4259 | message = cfstring_create_with_utf8_cstring (SDATA (prompt)); |
| 4263 | kCFStringEncodingUTF8, | ||
| 4264 | kCFAllocatorNull); | ||
| 4265 | options.message = message; | 4260 | options.message = message; |
| 4266 | } | 4261 | } |
| 4267 | /* Don't set the application, let it use default. | 4262 | /* Don't set the application, let it use default. |
| 4268 | client = CFStringCreateWithCStringNoCopy(NULL, "Emacs", | 4263 | options.clientName = CFSTR ("Emacs"); |
| 4269 | kCFStringEncodingMacRoman, NULL); | ||
| 4270 | options.clientName = client; | ||
| 4271 | */ | 4264 | */ |
| 4272 | 4265 | ||
| 4273 | if (!NILP (only_dir_p)) | 4266 | if (!NILP (only_dir_p)) |
| @@ -4276,17 +4269,14 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) | |||
| 4276 | else if (NILP (mustmatch)) | 4269 | else if (NILP (mustmatch)) |
| 4277 | { | 4270 | { |
| 4278 | /* This is a save dialog */ | 4271 | /* This is a save dialog */ |
| 4279 | ok = CFStringCreateWithCString (NULL, "Ok", kCFStringEncodingUTF8); | ||
| 4280 | title = CFStringCreateWithCString (NULL, "Enter name", | ||
| 4281 | kCFStringEncodingUTF8); | ||
| 4282 | options.optionFlags |= kNavDontConfirmReplacement; | 4272 | options.optionFlags |= kNavDontConfirmReplacement; |
| 4283 | options.actionButtonLabel = ok; | 4273 | options.actionButtonLabel = CFSTR ("Ok"); |
| 4284 | options.windowTitle = title; | 4274 | options.windowTitle = CFSTR ("Enter name"); |
| 4285 | 4275 | ||
| 4286 | if (!NILP(default_filename)) | 4276 | if (!NILP(default_filename)) |
| 4287 | { | 4277 | { |
| 4288 | saveName = CFStringCreateWithCString(NULL, SDATA(default_filename), | 4278 | saveName = |
| 4289 | kCFStringEncodingUTF8); | 4279 | cfstring_create_with_utf8_cstring (SDATA (default_filename)); |
| 4290 | options.saveFileName = saveName; | 4280 | options.saveFileName = saveName; |
| 4291 | options.optionFlags |= kNavSelectDefaultLocation; | 4281 | options.optionFlags |= kNavSelectDefaultLocation; |
| 4292 | } | 4282 | } |
| @@ -4320,10 +4310,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) | |||
| 4320 | } | 4310 | } |
| 4321 | 4311 | ||
| 4322 | if (saveName) CFRelease(saveName); | 4312 | if (saveName) CFRelease(saveName); |
| 4323 | if (client) CFRelease(client); | ||
| 4324 | if (message) CFRelease(message); | 4313 | if (message) CFRelease(message); |
| 4325 | if (ok) CFRelease(ok); | ||
| 4326 | if (title) CFRelease(title); | ||
| 4327 | 4314 | ||
| 4328 | if (status == noErr) { | 4315 | if (status == noErr) { |
| 4329 | userAction = NavDialogGetUserAction(dialogRef); | 4316 | userAction = NavDialogGetUserAction(dialogRef); |
diff --git a/src/macmenu.c b/src/macmenu.c index af24cfe237c..f0696a49774 100644 --- a/src/macmenu.c +++ b/src/macmenu.c | |||
| @@ -2264,17 +2264,8 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu, | |||
| 2264 | item_name[255] = 0; | 2264 | item_name[255] = 0; |
| 2265 | #if TARGET_API_MAC_CARBON | 2265 | #if TARGET_API_MAC_CARBON |
| 2266 | { | 2266 | { |
| 2267 | CFStringRef string = | 2267 | CFStringRef string = cfstring_create_with_utf8_cstring (item_name); |
| 2268 | CFStringCreateWithCString (NULL, item_name, kCFStringEncodingUTF8); | 2268 | |
| 2269 | |||
| 2270 | if (string == NULL) | ||
| 2271 | { | ||
| 2272 | /* Failed to interpret as UTF8. Fall back to Mac Roman. | ||
| 2273 | Maybe wv->name is corrupted? */ | ||
| 2274 | string = CFStringCreateWithCString (NULL, item_name, | ||
| 2275 | kCFStringEncodingMacRoman); | ||
| 2276 | } | ||
| 2277 | |||
| 2278 | SetMenuItemTextWithCFString (menu, pos, string); | 2269 | SetMenuItemTextWithCFString (menu, pos, string); |
| 2279 | CFRelease (string); | 2270 | CFRelease (string); |
| 2280 | } | 2271 | } |
diff --git a/src/macterm.h b/src/macterm.h index f9bde772fcd..ff7110828b1 100644 --- a/src/macterm.h +++ b/src/macterm.h | |||
| @@ -600,5 +600,9 @@ extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int, | |||
| 600 | #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0 | 600 | #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0 |
| 601 | #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0 | 601 | #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0 |
| 602 | 602 | ||
| 603 | #if TARGET_API_MAC_CARBON | ||
| 604 | extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *)); | ||
| 605 | #endif | ||
| 606 | |||
| 603 | /* arch-tag: 6b4ca125-5bef-476d-8ee8-31ed808b7e79 | 607 | /* arch-tag: 6b4ca125-5bef-476d-8ee8-31ed808b7e79 |
| 604 | (do not change this comment) */ | 608 | (do not change this comment) */ |