Commit d8f96db8 authored by Steven Tamm's avatar Steven Tamm
Browse files

* 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.
parent 4e4b7d76
2004-12-03 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
* 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.
2004-12-02 Richard M. Stallman <rms@gnu.org>
 
* config.in (RE_TRANSLATE_P): If make_number is not a macro,
......
......@@ -2416,8 +2416,7 @@ image_load_quartz2d (f, img, png_p)
UNGCPRO;
return 0;
}
path = CFStringCreateWithCString (NULL, SDATA (file),
kCFStringEncodingUTF8);
path = cfstring_create_with_utf8_cstring (SDATA (file));
url = CFURLCreateWithFileSystemPath (NULL, path,
kCFURLPOSIXPathStyle, 0);
CFRelease (path);
......
......@@ -262,6 +262,22 @@ posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen)
return 1;
}
#if TARGET_API_MAC_CARBON
CFStringRef
cfstring_create_with_utf8_cstring (c_str)
const char *c_str;
{
CFStringRef str;
str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingUTF8);
if (str == NULL)
/* Failed to interpret as UTF 8. Fall back on Mac Roman. */
str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingMacRoman);
return str;
}
#endif
#ifndef MAC_OSX
/* The following functions with "sys_" prefix are stubs to Unix
......
......@@ -1932,8 +1932,7 @@ x_set_name (f, name, explicit)
{
#if TARGET_API_MAC_CARBON
CFStringRef windowTitle =
CFStringCreateWithCString (NULL, SDATA (name),
kCFStringEncodingUTF8);
cfstring_create_with_utf8_cstring (SDATA (name));
SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
CFRelease (windowTitle);
......@@ -2015,8 +2014,7 @@ x_set_title (f, name, old_name)
{
#if TARGET_API_MAC_CARBON
CFStringRef windowTitle =
CFStringCreateWithCString (NULL, SDATA (name),
kCFStringEncodingUTF8);
cfstring_create_with_utf8_cstring (SDATA (name));
SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
CFRelease (windowTitle);
......@@ -4246,8 +4244,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
NavDialogRef dialogRef;
NavTypeListHandle fileTypes = NULL;
NavUserAction userAction;
CFStringRef message=NULL, client=NULL, saveName = NULL, ok = NULL;
CFStringRef title = NULL;
CFStringRef message=NULL, saveName = NULL;
BLOCK_INPUT;
/* 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. */)
options.optionFlags |= kNavSelectAllReadableItem;
if (!NILP(prompt))
{
message = CFStringCreateWithCStringNoCopy(NULL, SDATA(prompt),
kCFStringEncodingUTF8,
kCFAllocatorNull);
message = cfstring_create_with_utf8_cstring (SDATA (prompt));
options.message = message;
}
/* Don't set the application, let it use default.
client = CFStringCreateWithCStringNoCopy(NULL, "Emacs",
kCFStringEncodingMacRoman, NULL);
options.clientName = client;
options.clientName = CFSTR ("Emacs");
*/
if (!NILP (only_dir_p))
......@@ -4276,17 +4269,14 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
else if (NILP (mustmatch))
{
/* This is a save dialog */
ok = CFStringCreateWithCString (NULL, "Ok", kCFStringEncodingUTF8);
title = CFStringCreateWithCString (NULL, "Enter name",
kCFStringEncodingUTF8);
options.optionFlags |= kNavDontConfirmReplacement;
options.actionButtonLabel = ok;
options.windowTitle = title;
options.actionButtonLabel = CFSTR ("Ok");
options.windowTitle = CFSTR ("Enter name");
if (!NILP(default_filename))
{
saveName = CFStringCreateWithCString(NULL, SDATA(default_filename),
kCFStringEncodingUTF8);
saveName =
cfstring_create_with_utf8_cstring (SDATA (default_filename));
options.saveFileName = saveName;
options.optionFlags |= kNavSelectDefaultLocation;
}
......@@ -4320,10 +4310,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
}
if (saveName) CFRelease(saveName);
if (client) CFRelease(client);
if (message) CFRelease(message);
if (ok) CFRelease(ok);
if (title) CFRelease(title);
if (status == noErr) {
userAction = NavDialogGetUserAction(dialogRef);
......
......@@ -2264,17 +2264,8 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu,
item_name[255] = 0;
#if TARGET_API_MAC_CARBON
{
CFStringRef string =
CFStringCreateWithCString (NULL, item_name, kCFStringEncodingUTF8);
if (string == NULL)
{
/* Failed to interpret as UTF8. Fall back to Mac Roman.
Maybe wv->name is corrupted? */
string = CFStringCreateWithCString (NULL, item_name,
kCFStringEncodingMacRoman);
}
CFStringRef string = cfstring_create_with_utf8_cstring (item_name);
SetMenuItemTextWithCFString (menu, pos, string);
CFRelease (string);
}
......
......@@ -600,5 +600,9 @@ extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int,
#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
#if TARGET_API_MAC_CARBON
extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *));
#endif
/* arch-tag: 6b4ca125-5bef-476d-8ee8-31ed808b7e79
(do not change this comment) */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment