+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,
{
#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);
{
#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);
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 */
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))
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;
}
}
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);
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);
}