Stub out all users of old API.

This commit is contained in:
Your Name
2026-06-30 09:39:45 +01:00
parent b8a62979ac
commit 9e8cf6f0e2
14 changed files with 161 additions and 43 deletions

View File

@@ -774,8 +774,6 @@ args_make_commands_prepare(struct cmd *self, struct cmdq_item *item, u_int idx,
const char *default_command, int wait, int expand)
{
struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct client *tc = cmdq_get_target_client(item);
struct args_value *value;
struct args_command_state *state;
const char *cmd;
@@ -804,15 +802,22 @@ args_make_commands_prepare(struct cmd *self, struct cmdq_item *item, u_int idx,
state->cmd = xstrdup(cmd);
log_debug("%s: %s", __func__, state->cmd);
#if 0 /* XXX: command parser conversion */
if (wait)
state->pi.item = item;
cmd_get_source(self, &file, &state->pi.line);
if (file != NULL)
state->pi.file = xstrdup(file);
state->pi.c = tc;
state->pi.c = cmdq_get_target_client(item);
if (state->pi.c != NULL)
state->pi.c->references++;
cmd_find_copy_state(&state->pi.fs, target);
cmd_find_copy_state(&state->pi.fs, cmdq_get_target(item));
#else
(void)wait;
cmd_get_source(self, &file, &state->pi.line);
if (file != NULL)
state->pi.file = xstrdup(file);
#endif
return (state);
}
@@ -822,16 +827,17 @@ struct cmd_list *
args_make_commands(struct args_command_state *state, int argc, char **argv,
char **error)
{
struct cmd_parse_result *pr;
char *cmd, *new_cmd;
int i;
if (state->cmdlist != NULL) {
if (argc == 0)
return (state->cmdlist);
return (cmd_list_copy(state->cmdlist, argc, argv));
}
#if 0 /* XXX: command parser conversion */
struct cmd_parse_result *pr;
char *cmd, *new_cmd;
int i;
cmd = xstrdup(state->cmd);
log_debug("%s: %s", __func__, cmd);
cmd_log_argv(argc, argv, __func__);
@@ -853,6 +859,10 @@ args_make_commands(struct args_command_state *state, int argc, char **argv,
return (pr->cmdlist);
}
fatalx("invalid parse return state");
#else
(void)error;
fatalx("XXX: command parser conversion not done for ARGS_COMMANDS");
#endif
}
/* Free commands state. */
@@ -861,8 +871,10 @@ args_make_commands_free(struct args_command_state *state)
{
if (state->cmdlist != NULL)
cmd_list_free(state->cmdlist);
#if 0 /* XXX: command parser conversion */
if (state->pi.c != NULL)
server_client_unref(state->pi.c);
#endif
free((void *)state->pi.file);
free(state->cmd);
free(state);

42
cfg.c
View File

@@ -98,9 +98,10 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item,
{
FILE *f;
struct cmd_parse_input pi;
struct cmd_parse_result *pr;
struct cmd_parse_tree *tree;
struct cmdq_item *new_item0;
struct cmdq_state *state;
char *cause = NULL;
if (new_item != NULL)
*new_item = NULL;
@@ -117,18 +118,16 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item,
pi.flags = flags;
pi.file = path;
pi.line = 1;
pi.item = item;
pi.c = c;
pr = cmd_parse_from_file(f, &pi);
tree = cmd_parse_from_file(f, &pi, &cause);
fclose(f);
if (pr->status == CMD_PARSE_ERROR) {
cfg_add_cause("%s", pr->error);
free(pr->error);
if (tree == NULL) {
cfg_add_cause("%s", cause);
free(cause);
return (-1);
}
cmd_parse_log(__func__, tree);
if (flags & CMD_PARSE_PARSEONLY) {
cmd_list_free(pr->cmdlist);
cmd_parse_free(tree);
return (0);
}
@@ -138,12 +137,12 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item,
state = cmdq_new_state(NULL, NULL, 0);
cmdq_add_format(state, "current_file", "%s", pi.file);
new_item0 = cmdq_get_command(pr->cmdlist, state);
new_item0 = cmd_invoke_get(tree, state, 0, NULL);
if (item != NULL)
new_item0 = cmdq_insert_after(item, new_item0);
else
new_item0 = cmdq_append(NULL, new_item0);
cmd_list_free(pr->cmdlist);
cmd_parse_free(tree);
cmdq_free_state(state);
if (new_item != NULL)
@@ -157,9 +156,10 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,
int flags, struct cmdq_item **new_item)
{
struct cmd_parse_input pi;
struct cmd_parse_result *pr;
struct cmd_parse_tree *tree;
struct cmdq_item *new_item0;
struct cmdq_state *state;
char *cause = NULL;
if (new_item != NULL)
*new_item = NULL;
@@ -170,17 +170,15 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,
pi.flags = flags;
pi.file = path;
pi.line = 1;
pi.item = item;
pi.c = c;
pr = cmd_parse_from_buffer(buf, len, &pi);
if (pr->status == CMD_PARSE_ERROR) {
cfg_add_cause("%s", pr->error);
free(pr->error);
tree = cmd_parse_from_buffer(buf, len, &pi, &cause);
if (tree == NULL) {
cfg_add_cause("%s", cause);
free(cause);
return (-1);
}
cmd_parse_log(__func__, tree);
if (flags & CMD_PARSE_PARSEONLY) {
cmd_list_free(pr->cmdlist);
cmd_parse_free(tree);
return (0);
}
@@ -190,12 +188,12 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,
state = cmdq_new_state(NULL, NULL, 0);
cmdq_add_format(state, "current_file", "%s", pi.file);
new_item0 = cmdq_get_command(pr->cmdlist, state);
new_item0 = cmd_invoke_get(tree, state, 0, NULL);
if (item != NULL)
new_item0 = cmdq_insert_after(item, new_item0);
else
new_item0 = cmdq_append(NULL, new_item0);
cmd_list_free(pr->cmdlist);
cmd_parse_free(tree);
cmdq_free_state(state);
if (new_item != NULL)

View File

@@ -232,7 +232,6 @@ int
client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
int feat)
{
struct cmd_parse_result *pr;
struct msg_command *data;
int fd, i;
const char *ttynam, *termname, *cwd;
@@ -243,7 +242,6 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
ssize_t linelen;
char *line = NULL, **caps = NULL, *cause;
u_int ncaps = 0;
struct args_value *values;
/* Set up the initial command. */
if (shell_command != NULL) {
@@ -255,6 +253,10 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
} else {
msg = MSG_COMMAND;
#if 0 /* XXX: command parser conversion */
struct cmd_parse_result *pr;
struct args_value *values;
/*
* It's annoying parsing the command string twice (in client
* and later in server) but it is necessary to get the start
@@ -270,6 +272,13 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
free(pr->error);
args_free_values(values, argc);
free(values);
#else
/*
* XXX: command parser conversion. The old parser was used only
* to detect CMD_STARTSERVER here.
*/
flags |= CLIENT_STARTSERVER;
#endif
}
/* Create client process structure (starts logging). */

View File

@@ -57,7 +57,6 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self);
key_code key;
const char *tablename, *note = args_get(args, 'N');
struct cmd_parse_result *pr;
int repeat;
struct args_value *value;
u_int count = args_count(args);
@@ -88,6 +87,9 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL);
}
#if 0 /* XXX: command parser conversion */
struct cmd_parse_result *pr;
if (count == 2)
pr = cmd_parse_from_string(args_string(args, 1), NULL);
else {
@@ -104,4 +106,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
}
key_bindings_add(tablename, key, note, repeat, pr->cmdlist);
return (CMD_RETURN_NORMAL);
#else
fatalx("XXX: command parser conversion not done for bind-key");
#endif
}

View File

@@ -328,7 +328,11 @@ cmd_invoke_build_command(struct cmdq_item *item, struct cmd_invoke_state *is,
break;
case CMD_PARSE_COMMANDS:
values[count].type = ARGS_COMMANDS;
#if 0 /* XXX: command parser conversion */
values[count].cmdparse = child;
#else
fatalx("XXX: command parser conversion not done for ARGS_COMMANDS");
#endif
break;
default:
fatalx("unexpected node type in command");
@@ -373,7 +377,8 @@ cmd_invoke_get(struct cmd_parse_tree *tree, struct cmdq_state *state, int argc,
is = xcalloc(1, sizeof *is);
is->references = 1;
is->tree = cmd_parse_add_ref(tree);
cmd_parse_log(tree);
log_debug("%s: tree %p", __func__, tree);
cmd_parse_log(__func__, tree);
is->argc = argc;
if (argc != 0) {
@@ -445,7 +450,9 @@ cmd_invoke_fire(struct cmdq_item *item, struct cmd_invoke_state *is)
node = cmd_invoke_next(is);
if (node == NULL)
return (CMD_RETURN_NORMAL);
cmd_parse_log_node(node);
log_debug("%s: node %s", __func__,
cmd_parse_node_type_string(cmd_parse_node_type(node)));
cmd_parse_log_node(__func__, node);
switch (cmd_parse_node_type(node)) {
case CMD_PARSE_ROOT:
@@ -470,6 +477,7 @@ cmd_invoke_fire(struct cmdq_item *item, struct cmd_invoke_state *is)
case CMD_PARSE_ELSE:
break;
case CMD_PARSE_COMMAND:
fatalx("XXX: command execution not implemented yet");
cmd = cmd_invoke_build_command(item, is, node);
if (cmd == NULL) {
cmd_invoke_skip_sequence(is);

View File

@@ -557,7 +557,9 @@ control_read_callback(__unused struct bufferevent *bufev, void *data)
struct evbuffer *buffer = cs->read_event->input;
char *line, *error;
struct cmdq_state *state;
#if 0 /* XXX: command parser conversion */
enum cmd_parse_status status;
#endif
for (;;) {
line = evbuffer_readln(buffer, NULL, EVBUFFER_EOL_LF);
@@ -570,11 +572,18 @@ control_read_callback(__unused struct bufferevent *bufev, void *data)
break;
}
#if 0 /* XXX: command parser conversion */
state = cmdq_new_state(NULL, NULL, CMDQ_STATE_CONTROL);
status = cmd_parse_and_append(line, NULL, c, state, &error);
if (status == CMD_PARSE_ERROR)
cmdq_append(c, cmdq_get_callback(control_error, error));
cmdq_free_state(state);
#else
state = cmdq_new_state(NULL, NULL, CMDQ_STATE_CONTROL);
error = xstrdup("XXX: command parser conversion not done for control mode");
cmdq_append(c, cmdq_get_callback(control_error, error));
cmdq_free_state(state);
#endif
free(line);
}

View File

@@ -672,6 +672,8 @@ key_bindings_init(void)
"bind -Tcopy-mode-vi C-Up { send -X scroll-up }",
"bind -Tcopy-mode-vi C-Down { send -X scroll-down }",
};
#if 0 /* XXX: command parser conversion */
u_int i;
struct cmd_parse_result *pr;
@@ -684,6 +686,10 @@ key_bindings_init(void)
cmdq_append(NULL, cmdq_get_command(pr->cmdlist, NULL));
cmd_list_free(pr->cmdlist);
}
#else
log_debug("XXX: command parser conversion not done for %u default keys",
(u_int)nitems(defaults));
#endif
cmdq_append(NULL, cmdq_get_callback(key_bindings_init_done, NULL));
}

8
menu.c
View File

@@ -316,7 +316,9 @@ menu_key_cb(struct client *c, void *data, struct key_event *event)
const char *name = NULL;
const struct menu_item *item;
struct cmdq_state *state;
#if 0 /* XXX: command parser conversion */
enum cmd_parse_status status;
#endif
char *error;
if (KEYC_IS_MOUSE(event->key)) {
@@ -497,11 +499,17 @@ chosen:
event = NULL;
state = cmdq_new_state(&md->fs, event, 0);
#if 0 /* XXX: command parser conversion */
status = cmd_parse_and_append(item->command, NULL, c, state, &error);
if (status == CMD_PARSE_ERROR) {
cmdq_append(c, cmdq_get_error(error));
free(error);
}
#else
error = xstrdup("XXX: command parser conversion not done for menu");
cmdq_append(c, cmdq_get_error(error));
free(error);
#endif
cmdq_free_state(state);
return (1);

View File

@@ -1816,11 +1816,14 @@ mode_tree_run_command(struct client *c, struct cmd_find_state *fs,
{
struct cmdq_state *state;
char *command, *error;
#if 0 /* XXX: command parser conversion */
enum cmd_parse_status status;
#endif
command = cmd_template_replace(template, name, 1);
if (command != NULL && *command != '\0') {
state = cmdq_new_state(fs, NULL, 0);
#if 0 /* XXX: command parser conversion */
status = cmd_parse_and_append(command, NULL, c, state, &error);
if (status == CMD_PARSE_ERROR) {
if (c != NULL) {
@@ -1829,6 +1832,14 @@ mode_tree_run_command(struct client *c, struct cmd_find_state *fs,
}
free(error);
}
#else
error = xstrdup("XXX: command parser conversion not done for mode tree");
if (c != NULL) {
*error = toupper((u_char)*error);
status_message_set(c, -1, 1, 0, 0, "%s", error);
}
free(error);
#endif
cmdq_free_state(state);
}
free(command);

View File

@@ -62,8 +62,6 @@ notify_insert_hook(struct cmdq_item *item, struct notify_entry *ne)
struct options_entry *o;
struct options_array_item *a;
struct cmd_list *cmdlist;
const char *value;
struct cmd_parse_result *pr;
log_debug("%s: inserting hook %s", __func__, ne->name);
@@ -95,6 +93,10 @@ notify_insert_hook(struct cmdq_item *item, struct notify_entry *ne)
cmdq_add_formats(state, ne->formats);
if (*ne->name == '@') {
#if 0 /* XXX: command parser conversion */
struct cmd_parse_result *pr;
const char *value;
value = options_get_string(oo, ne->name);
pr = cmd_parse_from_string(value, NULL);
switch (pr->status) {
@@ -107,6 +109,10 @@ notify_insert_hook(struct cmdq_item *item, struct notify_entry *ne)
notify_insert_one_hook(item, ne, pr->cmdlist, state);
break;
}
#else
log_debug("%s: command parser conversion not done for hook %s",
__func__, ne->name);
#endif
} else {
a = options_array_first(o);
while (a != NULL) {

View File

@@ -260,7 +260,6 @@ options_default(struct options *oo, const struct options_table_entry *oe)
struct options_entry *o;
union options_value *ov;
u_int i;
struct cmd_parse_result *pr;
o = options_empty(oo, oe);
ov = &o->value;
@@ -280,6 +279,9 @@ options_default(struct options *oo, const struct options_table_entry *oe)
ov->string = xstrdup(oe->default_str);
break;
case OPTIONS_TABLE_COMMAND:
#if 0 /* XXX: command parser conversion */
struct cmd_parse_result *pr;
pr = cmd_parse_from_string(oe->default_str, NULL);
switch (pr->status) {
case CMD_PARSE_ERROR:
@@ -289,6 +291,10 @@ options_default(struct options *oo, const struct options_table_entry *oe)
ov->cmdlist = pr->cmdlist;
break;
}
#else
log_debug("XXX: command parser conversion not done for command option default %s",
oe->name);
#endif
break;
default:
ov->number = oe->default_num;
@@ -436,7 +442,6 @@ options_array_set(struct options_entry *o, u_int idx, const char *value,
{
struct options_array_item *a;
char *new;
struct cmd_parse_result *pr;
long long number;
if (!OPTIONS_IS_ARRAY(o)) {
@@ -453,6 +458,9 @@ options_array_set(struct options_entry *o, u_int idx, const char *value,
}
if (OPTIONS_IS_COMMAND(o)) {
#if 0 /* XXX: command parser conversion */
struct cmd_parse_result *pr;
pr = cmd_parse_from_string(value, NULL);
switch (pr->status) {
case CMD_PARSE_ERROR:
@@ -472,6 +480,13 @@ options_array_set(struct options_entry *o, u_int idx, const char *value,
options_value_free(o, &a->value);
a->value.cmdlist = pr->cmdlist;
return (0);
#else
if (cause != NULL) {
xasprintf(cause,
"XXX: command parser conversion not done for command option array");
}
return (-1);
#endif
}
if (OPTIONS_IS_STRING(o)) {
@@ -1131,7 +1146,6 @@ options_from_string(struct options *oo, const struct options_table_entry *oe,
const char *errstr, *new;
char *old;
key_code key;
struct cmd_parse_result *pr;
if (oe != NULL) {
if (value == NULL &&
@@ -1190,6 +1204,9 @@ options_from_string(struct options *oo, const struct options_table_entry *oe,
case OPTIONS_TABLE_CHOICE:
return (options_from_string_choice(oe, oo, name, value, cause));
case OPTIONS_TABLE_COMMAND:
#if 0 /* XXX: command parser conversion */
struct cmd_parse_result *pr;
pr = cmd_parse_from_string(value, NULL);
switch (pr->status) {
case CMD_PARSE_ERROR:
@@ -1200,6 +1217,11 @@ options_from_string(struct options *oo, const struct options_table_entry *oe,
return (0);
}
break;
#else
xasprintf(cause,
"XXX: command parser conversion not done for command option");
return (-1);
#endif
}
return (-1);
}

View File

@@ -2578,8 +2578,6 @@ server_client_dispatch_command(struct client *c, struct imsg *imsg)
size_t len;
int argc = 0;
char **argv, *cause;
struct cmd_parse_result *pr;
struct args_value *values;
struct cmdq_item *new_item;
if (c->flags & CLIENT_EXIT)
@@ -2604,6 +2602,10 @@ server_client_dispatch_command(struct client *c, struct imsg *imsg)
new_item = cmdq_get_callback(server_client_default_command,
NULL);
} else {
#if 0 /* XXX: command parser conversion */
struct cmd_parse_result *pr;
struct args_value *values;
values = args_from_vector(argc, argv);
pr = cmd_parse_from_arguments(values, argc, NULL);
switch (pr->status) {
@@ -2623,6 +2625,11 @@ server_client_dispatch_command(struct client *c, struct imsg *imsg)
} else
new_item = cmdq_get_command(pr->cmdlist, NULL);
cmd_list_free(pr->cmdlist);
#else
cause = xstrdup(
"XXX: command parser conversion not done for client commands");
goto error;
#endif
}
cmdq_append(c, new_item);
cmdq_append(c, cmdq_get_callback(server_client_command_done, NULL));

View File

@@ -1218,7 +1218,6 @@ window_customize_set_command_callback(struct client *c, void *itemdata,
struct window_customize_itemdata *item = itemdata;
struct window_customize_modedata *data = item->data;
struct key_binding *bd;
struct cmd_parse_result *pr;
char *error;
if (s == NULL || *s == '\0' || data->dead)
@@ -1226,6 +1225,9 @@ window_customize_set_command_callback(struct client *c, void *itemdata,
if (item == NULL || !window_customize_get_key(item, NULL, &bd))
return (PROMPT_CLOSE);
#if 0 /* XXX: command parser conversion */
struct cmd_parse_result *pr;
pr = cmd_parse_from_string(s, NULL);
switch (pr->status) {
case CMD_PARSE_ERROR:
@@ -1240,6 +1242,10 @@ window_customize_set_command_callback(struct client *c, void *itemdata,
mode_tree_build(data->data);
mode_tree_draw(data->data);
data->wp->flags |= PANE_REDRAW;
#else
error = xstrdup("XXX: command parser conversion not done for customize");
goto fail;
#endif
return (PROMPT_CLOSE);

View File

@@ -434,7 +434,9 @@ window_switch_run_command(struct window_switch_modedata *data, struct client *c)
char *target = NULL;
struct cmdq_state *state;
char *command, *error;
#if 0 /* XXX: command parser conversion */
enum cmd_parse_status status;
#endif
if (data->matches_size == 0)
return (0);
@@ -466,6 +468,7 @@ window_switch_run_command(struct window_switch_modedata *data, struct client *c)
command = cmd_template_replace(data->command, target, 1);
if (command != NULL && *command != '\0') {
state = cmdq_new_state(&fs, NULL, 0);
#if 0 /* XXX: command parser conversion */
status = cmd_parse_and_append(command, NULL, c, state, &error);
if (status == CMD_PARSE_ERROR) {
if (c != NULL) {
@@ -474,6 +477,14 @@ window_switch_run_command(struct window_switch_modedata *data, struct client *c)
}
free(error);
}
#else
error = xstrdup("XXX: command parser conversion not done for window switch");
if (c != NULL) {
*error = toupper((u_char)*error);
status_message_set(c, -1, 1, 0, 0, "%s", error);
}
free(error);
#endif
cmdq_free_state(state);
}
free(command);