From 48c4e3221dc16e4931a811dc04c5e162e3221718 Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Wed, 11 Dec 2024 17:18:33 +0100 Subject: [PATCH] remove quotes trimming, since it is done automatically by shell --- examples/parse_args.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/examples/parse_args.h b/examples/parse_args.h index 626201f55..aab5a247a 100644 --- a/examples/parse_args.h +++ b/examples/parse_args.h @@ -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); @@ -110,11 +110,12 @@ 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); @@ -122,16 +123,7 @@ const char* parse_opt(int argc, char** argv, const char* opt, bool opt_has_value } } } - 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; } /**