bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#13907: 24.3.50; cygw32 build mishandles drag-n-dropped file with non


From: Daniel Colascione
Subject: bug#13907: 24.3.50; cygw32 build mishandles drag-n-dropped file with non-ASCII characters in name
Date: Fri, 08 Mar 2013 19:03:58 -0800
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3

On 3/8/2013 7:03 PM, Daniel Colascione wrote:
> On 3/8/2013 1:25 PM, Daniel Colascione wrote:
>> On 3/8/2013 12:53 PM, Eli Zaretskii wrote:
>>>> Date: Fri, 08 Mar 2013 22:33:07 +0200
>>>> From: Eli Zaretskii <eliz@gnu.org>
>>>> Cc: 13907@debbugs.gnu.org
>>>>
>>>> And one more question: what is the value of file-name _before_ it is
>>>> passed to cygwin-convert-file-name-from-windows?  Does it perhaps
>>>> already have the U-umlaut replaced by a blank?
>>>
>>> I think the problem is on the C level, not on the Lisp level.  Take a
>>> look at w32term.c:construct_drag_n_drop -- it uses ANSI version of
>>> DragQueryFile to get the file name, then decodes it by DECODE_FILE.
>>> But DECODE_FILE uses UTF-8 in the cygw32 build, so this is
>>> inappropriate for decoding file names that come from Windows APIs.
>>>
>>> Instead, in the cygw32 build, construct_drag_n_drop should use
>>> DragQueryFileW and convert the file name to the internal Emacs
>>> representation using from_unicode.
>>>
>>
>>
>> Thanks for finding that! I've been swamped this week, and I haven't been 
>> able to
>> do any investigation. I'll see whether I can come up with a fix this weekend.
>>
> 
> The patch below resolves the issue for me. Assuming it's acceptable, where
> should I install it?
> 
> ~/edev/trunk
> $ bzr diff
> === modified file 'src/w32term.c'
> --- src/w32term.c       2013-02-16 13:59:37 +0000
> +++ src/w32term.c       2013-03-09 03:02:10 +0000
> @@ -3186,12 +3186,27 @@
> 
>    for (i = 0; i < num_files; i++)
>      {
> +#ifdef NTGUI_UNICODE
> +      len = DragQueryFileW (hdrop, i, NULL, 0);
> +      if (len <= 0)
> +       continue;
> +
> +      name = alloca ((len + 1) * sizeof (wchar_t));
> +      DragQueryFileW (hdrop, i, (wchar_t *) name, len + 1);
> +      files = Fcons (
> +        from_unicode (make_unibyte_string(
> +                        name,
> +                        1 + sizeof (wchar_t) * len)),
> +        files);
> +#else
>        len = DragQueryFile (hdrop, i, NULL, 0);
>        if (len <= 0)
>         continue;
> +
>        name = alloca (len + 1);
>        DragQueryFile (hdrop, i, name, len + 1);
>        files = Fcons (DECODE_FILE (build_string (name)), files);
> +#endif /* NTGUI_UNICODE */
>      }
> 
>    DragFinish (hdrop);

By the way: shouldn't we have an unwind handler here so that we call DragFinish
even if our memory allocation fails?

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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