]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
util: Delete unused argconfig subopts type
authorTokunori Ikegami <ikegami.t@gmail.com>
Sun, 30 Apr 2023 13:35:46 +0000 (22:35 +0900)
committerDaniel Wagner <wagi@monom.org>
Tue, 2 May 2023 09:35:10 +0000 (11:35 +0200)
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
util/argconfig.c
util/argconfig.h

index 6b547b9b21934d93f084445093162f294af445af..630c3ea5192a9e57ae8351c6832729c929f7f80b 100644 (file)
@@ -48,8 +48,6 @@
 #define fallthrough do {} while (0)
 #endif
 
-static char END_DEFAULT[] = "__end_default__";
-
 static const char *append_usage_str = "";
 
 void argconfig_append_usage(const char *str)
@@ -167,8 +165,6 @@ static int argconfig_parse_type(struct argconfig_commandline_options *s, struct
        void *value = (void *)(char *)s->default_value;
        char *endptr;
        int ret = 0;
-       char **opts = ((char **)value);
-       int remaining_space = CFG_MAX_SUBOPTS - 2;
 
        switch (s->config_type) {
        case CFG_STRING:
@@ -229,18 +225,6 @@ static int argconfig_parse_type(struct argconfig_commandline_options *s, struct
                if (errno || optarg == endptr)
                        ret = argconfig_error("float", option[index].name, optarg);
                break;
-       case CFG_SUBOPTS:
-               *opts = END_DEFAULT;
-               opts += 2;
-               ret = argconfig_parse_subopt_string(optarg, opts, remaining_space);
-               if (ret) {
-                       if (ret == 2)
-                               fprintf(stderr, "Error Parsing Sub-Options: Too many options!\n");
-                       else
-                               fprintf(stderr, "Error Parsing Sub-Options\n");
-                       ret = -EINVAL;
-               }
-               break;
        case CFG_FLAG:
                *((bool *)value) = true;
                break;
@@ -360,82 +344,6 @@ out:
        return ret;
 }
 
-int argconfig_parse_subopt_string(char *string, char **options,
-                                 size_t max_options)
-{
-       char **o = options;
-       char *tmp;
-       size_t toklen;
-
-       if (!string || !strlen(string)) {
-               *(o++) = NULL;
-               *(o++) = NULL;
-               return 0;
-       }
-
-       tmp = calloc(strlen(string) + 2, 1);
-       if (!tmp)
-               return 1;
-       strcpy(tmp, string);
-
-       toklen = strcspn(tmp, "=");
-
-       if (!toklen) {
-               free(tmp);
-               return 1;
-       }
-
-       *(o++) = tmp;
-       tmp[toklen] = 0;
-       tmp += toklen + 1;
-
-       while (1) {
-               if (*tmp == '"' || *tmp == '\'' || *tmp == '[' || *tmp == '(' ||
-                   *tmp == '{') {
-
-                       tmp++;
-                       toklen = strcspn(tmp, "\"'])}");
-
-                       if (!toklen)
-                               return 1;
-
-                       *(o++) = tmp;
-                       tmp[toklen] = 0;
-                       tmp += toklen + 1;
-
-                       toklen = strcspn(tmp, ";:,");
-                       tmp[toklen] = 0;
-                       tmp += toklen + 1;
-               } else {
-                       toklen = strcspn(tmp, ";:,");
-
-                       if (!toklen)
-                               return 1;
-
-                       *(o++) = tmp;
-                       tmp[toklen] = 0;
-                       tmp += toklen + 1;
-               }
-
-               toklen = strcspn(tmp, "=");
-
-               if (!toklen)
-                       break;
-
-               *(o++) = tmp;
-               tmp[toklen] = 0;
-               tmp += toklen + 1;
-
-               if ((o - options) > (max_options - 2))
-                       return 2;
-       }
-
-       *(o++) = NULL;
-       *(o++) = NULL;
-
-       return 0;
-}
-
 int argconfig_parse_comma_sep_array(char *string, int *val,
                                         unsigned max_length)
 {
index f0e39f4ef4991d3532f7f77a8d9ce032749db1b9..1a2828ff47e31667774c42079d2681510103ebbe 100644 (file)
@@ -53,7 +53,6 @@ enum argconfig_types {
        CFG_SHORT,
        CFG_POSITIVE,
        CFG_INCREMENT,
-       CFG_SUBOPTS,
 };
 
 #define OPT_ARGS(n) \
@@ -107,15 +106,11 @@ struct argconfig_commandline_options {
        bool seen;
 };
 
-#define CFG_MAX_SUBOPTS 500
-
 void argconfig_append_usage(const char *str);
 void argconfig_print_help(const char *program_desc,
                          struct argconfig_commandline_options *options);
 int argconfig_parse(int argc, char *argv[], const char *program_desc,
                    struct argconfig_commandline_options *options);
-int argconfig_parse_subopt_string(char *string, char **options,
-                                 size_t max_options);
 int argconfig_parse_comma_sep_array(char *string, int *ret,
                                         unsigned max_length);
 int argconfig_parse_comma_sep_array_short(char *string, unsigned short *ret,