* Re: image file with Chinese file names [not found] <E1FKja3-0001Jl-Ow@lists.gnu.org> @ 2006-03-29 1:21 ` Kenichi Handa 2006-03-31 3:10 ` Richard Stallman 0 siblings, 1 reply; 3+ messages in thread From: Kenichi Handa @ 2006-03-29 1:21 UTC (permalink / raw) Cc: emacs-devel 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: image file with Chinese file names 2006-03-29 1:21 ` image file with Chinese file names Kenichi Handa @ 2006-03-31 3:10 ` Richard Stallman 2006-04-03 1:26 ` Kenichi Handa 0 siblings, 1 reply; 3+ messages in thread From: Richard Stallman @ 2006-03-31 3:10 UTC (permalink / raw) Cc: mjchan, emacs-devel 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 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. I looked at image.c, and I think the right place for encoding is the end of x_find_image_file. That is, it should return an encoded name. That appears correct for all calls to that function, though I could not perfectly understand all of the callers. Please try that. (Please update the comments on x_find_image_file to say its value has been encoded.) ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: image file with Chinese file names 2006-03-31 3:10 ` Richard Stallman @ 2006-04-03 1:26 ` Kenichi Handa 0 siblings, 0 replies; 3+ messages in thread From: Kenichi Handa @ 2006-04-03 1:26 UTC (permalink / raw) Cc: mjchan, emacs-devel In article <E1FPA2F-0001vR-23@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> writes: > 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 > 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. > I looked at image.c, and I think the right place for encoding is the > end of x_find_image_file. That is, it should return an encoded name. > That appears correct for all calls to that function, though I could > not perfectly understand all of the callers. > Please try that. (Please update the comments on x_find_image_file > to say its value has been encoded.) Ok, I've just committed the attache chagne. --- Kenichi Handa handa@m17n.org 2006-04-03 Kenichi Handa <handa@m17n.org> * image.c: Include "charset.h" and "coding.h". (x_find_image_file): Return an encoded file name. Index: image.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/image.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- image.c 16 Mar 2006 08:05:34 -0000 1.50 +++ image.c 3 Apr 2006 01:23:03 -0000 1.51 @@ -39,6 +39,8 @@ #include "blockinput.h" #include "systime.h" #include <epaths.h> +#include "charset.h" +#include "coding.h" #ifdef HAVE_X_WINDOWS @@ -2246,8 +2248,8 @@ /* Find image file FILE. Look in data-directory, then - x-bitmap-file-path. Value is the full name of the file found, or - nil if not found. */ + x-bitmap-file-path. Value is the encoded full name of the file + found, or nil if not found. */ Lisp_Object x_find_image_file (file) @@ -2267,7 +2269,10 @@ if (fd == -1) file_found = Qnil; else - close (fd); + { + file_found = ENCODE_FILE (file_found); + close (fd); + } UNGCPRO; return file_found; ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-03 1:26 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <E1FKja3-0001Jl-Ow@lists.gnu.org> 2006-03-29 1:21 ` image file with Chinese file names Kenichi Handa 2006-03-31 3:10 ` Richard Stallman 2006-04-03 1:26 ` Kenichi Handa
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).