Commit 5c444c4e authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

cmd: Fix shortpath handling in for loops.

When 's' is used as a modifier, the paths that are presented to the other modifiers needs to be a short path. Given the 'filename' part of the path may not exist, we cannot use GetShortPathName directly without first removing the filename part to just leave the directory bit. Signed-off-by: 's avatarJason Edmeades <us@edmeades.me.uk> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent ba1eb91a
...@@ -399,6 +399,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute) ...@@ -399,6 +399,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
WCHAR finaloutput[MAX_PATH]; WCHAR finaloutput[MAX_PATH];
WCHAR fullfilename[MAX_PATH]; WCHAR fullfilename[MAX_PATH];
WCHAR thisoutput[MAX_PATH]; WCHAR thisoutput[MAX_PATH];
WCHAR *filepart = NULL;
WCHAR *pos = *start+1; WCHAR *pos = *start+1;
WCHAR *firstModifier = pos; WCHAR *firstModifier = pos;
WCHAR *lastModifier = NULL; WCHAR *lastModifier = NULL;
...@@ -522,7 +523,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute) ...@@ -522,7 +523,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
/* After this, we need full information on the file, /* After this, we need full information on the file,
which is valid not to exist. */ which is valid not to exist. */
if (!skipFileParsing) { if (!skipFileParsing) {
if (GetFullPathNameW(outputparam, MAX_PATH, fullfilename, NULL) == 0) { if (GetFullPathNameW(outputparam, MAX_PATH, fullfilename, &filepart) == 0) {
exists = FALSE; exists = FALSE;
fullfilename[0] = 0x00; fullfilename[0] = 0x00;
} else { } else {
...@@ -598,8 +599,16 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute) ...@@ -598,8 +599,16 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
/* 4. Handle 's' : Use short paths (File doesn't have to exist) */ /* 4. Handle 's' : Use short paths (File doesn't have to exist) */
if (memchrW(firstModifier, 's', modifierLen) != NULL) { if (memchrW(firstModifier, 's', modifierLen) != NULL) {
if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW); if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW);
/* Don't flag as doneModifier - %~s on its own is processed later */
GetShortPathNameW(outputparam, outputparam, ARRAY_SIZE(outputparam)); /* Convert fullfilename's path to a short path - Save filename away as
only path is valid, name may not exist which causes GetShortPathName
to fail if it is provided */
if (filepart) {
strcpyW(thisoutput, filepart);
*filepart = 0x00;
GetShortPathNameW(fullfilename, fullfilename, ARRAY_SIZE(fullfilename));
strcatW(fullfilename, thisoutput);
}
} }
/* 5. Handle 'f' : Fully qualified path (File doesn't have to exist) */ /* 5. Handle 'f' : Fully qualified path (File doesn't have to exist) */
...@@ -673,7 +682,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute) ...@@ -673,7 +682,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
memchrW(firstModifier, 's', modifierLen) != NULL) { memchrW(firstModifier, 's', modifierLen) != NULL) {
doneModifier = TRUE; doneModifier = TRUE;
if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW); if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW);
strcatW(finaloutput, outputparam); strcatW(finaloutput, fullfilename);
} }
} }
} }
......
...@@ -530,9 +530,9 @@ N ...@@ -530,9 +530,9 @@ N
'.OOL' '.OOL'
'.TABC' '.TABC'
'' ''
@todo_wine@'@drive@@shortpath@R S'@or_broken@'' '@drive@@shortpath@R S'@or_broken@''
@todo_wine@'@drive@@shortpath@T'@or_broken@'' '@drive@@shortpath@T'@or_broken@''
@todo_wine@'@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@'' '@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@''
''@or_broken@'%~ai' ''@or_broken@'%~ai'
''@or_broken@'%~ai' ''@or_broken@'%~ai'
'--a------'@or_broken@'--a--------'@or_broken@'--a--c---'@or_broken@'%~ai' '--a------'@or_broken@'--a--------'@or_broken@'--a--c---'@or_broken@'%~ai'
...@@ -566,9 +566,9 @@ N ...@@ -566,9 +566,9 @@ N
'.OOL' '.OOL'
'.TABC' '.TABC'
'' ''
@todo_wine@'@drive@@shortpath@R S'@or_broken@'' '@drive@@shortpath@R S'@or_broken@''
@todo_wine@'@drive@@shortpath@T'@or_broken@'' '@drive@@shortpath@T'@or_broken@''
@todo_wine@'@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@'' '@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@''
@drive@@path@ @drive@@path@
@drive@@path@ @drive@@path@
@drive@ @drive@
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment