From: Andre Noll Date: Mon, 7 Sep 2015 21:40:58 +0000 (+0200) Subject: play: Remove support for non-lopsub commands. X-Git-Tag: v0.6.0~2^2~38 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=8326bbaf785bfcf0ecf57190facc6f97c30c8d98;p=paraslash.git play: Remove support for non-lopsub commands. This cleans up play.c to get rid of struct pp_command, the array of command handlers and the compatibility code for non-lopsub commands in run_command() and com_help(). Also the FOR_EACH_COMMAND() macro to iterate over all non-lopsub commands can go away and we no longer need to include the play.command_list.h header generated by command_util.bash. --- diff --git a/play.c b/play.c index c6a78598..1ab40101 100644 --- a/play.c +++ b/play.c @@ -665,22 +665,6 @@ static char **get_mapped_keyseqs(void) return result; } -#include "play.command_list.h" - -typedef int play_command_handler_t(struct play_task *, int, char**); - -/* defines one command of para_play */ -struct pp_command { - const char *name; - play_command_handler_t *handler; - const char *description; - const char *usage; - const char *help; -}; - -static struct pp_command pp_cmds[] = {DEFINE_PLAY_CMD_ARRAY}; -#define FOR_EACH_COMMAND(c) for (c = 0; pp_cmds[c].name; c++) - static struct i9e_completer pp_completers[]; I9E_DUMMY_COMPLETER(jmp); @@ -755,11 +739,6 @@ static int com_help(struct play_task *pt, struct lls_parse_result *lpr) lls_command_name(cmd), lls_purpose(cmd)); btr_add_output(buf, sz, pt->btrn); } - FOR_EACH_COMMAND(i) { - sz = xasprintf(&buf, "%s\t%s\n", pp_cmds[i].name, - pp_cmds[i].description); - btr_add_output(buf, sz, pt->btrn); - } return 0; } FOR_EACH_MAPPED_KEY(i) { @@ -1015,7 +994,7 @@ EXPORT_PLAY_CMD_HANDLER(ff); static int run_command(char *line, struct play_task *pt) { - int i, ret, argc; + int ret, argc; char **argv = NULL; char *errctx = NULL; const struct play_command_info *pci; @@ -1029,26 +1008,16 @@ static int run_command(char *line, struct play_task *pt) if (ret == 0) goto out; argc = ret; - ret = lls(lls_lookup_subcmd(argv[0], play_cmd_suite, &errctx)); - if (ret >= 0) { - cmd = lls_cmd(ret, play_cmd_suite); - ret = lls(lls_parse(argc, argv, cmd, &lpr, &errctx)); - if (ret < 0) - goto out; - pci = lls_user_data(cmd); - ret = pci->handler(pt, lpr); - lls_free_parse_result(lpr, cmd); - } else { - FOR_EACH_COMMAND(i) { - if (strcmp(pp_cmds[i].name, argv[0])) - continue; - free(errctx); - errctx = NULL; - ret = pp_cmds[i].handler(pt, argc, argv); - break; - } - } + if (ret < 0) + goto out; + cmd = lls_cmd(ret, play_cmd_suite); + ret = lls(lls_parse(argc, argv, cmd, &lpr, &errctx)); + if (ret < 0) + goto out; + pci = lls_user_data(cmd); + ret = pci->handler(pt, lpr); + lls_free_parse_result(lpr, cmd); out: if (errctx) PARA_ERROR_LOG("%s\n", errctx);