diff options
author | pgen <p.gen.progs@gmail.com> | 2019-10-06 13:35:34 +0200 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2019-10-06 13:35:34 +0200 |
commit | 900c171e23afaba31e8e0c916c9befc57f2180da (patch) | |
tree | 9a496c63af7d346cfea7dea361ece2333c7adb31 /ctxopt.c | |
parent | 23c275d89d00642fbff8a0fae812330f50de316c (diff) |
Remove a useless feature in ctxopt.c
The specific management of the word "^" is not really useful and
error-prone.
Diffstat (limited to 'ctxopt.c')
-rw-r--r-- | ctxopt.c | 65 |
1 files changed, 10 insertions, 55 deletions
@@ -2366,8 +2366,7 @@ ctxopt_build_cmdline_list(int nb_words, char ** words) /* Interpret its beginning and look for the start of the real word */ /* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - while (start <= len - 1 - && (str[start] == '^' || str[start] == '{' || str[start] == '}')) + while (start <= len - 1 && (str[start] == '{' || str[start] == '}')) { ll_append(cmdline_list, xstrndup(str + start, 1)); start++; @@ -2375,7 +2374,7 @@ ctxopt_build_cmdline_list(int nb_words, char ** words) } end = len - 1; - if (str[end] == '^' || str[end] == '{' || str[end] == '}') + if (str[end] == '{' || str[end] == '}') { if (end > 0 && str[end - 1] != '\\') { @@ -2383,7 +2382,7 @@ ctxopt_build_cmdline_list(int nb_words, char ** words) end--; node = cmdline_list->tail; - while (str[end] == '^' || str[end] == '{' || str[end] == '}') + while (str[end] == '{' || str[end] == '}') { if (end > start && str[end - 1] == '\\') break; @@ -2459,24 +2458,10 @@ ctxopt_build_cmdline_list(int nb_words, char ** words) if (strcmp(word, "{}") == 0) goto next; - /* Keep only one '^' in sequence */ - /* """"""""""""""""""""""""""""" */ - if (strcmp(word, "^") == 0) - if (prev_word != NULL && strcmp(prev_word, "^") == 0) - { - ll_node_t * old_node = node; - node = node->prev; - ll_delete(cmdline_list, old_node); - free(old_node->data); - free(old_node); - goto next; - } - - /* Remove a SG if the previous element is SG or '^' */ - /* """""""""""""""""""""""""""""""""""""""""""""""""" */ + /* Remove a SG if the previous element is SG */ + /* """"""""""""""""""""""""""""""""""""""""" */ if (strcmp(word, "\x1d") == 0) - if (prev_word != NULL - && (strcmp(prev_word, "\x1d") == 0 || strcmp(prev_word, "^") == 0)) + if (prev_word != NULL && (strcmp(prev_word, "\x1d") == 0)) { ll_node_t * old_node = node; node = node->prev; @@ -2486,30 +2471,13 @@ ctxopt_build_cmdline_list(int nb_words, char ** words) goto next; } - /* Force a '^' if the previous element is SG */ - /* """""""""""""""""""""""""""""""""""""""""" */ - if (strcmp(word, "^") == 0) - { - if (prev_word != NULL && strcmp(prev_word, "\x1d") == 0) - { - *prev_word = '^'; - - ll_node_t * old_node = node; - node = node->prev; - ll_delete(cmdline_list, old_node); - free(old_node->data); - free(old_node); - goto next; - } - } - next: prev_word = node->data; node = node->next; } - /* Clean useless '^' and SG at the beginning and end of list */ - /* """"""""""""""""""""""""""""""""""""""""""""""""""""""""" */ + /* Clean useless and SG at the beginning and end of list */ + /* """"""""""""""""""""""""""""""""""""""""""""""""""""" */ node = cmdline_list->head; if (node == NULL) @@ -2517,7 +2485,7 @@ ctxopt_build_cmdline_list(int nb_words, char ** words) word = node->data; - if (strcmp(word, "\x1d") == 0 || strcmp(word, "^") == 0) + if (strcmp(word, "\x1d") == 0) { ll_delete(cmdline_list, node); free(word); @@ -2530,7 +2498,7 @@ ctxopt_build_cmdline_list(int nb_words, char ** words) word = node->data; - if (strcmp(word, "\x1d") == 0 || strcmp(word, "^") == 0) + if (strcmp(word, "\x1d") == 0) { ll_delete(cmdline_list, node); free(word); @@ -2625,19 +2593,6 @@ ctxopt_analyze(int nb_words, char ** words, int * nb_rem_args, ctx = ctx_inst->ctx; } } - else if (strcmp(par_name, "^") == 0) - { - check_for_missing_mandatory_opt(ctx_inst, (char *)(cli_node->prev->data)); - check_for_occurrences_issues(ctx_inst); - - /* Forced backtracking to the first context instance */ - /* """"""""""""""""""""""""""""""""""""""""""""""""" */ - if (ctx_inst->prev_ctx_inst != NULL) - { - ctx_inst = first_ctx_inst; - ctx = ctx_inst->ctx; - } - } else if (expect_par && *par_name == '-') { int pos = 0; |