mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-14 18:35:39 +00:00
cmd: set "var=value" ignores trailing characters.
This commit is contained in:
parent
1648340d09
commit
56a33a8c55
|
@ -4038,8 +4038,13 @@ void WCMD_setshow_env (WCHAR *s) {
|
||||||
|
|
||||||
s += 2;
|
s += 2;
|
||||||
while (*s && (*s==' ' || *s=='\t')) s++;
|
while (*s && (*s==' ' || *s=='\t')) s++;
|
||||||
if (*s=='\"')
|
/* set /P "var=value"jim ignores anything after the last quote */
|
||||||
WCMD_strip_quotes(s);
|
if (*s=='\"') {
|
||||||
|
WCHAR *lastquote;
|
||||||
|
lastquote = WCMD_strip_quotes(s);
|
||||||
|
if (lastquote) *lastquote = 0x00;
|
||||||
|
WINE_TRACE("set: Stripped command line '%s'\n", wine_dbgstr_w(s));
|
||||||
|
}
|
||||||
|
|
||||||
/* If no parameter, or no '=' sign, return an error */
|
/* If no parameter, or no '=' sign, return an error */
|
||||||
if (!(*s) || ((p = strchrW (s, '=')) == NULL )) {
|
if (!(*s) || ((p = strchrW (s, '=')) == NULL )) {
|
||||||
|
@ -4104,8 +4109,14 @@ void WCMD_setshow_env (WCHAR *s) {
|
||||||
} else {
|
} else {
|
||||||
DWORD gle;
|
DWORD gle;
|
||||||
|
|
||||||
if (*s=='\"')
|
/* set "var=value"jim ignores anything after the last quote */
|
||||||
WCMD_strip_quotes(s);
|
if (*s=='\"') {
|
||||||
|
WCHAR *lastquote;
|
||||||
|
lastquote = WCMD_strip_quotes(s);
|
||||||
|
if (lastquote) *lastquote = 0x00;
|
||||||
|
WINE_TRACE("set: Stripped command line '%s'\n", wine_dbgstr_w(s));
|
||||||
|
}
|
||||||
|
|
||||||
p = strchrW (s, '=');
|
p = strchrW (s, '=');
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
env = GetEnvironmentStringsW();
|
env = GetEnvironmentStringsW();
|
||||||
|
|
|
@ -286,6 +286,24 @@ set WINE_FOO=foo@space@
|
||||||
echo '%WINE_FOO%'
|
echo '%WINE_FOO%'
|
||||||
set WINE_FOO=foo@tab@
|
set WINE_FOO=foo@tab@
|
||||||
echo '%WINE_FOO%'
|
echo '%WINE_FOO%'
|
||||||
|
rem Space symbol must appear in `var`
|
||||||
|
set WINE_FOO=value@space@
|
||||||
|
echo '%WINE_FOO%'
|
||||||
|
rem Space symbol must NOT appear in `var`
|
||||||
|
set "WINE_FOO=value"@space@
|
||||||
|
echo '%WINE_FOO%'
|
||||||
|
rem Mixed examples:
|
||||||
|
set WINE_FOO=jim fred
|
||||||
|
echo '%WINE_FOO%'
|
||||||
|
set WINE_FOO="jim" fred
|
||||||
|
echo '%WINE_FOO%'
|
||||||
|
set "WINE_FOO=jim fred"
|
||||||
|
echo '%WINE_FOO%'
|
||||||
|
set "WINE_FOO=jim" fred
|
||||||
|
echo '%WINE_FOO%'
|
||||||
|
rem Only the final quote ends the string
|
||||||
|
set "WINE_FOO=apple"banana"grape"orange
|
||||||
|
echo '%WINE_FOO%'
|
||||||
set WINE_FOO=
|
set WINE_FOO=
|
||||||
|
|
||||||
echo ------------ Testing variable expansion ------------
|
echo ------------ Testing variable expansion ------------
|
||||||
|
|
|
@ -251,6 +251,13 @@ foo
|
||||||
''
|
''
|
||||||
'foo@space@'
|
'foo@space@'
|
||||||
'foo@tab@'
|
'foo@tab@'
|
||||||
|
'value@space@'
|
||||||
|
'value'
|
||||||
|
'jim fred'
|
||||||
|
'"jim" fred'
|
||||||
|
'jim fred'
|
||||||
|
'jim'
|
||||||
|
'apple"banana"grape'
|
||||||
------------ Testing variable expansion ------------
|
------------ Testing variable expansion ------------
|
||||||
~dp0 should be directory containing batch file
|
~dp0 should be directory containing batch file
|
||||||
@pwd@\
|
@pwd@\
|
||||||
|
|
|
@ -115,7 +115,7 @@ BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr);
|
||||||
void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute);
|
void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute);
|
||||||
|
|
||||||
void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext);
|
void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext);
|
||||||
void WCMD_strip_quotes(WCHAR *cmd);
|
WCHAR *WCMD_strip_quotes(WCHAR *cmd);
|
||||||
WCHAR *WCMD_LoadMessage(UINT id);
|
WCHAR *WCMD_LoadMessage(UINT id);
|
||||||
void WCMD_strsubstW(WCHAR *start, const WCHAR* next, const WCHAR* insert, int len);
|
void WCMD_strsubstW(WCHAR *start, const WCHAR* next, const WCHAR* insert, int len);
|
||||||
BOOL WCMD_ReadFile(const HANDLE hIn, WCHAR *intoBuf, const DWORD maxChars, LPDWORD charsRead);
|
BOOL WCMD_ReadFile(const HANDLE hIn, WCHAR *intoBuf, const DWORD maxChars, LPDWORD charsRead);
|
||||||
|
|
|
@ -496,20 +496,23 @@ BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr) {
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* WCMD_strip_quotes
|
* WCMD_strip_quotes
|
||||||
*
|
*
|
||||||
* Remove first and last quote WCHARacters, preserving all other text
|
* Remove first and last quote WCHARacters, preserving all other text
|
||||||
|
* Returns the location of the final quote
|
||||||
*/
|
*/
|
||||||
void WCMD_strip_quotes(WCHAR *cmd) {
|
WCHAR *WCMD_strip_quotes(WCHAR *cmd) {
|
||||||
WCHAR *src = cmd + 1, *dest = cmd, *lastq = NULL;
|
WCHAR *src = cmd + 1, *dest = cmd, *lastq = NULL, *lastquote;
|
||||||
while((*dest=*src) != '\0') {
|
while((*dest=*src) != '\0') {
|
||||||
if (*src=='\"')
|
if (*src=='\"')
|
||||||
lastq=dest;
|
lastq=dest;
|
||||||
dest++, src++;
|
dest++, src++;
|
||||||
}
|
}
|
||||||
|
lastquote = lastq;
|
||||||
if (lastq) {
|
if (lastq) {
|
||||||
dest=lastq++;
|
dest=lastq++;
|
||||||
while ((*dest++=*lastq++) != 0)
|
while ((*dest++=*lastq++) != 0)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
return lastquote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue