diff options
author | Ray Strode <rstrode@redhat.com> | 2008-08-05 15:09:30 -0400 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2008-08-05 15:19:10 -0400 |
commit | a05890e55c6f67157ee55618cf77a364fe734003 (patch) | |
tree | 39ea07128087c7f97c586a1dd2806f82306b5fdb | |
parent | e587fa6a45c77dbf00254eb1cc6179f72ad6a4a8 (diff) | |
download | plymouth-a05890e55c6f67157ee55618cf77a364fe734003.tar.gz plymouth-a05890e55c6f67157ee55618cf77a364fe734003.tar.xz plymouth-a05890e55c6f67157ee55618cf77a364fe734003.zip |
Handle flags and booleans better in command parser
We were occasionally misattributing one command for another
-rw-r--r-- | src/libply/ply-command-parser.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/libply/ply-command-parser.c b/src/libply/ply-command-parser.c index 131c3af..e812298 100644 --- a/src/libply/ply-command-parser.c +++ b/src/libply/ply-command-parser.c @@ -589,19 +589,38 @@ ply_command_option_read_arguments (ply_command_option_t *option, assert (argument != NULL); if (argument_is_option (argument)) - return false; + { + if (option->type == PLY_COMMAND_OPTION_TYPE_BOOLEAN || + option->type == PLY_COMMAND_OPTION_TYPE_FLAG) + { + option->result.as_boolean = true; + return true; + } - ply_list_remove_node (arguments, node); + return false; + } switch (option->type) { case PLY_COMMAND_OPTION_TYPE_FLAG: case PLY_COMMAND_OPTION_TYPE_BOOLEAN: + + /* next argument isn't ours, so treat it like an unqualified + * flag + */ + if (rpmatch (argument) < 0) + { + option->result.as_boolean = true; + return true; + } + option->result.as_boolean = (bool) rpmatch (argument); + ply_list_remove_node (arguments, node); return true; case PLY_COMMAND_OPTION_TYPE_STRING: - option->result.as_string = strdup (argument); + option->result.as_string = strdup (argument); + ply_list_remove_node (arguments, node); return true; case PLY_COMMAND_OPTION_TYPE_INTEGER: @@ -625,7 +644,7 @@ ply_command_option_read_arguments (ply_command_option_t *option, return false; option->result.as_integer = (int) argument_as_long; - + ply_list_remove_node (arguments, node); return true; } } |