Skip to content

Commit 15d2700

Browse files
MiguelBarrochrisbra
authored andcommitted
patch 9.0.2089: sound_playfile() fails when using powershell
Problem: sound_playfile() fails when using powershell Solution: quote filename using doublequotes, don't escape filename, because it doesn't use the shell Avoiding powershell escaping because mci open command doesn't support single quoted filenames: open 'C:\whatever\sound.wav' is not valid. closes: #13471 Signed-off-by: GuyBrush <miguel.barro@live.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 5a53925 commit 15d2700

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/Make_mvc.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ $(XPM_OBJ) $(OUTDIR)\version.obj $(LINKARGS2)
12721272
$(VIM): $(VIM).exe
12731273

12741274
$(OUTDIR):
1275-
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
1275+
if not exist $(OUTDIR)/nul mkdir $(OUTDIR:/=\)
12761276

12771277
CFLAGS_INST = /nologo /O2 -DNDEBUG -DWIN32 -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) $(CFLAGS_DEPR)
12781278

src/sound.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ sound_wndproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
322322

323323
vim_snprintf(buf, sizeof(buf), "close sound%06ld",
324324
p->snd_id);
325-
mciSendString(buf, NULL, 0, 0);
325+
mciSendStringA(buf, NULL, 0, 0);
326326

327327
long result = wParam == MCI_NOTIFY_SUCCESSFUL ? 0
328328
: wParam == MCI_NOTIFY_ABORTED ? 1 : 2;
@@ -376,7 +376,7 @@ f_sound_playfile(typval_T *argvars, typval_T *rettv)
376376
{
377377
long newid = sound_id + 1;
378378
size_t len;
379-
char_u *p, *esc;
379+
char_u *p, *filename;
380380
WCHAR *wp;
381381
soundcb_T *soundcb;
382382
char buf[32];
@@ -385,17 +385,15 @@ f_sound_playfile(typval_T *argvars, typval_T *rettv)
385385
if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
386386
return;
387387

388-
esc = vim_strsave_shellescape(tv_get_string(&argvars[0]), FALSE, FALSE);
388+
filename = tv_get_string(&argvars[0]);
389389

390-
len = STRLEN(esc) + 5 + 18 + 1;
390+
len = STRLEN(filename) + 5 + 18 + 2 + 1;
391391
p = alloc(len);
392392
if (p == NULL)
393393
{
394-
free(esc);
395394
return;
396395
}
397-
vim_snprintf((char *)p, len, "open %s alias sound%06ld", esc, newid);
398-
free(esc);
396+
vim_snprintf((char *)p, len, "open \"%s\" alias sound%06ld", filename, newid);
399397

400398
wp = enc_to_utf16((char_u *)p, NULL);
401399
free(p);
@@ -408,7 +406,7 @@ f_sound_playfile(typval_T *argvars, typval_T *rettv)
408406
return;
409407

410408
vim_snprintf(buf, sizeof(buf), "play sound%06ld notify", newid);
411-
err = mciSendString(buf, NULL, 0, sound_window());
409+
err = mciSendStringA(buf, NULL, 0, sound_window());
412410
if (err != 0)
413411
goto failure;
414412

@@ -426,7 +424,7 @@ f_sound_playfile(typval_T *argvars, typval_T *rettv)
426424

427425
failure:
428426
vim_snprintf(buf, sizeof(buf), "close sound%06ld", newid);
429-
mciSendString(buf, NULL, 0, NULL);
427+
mciSendStringA(buf, NULL, 0, NULL);
430428
}
431429

432430
void
@@ -440,14 +438,14 @@ f_sound_stop(typval_T *argvars, typval_T *rettv UNUSED)
440438

441439
id = tv_get_number(&argvars[0]);
442440
vim_snprintf(buf, sizeof(buf), "stop sound%06ld", id);
443-
mciSendString(buf, NULL, 0, NULL);
441+
mciSendStringA(buf, NULL, 0, NULL);
444442
}
445443

446444
void
447445
f_sound_clear(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
448446
{
449447
PlaySoundW(NULL, NULL, 0);
450-
mciSendString("close all", NULL, 0, NULL);
448+
mciSendStringA("close all", NULL, 0, NULL);
451449
}
452450

453451
# if defined(EXITFREE)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
2089,
707709
/**/
708710
2088,
709711
/**/

0 commit comments

Comments
 (0)