diff options
author | Quentin Glidic <sardemff7+git@sardemff7.net> | 2017-11-11 11:30:08 +0100 |
---|---|---|
committer | Quentin Glidic <sardemff7+git@sardemff7.net> | 2017-12-09 10:34:11 +0100 |
commit | 58ed481198200ef3228c02e491de44b177948e59 (patch) | |
tree | 4a877cf99da3e85a0d764822eef32d9a779b09f2 | |
parent | ae4ea622bbe786499379152d0f3d06be7664e6d7 (diff) |
xrmoptions: Use a switch where possible
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
-rw-r--r-- | source/xrmoptions.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/source/xrmoptions.c b/source/xrmoptions.c index 6c92881b..36c296be 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -226,11 +226,14 @@ void config_parser_add_option ( XrmOptionType type, const char *key, void **valu extra_options[num_extra_options].value.pointer = value; extra_options[num_extra_options].comment = comment; extra_options[num_extra_options].source = CONFIG_DEFAULT; - if ( type == xrm_String ) { + switch ( type ) + { + case xrm_String: extra_options[num_extra_options].mem = ( (char *) ( *value ) ); - } - else { + break; + default: extra_options[num_extra_options].mem = NULL; + break; } num_extra_options++; @@ -238,7 +241,9 @@ void config_parser_add_option ( XrmOptionType type, const char *key, void **valu static void config_parser_set ( XrmOption *option, char *xrmValue, enum ConfigSource source ) { - if ( option->type == xrm_String ) { + switch ( option->type ) + { + case xrm_String: if ( ( option )->mem != NULL ) { g_free ( option->mem ); option->mem = NULL; @@ -247,14 +252,14 @@ static void config_parser_set ( XrmOption *option, char *xrmValue, enum ConfigSo // Memory ( option )->mem = *( option->value.str ); - } - else if ( option->type == xrm_Number ) { + break; + case xrm_Number: *( option->value.num ) = (unsigned int) g_ascii_strtoull ( xrmValue, NULL, 10 ); - } - else if ( option->type == xrm_SNumber ) { + break; + case xrm_SNumber: *( option->value.snum ) = (int) g_ascii_strtoll ( xrmValue, NULL, 10 ); - } - else if ( option->type == xrm_Boolean ) { + break; + case xrm_Boolean: if ( strlen ( xrmValue ) > 0 && g_ascii_strcasecmp ( xrmValue, "true" ) == 0 ) { *( option->value.num ) = TRUE; @@ -262,9 +267,10 @@ static void config_parser_set ( XrmOption *option, char *xrmValue, enum ConfigSo else{ *( option->value.num ) = FALSE; } - } - else if ( option->type == xrm_Char ) { + break; + case xrm_Char: *( option->value.charc ) = helper_parse_char ( xrmValue ); + break; } option->source = source; } |