From 6e2393d90a17b5904bbabaddb07239146fe4bdc6 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 4 Apr 2002 17:55:13 +0000 Subject: [PATCH] Handles quoted arguments a little bit better (needs some overhauling to do it right, though). --- test/test_physfs.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/test_physfs.c b/test/test_physfs.c index b289a70..d8afe3c 100644 --- a/test/test_physfs.c +++ b/test/test_physfs.c @@ -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 @@ -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++;