Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
typo -= 2
[simgrid.git] / src / xbt / config.c
index 0eb3145..0c23d46 100644 (file)
@@ -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: