unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
Cc: emacs-devel@gnu.org
Subject: Re: image file with Chinese file names
Date: Wed, 29 Mar 2006 10:21:56 +0900	[thread overview]
Message-ID: <E1FOPNk-0002pb-00@etlken> (raw)
In-Reply-To: <E1FKja3-0001Jl-Ow@lists.gnu.org> (message from MJ Chan on Sat, 18 Mar 2006 17:07:28 -0500)

In article <E1FKja3-0001Jl-Ow@lists.gnu.org>, MJ Chan <mjchan@myrealbox.com> writes:

> [ this was originally posted to help-emacs-windows@gnu.org. ]
> 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
handa@m17n.org

       reply	other threads:[~2006-03-29  1:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1FKja3-0001Jl-Ow@lists.gnu.org>
2006-03-29  1:21 ` Kenichi Handa [this message]
2006-03-31  3:10   ` image file with Chinese file names Richard Stallman
2006-04-03  1:26     ` Kenichi Handa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1FOPNk-0002pb-00@etlken \
    --to=handa@m17n.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).