emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-24 r117497: Fix expansion and encoding of sound file


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-24 r117497: Fix expansion and encoding of sound file names on MS-Windows.
Date: Sat, 13 Sep 2014 08:27:39 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117497
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/18463
committer: Eli Zaretskii <address@hidden>
branch nick: emacs-24
timestamp: Sat 2014-09-13 11:26:44 +0300
message:
  Fix expansion and encoding of sound file names on MS-Windows.
  
   src/sound.c (Fplay_sound_internal): Encode the sound file name in
   the ANSI codepage.  Expand it against data-directory, as per docs,
   not against the current directory.  No need to make a local copy
   of the file name; pass the encoded file name directly to
   do_play_sound.  (Bug#18463)
   src/w32.c (ansi_encode_filename): If w32_get_short_filename returns
   NULL, and the file name is not encodable in ANSI codepage, return
   the string with "?" replacement characters, which will fail the
   caller.  This avoids returning a random value in that case.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/sound.c                    sound.c-20091113204419-o5vbwnq5f7feedwu-1323
  src/w32.c                      w32.c-20091113204419-o5vbwnq5f7feedwu-808
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-09-11 08:47:34 +0000
+++ b/src/ChangeLog     2014-09-13 08:26:44 +0000
@@ -1,3 +1,16 @@
+2014-09-13  Eli Zaretskii  <address@hidden>
+
+       * sound.c (Fplay_sound_internal): Encode the sound file name in
+       the ANSI codepage.  Expand it against data-directory, as per docs,
+       not against the current directory.  No need to make a local copy
+       of the file name; pass the encoded file name directly to
+       do_play_sound.  (Bug#18463)
+
+       * w32.c (ansi_encode_filename): If w32_get_short_filename returns
+       NULL, and the file name is not encodable in ANSI codepage, return
+       the string with "?" replacement characters, which will fail the
+       caller.  This avoids returning a random value in that case.
+
 2014-09-11  Martin Rudalics  <address@hidden>
 
        * window.c (Fresize_mini_window_internal): Set w->total_lines

=== modified file 'src/sound.c'
--- a/src/sound.c       2014-01-01 07:43:34 +0000
+++ b/src/sound.c       2014-09-13 08:26:44 +0000
@@ -88,6 +88,9 @@
 #include <limits.h>
 #include <windows.h>
 #include <mmsystem.h>
+
+#include "coding.h"
+#include "w32.h"
 /* END: Windows Specific Includes */
 
 #endif /* WINDOWSNT */
@@ -1309,9 +1312,7 @@
   struct gcpro gcpro1, gcpro2;
   Lisp_Object args[2];
 #else /* WINDOWSNT */
-  int len = 0;
-  Lisp_Object lo_file = {0};
-  char * psz_file = NULL;
+  Lisp_Object lo_file;
   unsigned long ui_volume_tmp = UINT_MAX;
   unsigned long ui_volume = UINT_MAX;
 #endif /* WINDOWSNT */
@@ -1383,10 +1384,11 @@
 
 #else /* WINDOWSNT */
 
-  lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil);
-  len = XSTRING (lo_file)->size;
-  psz_file = alloca (len + 1);
-  strcpy (psz_file, XSTRING (lo_file)->data);
+  lo_file = Fexpand_file_name (attrs[SOUND_FILE], Vdata_directory);
+  lo_file = ENCODE_FILE (lo_file);
+  /* Since UNICOWS.DLL includes only a stub for mciSendStringW, we
+     need to encode the file in the ANSI codepage.  */
+  lo_file = ansi_encode_filename (lo_file);
   if (INTEGERP (attrs[SOUND_VOLUME]))
     {
       ui_volume_tmp = XFASTINT (attrs[SOUND_VOLUME]);
@@ -1408,7 +1410,7 @@
     {
       ui_volume = ui_volume_tmp * (UINT_MAX / 100);
     }
-  do_play_sound (psz_file, ui_volume);
+  do_play_sound (SDATA (lo_file), ui_volume);
 
 #endif /* WINDOWSNT */
 

=== modified file 'src/w32.c'
--- a/src/w32.c 2014-07-04 07:40:08 +0000
+++ b/src/w32.c 2014-09-13 08:26:44 +0000
@@ -2387,6 +2387,8 @@
          dostounix_filename (shortname);
          encoded_filename = build_string (shortname);
        }
+      else
+       encoded_filename = build_unibyte_string (fname);
     }
   else
     encoded_filename = build_unibyte_string (fname);


reply via email to

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