- errcode=xbt_dict_get((xbt_dict_t)cfg,name,(void**)&variable);
- switch (errcode) {
- case no_error:
- break;
- case mismatch_error:
- ERROR1("No registrated variable corresponding to '%s'.",name);
- xbt_free(optionlist_cpy);
- return mismatch_error;
- break;
- default:
- xbt_free(optionlist_cpy);
- return errcode;
- }
-
- switch (variable->type) {
- case xbt_cfgelm_string:
- errcode = xbt_cfg_set_string(cfg, name, val);
- if (errcode != no_error) {
- xbt_free(optionlist_cpy);
- return errcode;
- }
- break;
-
- case xbt_cfgelm_int:
- i=strtol(val, &val, 0);
- if (val==NULL) {
- xbt_free(optionlist_cpy);
- xbt_assert1(FALSE,
- "Value of option %s not valid. Should be an integer",
- name);
- }
-
- errcode = xbt_cfg_set_int(cfg,name,i);
- if (errcode != no_error) {
- xbt_free(optionlist_cpy);
- return errcode;
- }
- break;
-
- case xbt_cfgelm_double:
- d=strtod(val, &val);
- if (val==NULL) {
- xbt_free(optionlist_cpy);
- xbt_assert1(FALSE,
- "Value of option %s not valid. Should be a double",
- name);
- }
-
- errcode = xbt_cfg_set_double(cfg,name,d);
- if (errcode != no_error) {
- xbt_free(optionlist_cpy);
- return errcode;
- }
- break;
-
- case xbt_cfgelm_host:
- str=val;
- val=strchr(val,':');
- if (!val) {
- xbt_free(optionlist_cpy);
- xbt_assert1(FALSE,
- "Value of option %s not valid. Should be an host (machine:port)",
- name);
- }
-
- *(val++)='\0';
- i=strtol(val, &val, 0);
- if (val==NULL) {
- xbt_free(optionlist_cpy);
- xbt_assert1(FALSE,
- "Value of option %s not valid. Should be an host (machine:port)",
- name);
+ TRY {
+ variable = xbt_dict_get((xbt_dict_t)cfg,name);
+ } CATCH(e) {
+ /* put it back on what won't get freed, ie within "options" and out of "optionlist_cpy" */
+ name = (char*) (optionlist_cpy-name + options);
+ free(optionlist_cpy);
+ if (e.category == not_found_error) {
+ xbt_ex_free(e);
+ THROW1(not_found_error,0,"No registrated variable corresponding to '%s'.",name);