X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/45c3f1cfee86fb48c96d53f8267f99b6db6e3d7a..505a8244525e28d212a27a6cc87d8a58b04dae44:/src/xbt/config.c diff --git a/src/xbt/config.c b/src/xbt/config.c index 0eb3145b86..0c23d46e1a 100644 --- a/src/xbt/config.c +++ b/src/xbt/config.c @@ -275,7 +275,7 @@ xbt_cfg_register(xbt_cfg_t * cfg, break; default: - XBT_ERROR("%d is an invalide type code", (int)type); + XBT_ERROR("%d is an invalid type code", (int)type); } xbt_dict_set((xbt_dict_t) * cfg, name, res, NULL); @@ -284,7 +284,7 @@ xbt_cfg_register(xbt_cfg_t * cfg, /** @brief Unregister an element from a config set. * * @param cfg the config set - * @param name the name of the elem to be freed + * @param name the name of the element to be freed * * Note that it removes both the description and the actual content. * Throws not_found when no such element exists. @@ -380,10 +380,11 @@ void xbt_cfg_help(xbt_cfg_t cfg) printf(" %s: %s\n", name, variable->desc); printf(" Type: %s; ", xbt_cfgelm_type_name[variable->type]); if (variable->min != 1 || variable->max != 1) { - if (variable->min == 0 && variable->max == 0) - printf("Arity: no bound; "); + printf("Arity: min:%d to max:", variable->min); + if (variable->max == 0) + printf("(no bound); "); else - printf("Arity: min:%d to max:%d; ", variable->min, variable->max); + printf("%d; ", variable->max); } size = xbt_dynar_length(variable->content); printf("Current value%s: ", (size <= 1 ? "" : "s")); @@ -453,6 +454,13 @@ void xbt_cfg_check(xbt_cfg_t cfg) size); } + if (variable->isdefault && size > variable->min) { + xbt_dict_cursor_free(&cursor); + THROWF(mismatch_error, 0, + "Config elem %s theoretically accepts %d %s, but has a default of %d values.", + name, variable->min, xbt_cfgelm_type_name[variable->type], size); + } + if (variable->max > 0 && variable->max < size) { xbt_dict_cursor_free(&cursor); THROWF(mismatch_error, 0, @@ -733,6 +741,7 @@ void *xbt_cfg_set_as_string(xbt_cfg_t cfg, const char *key, const char *value) { case xbt_cfgelm_boolean: xbt_cfg_set_boolean(cfg, key, value); /* throws */ + ret = (char *)value + strlen(value); break; case xbt_cfgelm_peer: