mca/base: add yes/no as valid values for boolean variables
This commit expands the set of accepted values for boolean values to include yes/no as synonyms for 1/0. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Этот коммит содержится в:
родитель
61fe2cc629
Коммит
65472a383f
@ -58,13 +58,16 @@ static int mca_base_var_enum_bool_vfs (mca_base_var_enum_t *self, const char *st
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
|
/* skip whitespace */
|
||||||
|
string_value += strspn (string_value, " \t\n\v\f\r");
|
||||||
|
|
||||||
v = strtol (string_value, &tmp, 10);
|
v = strtol (string_value, &tmp, 10);
|
||||||
if (*tmp != '\0') {
|
if (*tmp != '\0') {
|
||||||
if (0 == strcmp (string_value, "true") || 0 == strcmp (string_value, "t") ||
|
if (0 == strcmp (string_value, "true") || 0 == strcmp (string_value, "t") ||
|
||||||
0 == strcmp (string_value, "enabled")) {
|
0 == strcmp (string_value, "enabled") || 0 == strcmp (string_value, "yes")) {
|
||||||
v = 1;
|
v = 1;
|
||||||
} else if (0 == strcmp (string_value, "false") || 0 == strcmp (string_value, "f") ||
|
} else if (0 == strcmp (string_value, "false") || 0 == strcmp (string_value, "f") ||
|
||||||
0 == strcmp (string_value, "disabled")) {
|
0 == strcmp (string_value, "disabled") || 0 == strcmp (string_value, "no")) {
|
||||||
v = 0;
|
v = 0;
|
||||||
} else {
|
} else {
|
||||||
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
|
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
|
||||||
@ -88,7 +91,7 @@ static int mca_base_var_enum_bool_sfv (mca_base_var_enum_t *self, const int valu
|
|||||||
|
|
||||||
static int mca_base_var_enum_bool_dump (mca_base_var_enum_t *self, char **out)
|
static int mca_base_var_enum_bool_dump (mca_base_var_enum_t *self, char **out)
|
||||||
{
|
{
|
||||||
*out = strdup ("0: f|false|disabled, 1: t|true|enabled");
|
*out = strdup ("0: f|false|disabled|no, 1: t|true|enabled|yes");
|
||||||
return *out ? OPAL_SUCCESS : OPAL_ERR_OUT_OF_RESOURCE;
|
return *out ? OPAL_SUCCESS : OPAL_ERR_OUT_OF_RESOURCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,4 +166,15 @@ OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_base_var_enum_t);
|
|||||||
OPAL_DECLSPEC int mca_base_var_enum_create (const char *name, const mca_base_var_enum_value_t values[],
|
OPAL_DECLSPEC int mca_base_var_enum_create (const char *name, const mca_base_var_enum_value_t values[],
|
||||||
mca_base_var_enum_t **enumerator);
|
mca_base_var_enum_t **enumerator);
|
||||||
|
|
||||||
|
/* standard enumerators. it is invalid to call OBJ_RELEASE on any of these enumerators */
|
||||||
|
/**
|
||||||
|
* Boolean enumerator
|
||||||
|
*
|
||||||
|
* This enumerator maps:
|
||||||
|
* positive integer, true, yes, enabled, t -> 1
|
||||||
|
* 0, false, no, disabled, f -> 0
|
||||||
|
*/
|
||||||
|
extern mca_base_var_enum_t mca_base_var_enum_bool;
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(MCA_BASE_VAR_ENUM_H) */
|
#endif /* !defined(MCA_BASE_VAR_ENUM_H) */
|
||||||
|
@ -73,8 +73,6 @@ extern const char *var_type_names[];
|
|||||||
extern const size_t var_type_sizes[];
|
extern const size_t var_type_sizes[];
|
||||||
extern bool mca_base_var_initialized;
|
extern bool mca_base_var_initialized;
|
||||||
|
|
||||||
extern mca_base_var_enum_t mca_base_var_enum_bool;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \internal
|
* \internal
|
||||||
*
|
*
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user