diff options
author | Eli Zaretskii <eliz@gnu.org> | 2014-09-13 11:26:44 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2014-09-13 11:26:44 +0300 |
commit | a6cc335aef90cb4a2dc3fde77cbea9886240301e (patch) | |
tree | 2f01a0d438766d70cfbd50880950f6b2a4b0acf0 /src/sound.c | |
parent | e868e853a85fb4466ab045962a269db31760f354 (diff) | |
download | emacs-a6cc335aef90cb4a2dc3fde77cbea9886240301e.tar.gz |
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.
Diffstat (limited to 'src/sound.c')
-rw-r--r-- | src/sound.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/sound.c b/src/sound.c index a95678812e1..552f75b68e8 100644 --- a/src/sound.c +++ b/src/sound.c @@ -88,6 +88,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #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 @@ Internal use only, use `play-sound' instead. */) 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 @@ Internal use only, use `play-sound' instead. */) #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 @@ Internal use only, use `play-sound' instead. */) { 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 */ |