1
0
forked from aniani/vim

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>
This commit is contained in:
GuyBrush 2023-11-04 09:48:53 +01:00 committed by Christian Brabandt
parent 5a53925a6e
commit 15d270019e
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
3 changed files with 12 additions and 12 deletions

View File

@ -1272,7 +1272,7 @@ $(XPM_OBJ) $(OUTDIR)\version.obj $(LINKARGS2)
$(VIM): $(VIM).exe $(VIM): $(VIM).exe
$(OUTDIR): $(OUTDIR):
if not exist $(OUTDIR)/nul mkdir $(OUTDIR) if not exist $(OUTDIR)/nul mkdir $(OUTDIR:/=\)
CFLAGS_INST = /nologo /O2 -DNDEBUG -DWIN32 -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) $(CFLAGS_DEPR) CFLAGS_INST = /nologo /O2 -DNDEBUG -DWIN32 -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) $(CFLAGS_DEPR)

View File

@ -322,7 +322,7 @@ sound_wndproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
vim_snprintf(buf, sizeof(buf), "close sound%06ld", vim_snprintf(buf, sizeof(buf), "close sound%06ld",
p->snd_id); p->snd_id);
mciSendString(buf, NULL, 0, 0); mciSendStringA(buf, NULL, 0, 0);
long result = wParam == MCI_NOTIFY_SUCCESSFUL ? 0 long result = wParam == MCI_NOTIFY_SUCCESSFUL ? 0
: wParam == MCI_NOTIFY_ABORTED ? 1 : 2; : wParam == MCI_NOTIFY_ABORTED ? 1 : 2;
@ -376,7 +376,7 @@ f_sound_playfile(typval_T *argvars, typval_T *rettv)
{ {
long newid = sound_id + 1; long newid = sound_id + 1;
size_t len; size_t len;
char_u *p, *esc; char_u *p, *filename;
WCHAR *wp; WCHAR *wp;
soundcb_T *soundcb; soundcb_T *soundcb;
char buf[32]; char buf[32];
@ -385,17 +385,15 @@ f_sound_playfile(typval_T *argvars, typval_T *rettv)
if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
return; return;
esc = vim_strsave_shellescape(tv_get_string(&argvars[0]), FALSE, FALSE); filename = tv_get_string(&argvars[0]);
len = STRLEN(esc) + 5 + 18 + 1; len = STRLEN(filename) + 5 + 18 + 2 + 1;
p = alloc(len); p = alloc(len);
if (p == NULL) if (p == NULL)
{ {
free(esc);
return; return;
} }
vim_snprintf((char *)p, len, "open %s alias sound%06ld", esc, newid); vim_snprintf((char *)p, len, "open \"%s\" alias sound%06ld", filename, newid);
free(esc);
wp = enc_to_utf16((char_u *)p, NULL); wp = enc_to_utf16((char_u *)p, NULL);
free(p); free(p);
@ -408,7 +406,7 @@ f_sound_playfile(typval_T *argvars, typval_T *rettv)
return; return;
vim_snprintf(buf, sizeof(buf), "play sound%06ld notify", newid); vim_snprintf(buf, sizeof(buf), "play sound%06ld notify", newid);
err = mciSendString(buf, NULL, 0, sound_window()); err = mciSendStringA(buf, NULL, 0, sound_window());
if (err != 0) if (err != 0)
goto failure; goto failure;
@ -426,7 +424,7 @@ f_sound_playfile(typval_T *argvars, typval_T *rettv)
failure: failure:
vim_snprintf(buf, sizeof(buf), "close sound%06ld", newid); vim_snprintf(buf, sizeof(buf), "close sound%06ld", newid);
mciSendString(buf, NULL, 0, NULL); mciSendStringA(buf, NULL, 0, NULL);
} }
void void
@ -440,14 +438,14 @@ f_sound_stop(typval_T *argvars, typval_T *rettv UNUSED)
id = tv_get_number(&argvars[0]); id = tv_get_number(&argvars[0]);
vim_snprintf(buf, sizeof(buf), "stop sound%06ld", id); vim_snprintf(buf, sizeof(buf), "stop sound%06ld", id);
mciSendString(buf, NULL, 0, NULL); mciSendStringA(buf, NULL, 0, NULL);
} }
void void
f_sound_clear(typval_T *argvars UNUSED, typval_T *rettv UNUSED) f_sound_clear(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{ {
PlaySoundW(NULL, NULL, 0); PlaySoundW(NULL, NULL, 0);
mciSendString("close all", NULL, 0, NULL); mciSendStringA("close all", NULL, 0, NULL);
} }
# if defined(EXITFREE) # if defined(EXITFREE)

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2089,
/**/ /**/
2088, 2088,
/**/ /**/