commands: remove EXPECTED_MORE_THAN

Its uses have been replaced with EXPECTED_AT_LEAST.
This commit is contained in:
Ian Fan 2018-10-23 10:17:58 +01:00
parent a9fdd5dd2a
commit 5364255f26
6 changed files with 5 additions and 14 deletions

View file

@ -39,7 +39,6 @@ struct cmd_results {
}; };
enum expected_args { enum expected_args {
EXPECTED_MORE_THAN,
EXPECTED_AT_LEAST, EXPECTED_AT_LEAST,
EXPECTED_LESS_THAN, EXPECTED_LESS_THAN,
EXPECTED_EQUAL_TO EXPECTED_EQUAL_TO

View file

@ -20,14 +20,6 @@
struct cmd_results *checkarg(int argc, const char *name, enum expected_args type, int val) { struct cmd_results *checkarg(int argc, const char *name, enum expected_args type, int val) {
struct cmd_results *error = NULL; struct cmd_results *error = NULL;
switch (type) { switch (type) {
case EXPECTED_MORE_THAN:
if (argc > val) {
return NULL;
}
error = cmd_results_new(CMD_INVALID, name, "Invalid %s command "
"(expected more than %d argument%s, got %d)",
name, val, (char*[2]){"s", ""}[argc==1], argc);
break;
case EXPECTED_AT_LEAST: case EXPECTED_AT_LEAST:
if (argc >= val) { if (argc >= val) {
return NULL; return NULL;

View file

@ -10,7 +10,7 @@
struct cmd_results *bar_cmd_bindsym(int argc, char **argv) { struct cmd_results *bar_cmd_bindsym(int argc, char **argv) {
struct cmd_results *error = NULL; struct cmd_results *error = NULL;
if ((error = checkarg(argc, "bar bindsym", EXPECTED_MORE_THAN, 1))) { if ((error = checkarg(argc, "bar bindsym", EXPECTED_AT_LEAST, 2))) {
return error; return error;
} }
if (!config->current_bar) { if (!config->current_bar) {

View file

@ -145,7 +145,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
const char *bindtype = bindcode ? "bindcode" : "bindsym"; const char *bindtype = bindcode ? "bindcode" : "bindsym";
struct cmd_results *error = NULL; struct cmd_results *error = NULL;
if ((error = checkarg(argc, bindtype, EXPECTED_MORE_THAN, 1))) { if ((error = checkarg(argc, bindtype, EXPECTED_AT_LEAST, 2))) {
return error; return error;
} }

View file

@ -16,7 +16,7 @@
struct cmd_results *cmd_exec_always(int argc, char **argv) { struct cmd_results *cmd_exec_always(int argc, char **argv) {
struct cmd_results *error = NULL; struct cmd_results *error = NULL;
if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL); if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL);
if ((error = checkarg(argc, argv[-1], EXPECTED_MORE_THAN, 0))) { if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) {
return error; return error;
} }
@ -24,7 +24,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
if (strcmp(argv[0], "--no-startup-id") == 0) { if (strcmp(argv[0], "--no-startup-id") == 0) {
wlr_log(WLR_INFO, "exec switch '--no-startup-id' not supported, ignored."); wlr_log(WLR_INFO, "exec switch '--no-startup-id' not supported, ignored.");
--argc; ++argv; --argc; ++argv;
if ((error = checkarg(argc, argv[-1], EXPECTED_MORE_THAN, 0))) { if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) {
return error; return error;
} }
} }

View file

@ -96,7 +96,7 @@ static enum sway_container_layout get_layout(int argc, char **argv,
struct cmd_results *cmd_layout(int argc, char **argv) { struct cmd_results *cmd_layout(int argc, char **argv) {
struct cmd_results *error = NULL; struct cmd_results *error = NULL;
if ((error = checkarg(argc, "layout", EXPECTED_MORE_THAN, 0))) { if ((error = checkarg(argc, "layout", EXPECTED_AT_LEAST, 1))) {
return error; return error;
} }
struct sway_container *container = config->handler_context.container; struct sway_container *container = config->handler_context.container;