Merged fix for bug #503 from SDL 1.2 revision 3487
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402677
This commit is contained in:
parent
42495af337
commit
feb78335ca
1 changed files with 33 additions and 3 deletions
|
@ -25,14 +25,37 @@
|
||||||
#define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
|
#define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
|
||||||
#endif /* _WIN32_WCE < 300 */
|
#endif /* _WIN32_WCE < 300 */
|
||||||
|
|
||||||
|
static void
|
||||||
|
UnEscapeQuotes(char *arg)
|
||||||
|
{
|
||||||
|
char *last = NULL;
|
||||||
|
|
||||||
|
while (*arg) {
|
||||||
|
if (*arg == '"' && *last == '\\') {
|
||||||
|
char *c_curr = arg;
|
||||||
|
char *c_last = last;
|
||||||
|
|
||||||
|
while (*c_curr) {
|
||||||
|
*c_last = *c_curr;
|
||||||
|
c_last = c_curr;
|
||||||
|
c_curr++;
|
||||||
|
}
|
||||||
|
*c_last = '\0';
|
||||||
|
}
|
||||||
|
last = arg;
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse a command line buffer into arguments */
|
/* Parse a command line buffer into arguments */
|
||||||
static int
|
static int
|
||||||
ParseCommandLine(char *cmdline, char **argv)
|
ParseCommandLine(char *cmdline, char **argv)
|
||||||
{
|
{
|
||||||
char *bufp;
|
char *bufp;
|
||||||
int argc;
|
char *lastp = NULL;
|
||||||
|
int argc, last_argc;
|
||||||
|
|
||||||
argc = 0;
|
argc = last_argc = 0;
|
||||||
for (bufp = cmdline; *bufp;) {
|
for (bufp = cmdline; *bufp;) {
|
||||||
/* Skip leading whitespace */
|
/* Skip leading whitespace */
|
||||||
while (isspace(*bufp)) {
|
while (isspace(*bufp)) {
|
||||||
|
@ -48,7 +71,8 @@ ParseCommandLine(char *cmdline, char **argv)
|
||||||
++argc;
|
++argc;
|
||||||
}
|
}
|
||||||
/* Skip over word */
|
/* Skip over word */
|
||||||
while (*bufp && (*bufp != '"')) {
|
while (*bufp && (*bufp != '"' || *lastp == '\\')) {
|
||||||
|
lastp = bufp;
|
||||||
++bufp;
|
++bufp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -69,6 +93,12 @@ ParseCommandLine(char *cmdline, char **argv)
|
||||||
}
|
}
|
||||||
++bufp;
|
++bufp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Strip out \ from \" sequences */
|
||||||
|
if (argv && last_argc != argc) {
|
||||||
|
UnEscapeQuotes(argv[last_argc]);
|
||||||
|
}
|
||||||
|
last_argc = argc;
|
||||||
}
|
}
|
||||||
if (argv) {
|
if (argv) {
|
||||||
argv[argc] = NULL;
|
argv[argc] = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue