aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2014-09-13 11:26:44 +0300
committerEli Zaretskii2014-09-13 11:26:44 +0300
commita6cc335aef90cb4a2dc3fde77cbea9886240301e (patch)
tree2f01a0d438766d70cfbd50880950f6b2a4b0acf0
parente868e853a85fb4466ab045962a269db31760f354 (diff)
downloademacs-a6cc335aef90cb4a2dc3fde77cbea9886240301e.tar.gz
emacs-a6cc335aef90cb4a2dc3fde77cbea9886240301e.zip
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.
-rw-r--r--src/ChangeLog13
-rw-r--r--src/sound.c18
-rw-r--r--src/w32.c2
3 files changed, 25 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0117b83feb1..4f851edb0fd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
12014-09-13 Eli Zaretskii <eliz@gnu.org>
2
3 * sound.c (Fplay_sound_internal): Encode the sound file name in
4 the ANSI codepage. Expand it against data-directory, as per docs,
5 not against the current directory. No need to make a local copy
6 of the file name; pass the encoded file name directly to
7 do_play_sound. (Bug#18463)
8
9 * w32.c (ansi_encode_filename): If w32_get_short_filename returns
10 NULL, and the file name is not encodable in ANSI codepage, return
11 the string with "?" replacement characters, which will fail the
12 caller. This avoids returning a random value in that case.
13
12014-09-11 Martin Rudalics <rudalics@gmx.at> 142014-09-11 Martin Rudalics <rudalics@gmx.at>
2 15
3 * window.c (Fresize_mini_window_internal): Set w->total_lines 16 * window.c (Fresize_mini_window_internal): Set w->total_lines
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/>. */
88#include <limits.h> 88#include <limits.h>
89#include <windows.h> 89#include <windows.h>
90#include <mmsystem.h> 90#include <mmsystem.h>
91
92#include "coding.h"
93#include "w32.h"
91/* END: Windows Specific Includes */ 94/* END: Windows Specific Includes */
92 95
93#endif /* WINDOWSNT */ 96#endif /* WINDOWSNT */
@@ -1309,9 +1312,7 @@ Internal use only, use `play-sound' instead. */)
1309 struct gcpro gcpro1, gcpro2; 1312 struct gcpro gcpro1, gcpro2;
1310 Lisp_Object args[2]; 1313 Lisp_Object args[2];
1311#else /* WINDOWSNT */ 1314#else /* WINDOWSNT */
1312 int len = 0; 1315 Lisp_Object lo_file;
1313 Lisp_Object lo_file = {0};
1314 char * psz_file = NULL;
1315 unsigned long ui_volume_tmp = UINT_MAX; 1316 unsigned long ui_volume_tmp = UINT_MAX;
1316 unsigned long ui_volume = UINT_MAX; 1317 unsigned long ui_volume = UINT_MAX;
1317#endif /* WINDOWSNT */ 1318#endif /* WINDOWSNT */
@@ -1383,10 +1384,11 @@ Internal use only, use `play-sound' instead. */)
1383 1384
1384#else /* WINDOWSNT */ 1385#else /* WINDOWSNT */
1385 1386
1386 lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil); 1387 lo_file = Fexpand_file_name (attrs[SOUND_FILE], Vdata_directory);
1387 len = XSTRING (lo_file)->size; 1388 lo_file = ENCODE_FILE (lo_file);
1388 psz_file = alloca (len + 1); 1389 /* Since UNICOWS.DLL includes only a stub for mciSendStringW, we
1389 strcpy (psz_file, XSTRING (lo_file)->data); 1390 need to encode the file in the ANSI codepage. */
1391 lo_file = ansi_encode_filename (lo_file);
1390 if (INTEGERP (attrs[SOUND_VOLUME])) 1392 if (INTEGERP (attrs[SOUND_VOLUME]))
1391 { 1393 {
1392 ui_volume_tmp = XFASTINT (attrs[SOUND_VOLUME]); 1394 ui_volume_tmp = XFASTINT (attrs[SOUND_VOLUME]);
@@ -1408,7 +1410,7 @@ Internal use only, use `play-sound' instead. */)
1408 { 1410 {
1409 ui_volume = ui_volume_tmp * (UINT_MAX / 100); 1411 ui_volume = ui_volume_tmp * (UINT_MAX / 100);
1410 } 1412 }
1411 do_play_sound (psz_file, ui_volume); 1413 do_play_sound (SDATA (lo_file), ui_volume);
1412 1414
1413#endif /* WINDOWSNT */ 1415#endif /* WINDOWSNT */
1414 1416
diff --git a/src/w32.c b/src/w32.c
index 15e53600d95..fee1be22739 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -2387,6 +2387,8 @@ ansi_encode_filename (Lisp_Object filename)
2387 dostounix_filename (shortname); 2387 dostounix_filename (shortname);
2388 encoded_filename = build_string (shortname); 2388 encoded_filename = build_string (shortname);
2389 } 2389 }
2390 else
2391 encoded_filename = build_unibyte_string (fname);
2390 } 2392 }
2391 else 2393 else
2392 encoded_filename = build_unibyte_string (fname); 2394 encoded_filename = build_unibyte_string (fname);