Skip to content

Commit

Permalink
Handles quoted arguments a little bit better (needs some overhauling …
Browse files Browse the repository at this point in the history
…to do it right, though).
  • Loading branch information
icculus committed Apr 4, 2002
1 parent d317ba2 commit 6e2393d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/test_physfs.c
Expand Up @@ -102,10 +102,18 @@ static int cmd_deinit(char *args)

static int cmd_addarchive(char *args)
{
char *ptr = strchr(args, ' ');
char *ptr = strrchr(args, ' ');
int appending = atoi(ptr + 1);
*ptr = '\0';

if (*args == '\"')
{
args++;
*(ptr - 1) = '\0';
}

/*printf("[%s], [%d]\n", args, appending);*/

if (PHYSFS_addToSearchPath(args, appending))
printf("Successful.\n");
else
Expand Down Expand Up @@ -369,12 +377,15 @@ static int cmd_cat(char *args)
static int count_args(const char *str)
{
int retval = 0;
int in_quotes = 0;

if (str != NULL)
{
for (; *str != '\0'; str++)
{
if (*str == ' ')
if (*str == '\"')
in_quotes = !in_quotes;
else if ((*str == ' ') && (!in_quotes))
retval++;
} /* for */
retval++;
Expand Down

0 comments on commit 6e2393d

Please sign in to comment.