Skip to content

Commit

Permalink
remove quotes trimming, since it is done automatically by shell
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Dec 11, 2024
1 parent 5fdfd2f commit 48c4e32
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions examples/parse_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const char* parse_opt(int argc, char** argv, const char* opt, bool opt_has_value
} else if (i + 1 < argc && argv[i + 1]) {
value = argv[i + 1];
argv[i + 1] = NULL;
break;
return value;
} else {
printf("Option -%s given without a value\n", opt);
exit(-1);
Expand All @@ -110,28 +110,20 @@ const char* parse_opt(int argc, char** argv, const char* opt, bool opt_has_value
} else if (pos != NULL) {
value = pos + 1;
argv[i] = NULL;
return value;
} else if (i + 1 < argc && argv[i + 1]) {
argv[i] = NULL;
value = argv[i + 1];
argv[i + 1] = NULL;
break;
return value;
} else {
printf("Option --%s given without a value\n", opt);
exit(-1);
}
}
}
}
if (value != NULL) {
int len = strlen(value);
while (len > 1 && ((*value == '"' && value[len - 1] == '"') || (*value == '\'' && value[len - 1] == '\''))) {
value[len - 1] = 0;
value++;
len -= 2;
}
}

return value;
return NULL;
}

/**
Expand Down

0 comments on commit 48c4e32

Please sign in to comment.