emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: image file with Chinese file names


From: Kenichi Handa
Subject: Re: image file with Chinese file names
Date: Wed, 29 Mar 2006 10:21:56 +0900
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/22.0.50 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)

In article <address@hidden>, MJ Chan <address@hidden> writes:

> [ this was originally posted to address@hidden ]
> I'm seeing something that I'm not sure is necessary. When I use
> create-image with file with chinese name like this, image-size always
> return (30 . 30) as its size: (30 is the default size when image
> cannot be loaded according to emacs C source code). 

> (image-size (create-image image-file-name) t)

> if I do this:

> (image-size (create-image (encode-coding-string image-file-name 'big5)) t)

> It returns correct size. 

> I'm wondering if encode-coding-string is necessary here. My
> file-name-coding-system is already set to big5.

> Please note that in both cases, the image file itself can be displayed
> properly. It's just the image-size seems to have problem.

I found that image.c (and image.el) doesn't pay attention to
filename encoding.  For instance, when I visit a file
"À.png", Emacs crashes in png_load() as this:

Program received signal SIGSEGV, Segmentation fault.
0x40346777 in fclose () from /lib/libc.so.6
(gdb) bt 10
#0  0x40346777 in fclose () from /lib/libc.so.6
#1  0x080e6e91 in png_load (f=0x862c2f8, img=0x8598ab0) at image.c:6136
#2  0x080e2fb3 in lookup_image (f=0x862c2f8, spec=139477389) at image.c:1830
#3  0x080659c1 in handle_single_display_spec (it=0xbfffe1c0, spec=1, 
object=140136732, position=0xbfffe260, display_replaced_before_p=0) at 
xdisp.c:4187

This bug is because of this code:

      /* Open the image file.  */
      fp = fopen (SDATA (file), "rb");
      if (!fp)
        {
          image_error ("Cannot open image file `%s'", file, Qnil);
          UNGCPRO;
          fclose (fp);
          return 0;
        }

i.e. calling fclose() with NULL.  But the reason why this
part of code runs is that x_find_image_file() returns
not-yet-encoded file name, thus the above fopen fails.

As an image file name is passed from function to function, I
don't understand where we should put the interface between
decoded filename and encoded filename.

Could someone who knows the structure of image.c please work
on it?  Usually, you can use the macro ENCODE_FILE to encode
a filename.  But, please note that it may call a Lisp
function, thus may cause GC.

---
Kenichi Handa
address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]