summaryrefslogtreecommitdiffstats
path: root/ctxopt.c
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2020-06-29 18:06:06 +0200
committerpgen <p.gen.progs@gmail.com>2020-07-18 18:31:02 +0200
commite4be914f1d4399b6762103210ad9b6ca7a3d2db7 (patch)
treeb9766731fe92dccdf6637d298766c30c65fe4054 /ctxopt.c
parent13106044cbefca5893089fecac8641c9ef68b87a (diff)
Sync with github's ctxopt commit 450c47f
Diffstat (limited to 'ctxopt.c')
-rw-r--r--ctxopt.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/ctxopt.c b/ctxopt.c
index 2c500b9..7e9f688 100644
--- a/ctxopt.c
+++ b/ctxopt.c
@@ -378,12 +378,12 @@ fatal(errors e, char * errmsg)
fprintf(stderr,
"The parameter %s can only appear once in the context "
"introduced by %s.\n",
- cur_state->cur_opt_par_name, cur_state->ctx_par_name);
+ cur_state->cur_opt_params, cur_state->ctx_par_name);
else
fprintf(stderr,
"The parameter %s can only appear once "
"in the main context.\n",
- cur_state->cur_opt_par_name);
+ cur_state->cur_opt_params);
break;
case CTXOPTUNKPAR:
@@ -400,13 +400,13 @@ fatal(errors e, char * errmsg)
fprintf(stderr,
"The parameter %s must appear exactly %d times "
"in the context introduced by %s.\n",
- cur_state->cur_opt_par_name, cur_state->opts_count,
+ cur_state->cur_opt_params, cur_state->opts_count,
cur_state->ctx_par_name);
else
fprintf(stderr,
"The parameter %s must appear exactly %d times "
"in the main context.\n",
- cur_state->cur_opt_par_name, cur_state->opts_count);
+ cur_state->cur_opt_params, cur_state->opts_count);
break;
case CTXOPTCTLOPT:
@@ -414,13 +414,13 @@ fatal(errors e, char * errmsg)
fprintf(stderr,
"The parameter %s must appear less than %d times "
"in the context introduced by %s.\n",
- cur_state->cur_opt_par_name, cur_state->opts_count,
+ cur_state->cur_opt_params, cur_state->opts_count,
cur_state->ctx_par_name);
else
fprintf(stderr,
"The parameter %s must appear less than %d times "
"in the main context.\n",
- cur_state->cur_opt_par_name, cur_state->opts_count);
+ cur_state->cur_opt_params, cur_state->opts_count);
break;
case CTXOPTCTGOPT:
@@ -428,13 +428,13 @@ fatal(errors e, char * errmsg)
fprintf(stderr,
"The parameter %s must appear more than %d times "
"in the context introduced by %s.\n",
- cur_state->cur_opt_par_name, cur_state->opts_count,
+ cur_state->cur_opt_params, cur_state->opts_count,
cur_state->ctx_par_name);
else
fprintf(stderr,
"The parameter %s must appear more than %d times "
"in the main context.\n",
- cur_state->cur_opt_par_name, cur_state->opts_count);
+ cur_state->cur_opt_params, cur_state->opts_count);
break;
case CTXOPTCTEARG:
@@ -2133,6 +2133,8 @@ check_for_occurrences_issues(ctx_inst_t * ctx_inst)
opt_t * opt;
ll_node_t * node;
opt_inst_t * opt_inst;
+ char * cur_opt_params = cur_state->cur_opt_params;
+ char * cur_opt_par_name = cur_state->cur_opt_par_name;
/* Checks options. */
/* """"""""""""""" */
@@ -2144,6 +2146,7 @@ check_for_occurrences_issues(ctx_inst_t * ctx_inst)
/* Update current_state. */
/* """"""""""""""""""""" */
+ cur_state->cur_opt_params = opt->params;
cur_state->opts_count = opt->opt_count_mark;
cur_state->opt_args_count = opt->opt_args_count_mark;
@@ -2179,8 +2182,9 @@ check_for_occurrences_issues(ctx_inst_t * ctx_inst)
/* Update current_state. */
/* """"""""""""""""""""" */
- cur_state->opts_count = opt->opt_count_mark;
- cur_state->opt_args_count = opt->opt_args_count_mark;
+ cur_state->cur_opt_par_name = opt_inst->par;
+ cur_state->opts_count = opt->opt_count_mark;
+ cur_state->opt_args_count = opt->opt_args_count_mark;
int nb_values = opt_inst->values_list->len; /* Number of arguments of opt */
@@ -2205,6 +2209,8 @@ check_for_occurrences_issues(ctx_inst_t * ctx_inst)
node = node->next;
}
+ cur_state->cur_opt_params = cur_opt_params;
+ cur_state->cur_opt_par_name = cur_opt_par_name;
}
/* ======================================================================== */
@@ -3372,6 +3378,10 @@ ctxopt_analyze(int nb_words, char ** words, int * nb_rem_args,
opt_inst->values_list = ll_new();
opt_inst->next_ctx_inst = NULL;
+ /* Update current_state. */
+ /* """"""""""""""""""""" */
+ cur_state->cur_opt_params = opt->params;
+
/* Priority option are inserted at the start of the opt_inst list */
/* but their order of appearance in the context definition must */
/* be preserver so each new priority option will be placed after */
@@ -3629,7 +3639,7 @@ ctxopt_analyze(int nb_words, char ** words, int * nb_rem_args,
void
ctxopt_free_memory(void)
{
- ll_destroy(cmdline_list, NULL);
+ ll_destroy(cmdline_list, free);
ll_destroy(ctx_inst_list, ctx_inst_free);
bst_destroy(options_bst, opt_free);
bst_destroy(contexts_bst, ctx_free);