Author: jmorlan
Date: Sun Mar 1 23:25:13 2009
New Revision: 39836
URL:
http://svn.reactos.org/svn/reactos?rev=39836&view=rev
Log:
Fix BatchParams to handle unconventional spacing/quoting properly.
Modified:
trunk/reactos/base/shell/cmd/batch.c
Modified: trunk/reactos/base/shell/cmd/batch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/batch.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/batch.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/batch.c [iso-8859-1] Sun Mar 1 23:25:13 2009
@@ -130,28 +130,25 @@
while (*s2)
{
- if (_istspace (*s2) || _tcschr (_T(",;"), *s2))
- {
- *s1++ = _T('\0');
+ BOOL inquotes = FALSE;
+
+ /* Find next parameter */
+ while (_istspace(*s2) || (*s2 && _tcschr(_T(",;="), *s2)))
s2++;
- while (*s2 && _tcschr (_T(" ,;"), *s2))
- s2++;
- continue;
- }
-
- if ((*s2 == _T('"')) || (*s2 == _T('\'')))
- {
- TCHAR st = *s2;
-
- do
- *s1++ = *s2++;
- while (*s2 && (*s2 != st));
- }
-
- *s1++ = *s2++;
- }
-
- *s1++ = _T('\0');
+ if (!*s2)
+ break;
+
+ /* Copy it */
+ do
+ {
+ if (!inquotes && (_istspace(*s2) || _tcschr(_T(",;="), *s2)))
+ break;
+ inquotes ^= (*s2 == _T('"'));
+ *s1++ = *s2++;
+ } while (*s2);
+ *s1++ = _T('\0');
+ }
+
*s1 = _T('\0');
return dp;