all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Cocoa port: nsfont_escape_name error
@ 2008-07-18  4:54 Seiji Zenitani
  2008-07-19  0:05 ` Seiji Zenitani
  0 siblings, 1 reply; 3+ messages in thread
From: Seiji Zenitani @ 2008-07-18  4:54 UTC (permalink / raw)
  To: emacs-devel

Hi,

Cocoa Emacs works fine in Mac OSX English environment.
However, it (the same executable binary) immediately
crashes in Japanese language environment.
It looks like font-related initialization problem.
Any hints?

In English environment, you can try the following test.

$ build/Emacs.app/Contents/MacOS/Emacs
  ==> OK

$ __CF_USER_TEXT_ENCODING=0x1F6:1:14 build/Emacs.app/Contents/MacOS/ 
Emacs
$ __CF_USER_TEXT_ENCODING=0x1F6:1:14 gdb build/Emacs.app/Contents/ 
MacOS/Emacs
  ==> Emacs crashes.  Gdb info is as follows.

> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: KERN_PROTECTION_FAILURE at address: 0x911e903c
> 0x001fd67d in nsfont_escape_name (name=0x911e9034 "Hiragino Kaku  
> Gothic ProN") at nsfont.m:7272	      name[i] = '_';


P.S.
The environment variable __CF_USER_TEXT_ENCODING
is a good indicator of Mac OSX language environment.
*:0:0 is english, *:1:14 is Japanese.

Seiji




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Cocoa port: nsfont_escape_name error
  2008-07-18  4:54 Cocoa port: nsfont_escape_name error Seiji Zenitani
@ 2008-07-19  0:05 ` Seiji Zenitani
  2008-07-19 17:15   ` Adrian Robert
  0 siblings, 1 reply; 3+ messages in thread
From: Seiji Zenitani @ 2008-07-19  0:05 UTC (permalink / raw)
  To: emacs-devel emacs-devel

[-- Attachment #1: Type: text/plain, Size: 987 bytes --]

Hi,

On 2008/07/18, at 0:54, Seiji Zenitani wrote:
>
> Cocoa Emacs works fine in Mac OSX English environment.
> However, it (the same executable binary) immediately
> crashes in Japanese language environment.
> It looks like font-related initialization problem.
> Any hints?
>
> In English environment, you can try the following test.
>
> $ build/Emacs.app/Contents/MacOS/Emacs
> ==> OK
>
> $ __CF_USER_TEXT_ENCODING=0x1F6:1:14 build/Emacs.app/Contents/MacOS/ 
> Emacs
> $ __CF_USER_TEXT_ENCODING=0x1F6:1:14 gdb build/Emacs.app/Contents/ 
> MacOS/Emacs
> ==> Emacs crashes.  Gdb info is as follows.
>
>> Program received signal EXC_BAD_ACCESS, Could not access memory.
>> Reason: KERN_PROTECTION_FAILURE at address: 0x911e903c
>> 0x001fd67d in nsfont_escape_name (name=0x911e9034 "Hiragino Kaku  
>> Gothic ProN") at nsfont.m:7272	      name[i] = '_';


The attached fix works for me.
Since UTF8String returns const char *,
we have to duplicate the string in order to modify it.

Seiji


[-- Attachment #2: nsfont.diff --]
[-- Type: application/octet-stream, Size: 1146 bytes --]

--- nsfont.m.~1.5.~	2008-07-16 23:33:58.000000000 -0400
+++ nsfont.m	2008-07-18 18:31:21.000000000 -0400
@@ -150,7 +150,7 @@
   unsigned int traits = [[famMember objectAtIndex: 3] unsignedIntValue];
 /*   NSString *psName = [famMember objectAtIndex: 0]; */
   NSMutableString *suffix = [[famMember objectAtIndex: 1] mutableCopy];
-  char *escapedFamily = [family UTF8String];
+  char *escapedFamily = strdup ([family UTF8String]);
 
   nsfont_escape_name (escapedFamily);
   [suffix replaceOccurrencesOfString: @" " withString: @"" options: 0
@@ -181,6 +182,7 @@
      }
 
   [suffix release];
+  free (escapedFamily);
   return font_entity;
 }
 
@@ -1226,7 +1228,7 @@
 
         if (cfont != nil)
           {
-            char *family = [[cfont familyName] UTF8String];
+            char *family = strdup([[cfont familyName] UTF8String]);
             Lisp_Object famAndReg;
 
             nsfont_escape_name (family);
@@ -1238,6 +1241,7 @@
                        SDATA (SYMBOL_NAME (scripts[i])));
 
             Fset_fontset_font (name, scripts[i], famAndReg, Qnil, Qnil);
+            free (family);
           }
         else
           {

[-- Attachment #3: Type: text/plain, Size: 1 bytes --]



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Cocoa port: nsfont_escape_name error
  2008-07-19  0:05 ` Seiji Zenitani
@ 2008-07-19 17:15   ` Adrian Robert
  0 siblings, 0 replies; 3+ messages in thread
From: Adrian Robert @ 2008-07-19 17:15 UTC (permalink / raw)
  To: emacs-devel

Seiji Zenitani <zenitani <at> mac.com> writes:

> The attached fix works for me. Since UTF8String returns const char *,
> we have to duplicate the string in order to modify it.

Thanks, this patch looks reasonable and fixes the crash for me
(your test case); I've applied it.









^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-19 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-18  4:54 Cocoa port: nsfont_escape_name error Seiji Zenitani
2008-07-19  0:05 ` Seiji Zenitani
2008-07-19 17:15   ` Adrian Robert

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.