reactos/lib/shell32
diff -u -r1.40 -r1.41
--- shlexec.c 13 Sep 2004 18:04:09 -0000 1.40
+++ shlexec.c 20 Sep 2004 15:07:21 -0000 1.41
@@ -77,7 +77,7 @@
* %* all following parameters (see batfile)
*
* FIXME: use 'len'
- * FIXME: Careful of going over string-boundries. No checking is done to 'res'...
+ * FIXME: Careful of going over string boundaries. No checking is done to 'res'...
*/
static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lpFile, LPITEMIDLIST pidl, LPCWSTR args)
{
@@ -86,13 +86,6 @@
PWSTR res = out;
PCWSTR cmd;
LPVOID pv;
- WCHAR tmpBuffer[1024];
- PWSTR tmpB = tmpBuffer;
- WCHAR tmpEnvBuff[MAX_PATH];
- WCHAR* tmpE = tmpEnvBuff;
- DWORD envRet;
- static const WCHAR wszSPerc[] = {'%','s',0};
- static const WCHAR wszPerc[] = {'%',0};
TRACE("%p, %d, %s, %s, %p, %p\n", out, len, debugstr_w(fmt),
debugstr_w(lpFile), pidl, args);
@@ -186,38 +179,36 @@
}
break;
- default:
- /*
- * Check if this is a env-variable here...
- */
+ default:
+ /*
+ * Check if this is a env-variable here...
+ */
- /* Make sure that we have at least one more %.*/
- if (strstrW(fmt, wszPerc))
- {
- while (*fmt != '%')
- *tmpB++ = *fmt++;
- *tmpB++ = 0;
-
- TRACE("Checking %s to be a env-var\n", debugstr_w(tmpBuffer));
-
- envRet = GetEnvironmentVariableW(tmpBuffer, tmpE, MAX_PATH);
- if (envRet == 0 || envRet > MAX_PATH)
- {
- TRACE("The env. var can't be found or is bigger than MAX_PATH => useless.");
- res += sprintfW(res, wszSPerc, tmpBuffer);
+ /* Make sure that we have at least one more %.*/
+ if (strchrW(fmt, '%'))
+ {
+ WCHAR tmpBuffer[1024];
+ PWSTR tmpB = tmpBuffer;
+ WCHAR tmpEnvBuff[MAX_PATH];
+ DWORD envRet;
+
+ while (*fmt != '%')
+ *tmpB++ = *fmt++;
+ *tmpB++ = 0;
+
+ TRACE("Checking %s to be a env-var\n", debugstr_w(tmpBuffer));
+
+ envRet = GetEnvironmentVariableW(tmpBuffer, tmpEnvBuff, MAX_PATH);
+ if (envRet == 0 || envRet > MAX_PATH)
+ strcpyW( res, tmpBuffer );
+ else
+ strcpyW( res, tmpEnvBuff );
+ res += strlenW(res);
+ }
+ fmt++;
+ done = TRUE;
+ break;
}
- else
- {
- TRACE("Found it %s. Replacing... \n", debugstr_w(tmpEnvBuff));
- res += sprintfW(res, wszSPerc, tmpEnvBuff);
- }
- }
-
- } /* switch */
-
-
- fmt++;
- done = TRUE;
}
else
*res++ = *fmt++;