summaryrefslogtreecommitdiff
path: root/read_cfg.c
diff options
context:
space:
mode:
authorlouie <lshprung@yahoo.com>2020-07-26 19:16:45 -0700
committerlouie <lshprung@yahoo.com>2020-07-26 19:16:45 -0700
commit5efd6914fbc8101127bed8feda8b02ccb554b79a (patch)
treeac9f3fbebe91fba454f356c928cb85d0ab65facd /read_cfg.c
parent5f5f44712f815279ee80ba5455ad3d5cfb756f66 (diff)
Changed Windows launching implementation to ShellExecute
Diffstat (limited to 'read_cfg.c')
-rw-r--r--read_cfg.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/read_cfg.c b/read_cfg.c
index 74c0e4f..9029d0b 100644
--- a/read_cfg.c
+++ b/read_cfg.c
@@ -108,6 +108,8 @@ void check_line(char *buffer, char **options){
char *tok = strtok(buffer, delims);
char args[MAX_ARGS][BUF_LEN];
GROUP **g;
+ char *tok_p;
+ char *arg_p;
int g_count;
int search_res;
int i;
@@ -129,11 +131,33 @@ void check_line(char *buffer, char **options){
strcpy(args[i], tok);
//handle if an argument has spaces and is wrapped in quotes
if(tok[0] == '"'){
- while(tok[strlen(tok)-1] != '"'){
- tok = strtok(NULL, delims);
- strcat(args[i], " ");
- strcat(args[i], tok);
+ arg_p = &args[i][0];
+ tok_p = &tok[1];
+
+ while(*tok_p != '"'){
+ switch(*tok_p){
+
+
+ case '\0':
+ tok = strtok(NULL, delims);
+ tok_p = &tok[0];
+ *arg_p = ' ';
+ arg_p++;
+ break;
+
+ case '\\':
+ if(*(tok_p+1) == '"') tok_p++;
+
+ default:
+ *arg_p = *tok_p;
+ tok_p++;
+ arg_p++;
+
+ }
}
+
+ *arg_p = '\0';
+
}
tok = strtok(NULL, delims);