From: Andre Noll Date: Mon, 2 Jun 2025 21:25:47 +0000 (+0200) Subject: i9e: Constify completer arrays. X-Git-Url: https://git.tuebingen.mpg.de/?a=commitdiff_plain;h=231c2dda1c9f13df1d956dd2790992689b3f4838;p=paraslash.git i9e: Constify completer arrays. This way the array of completers goes into the rodata section. --- diff --git a/audioc.c b/audioc.c index 996459f9..36f9f040 100644 --- a/audioc.c +++ b/audioc.c @@ -84,7 +84,7 @@ struct audioc_task { struct task *task; }; -static struct i9e_completer audiod_completers[]; +static const struct i9e_completer audiod_completers[]; I9E_DUMMY_COMPLETER(cycle); I9E_DUMMY_COMPLETER(off); @@ -139,7 +139,7 @@ static void grab_completer(struct i9e_completion_info *ci, i9e_complete_option(opts, ci, cr); } -static struct i9e_completer audiod_completers[] = { +static const struct i9e_completer audiod_completers[] = { #define LSG_AUDIOD_CMD_CMD(_name) {.name = #_name, \ .completer = _name ## _completer} LSG_AUDIOD_CMD_SUBCOMMANDS diff --git a/client.c b/client.c index 77d0d2b5..a5a8af53 100644 --- a/client.c +++ b/client.c @@ -242,7 +242,7 @@ I9E_DUMMY_COMPLETER(stop); I9E_DUMMY_COMPLETER(addatt); I9E_DUMMY_COMPLETER(init); -static struct i9e_completer completers[]; +static const struct i9e_completer completers[]; static void ll_completer(struct i9e_completion_info *ci, struct i9e_completion_result *cr) @@ -505,7 +505,7 @@ static int client_i9e_line_handler(char *line) return 1; } -static struct i9e_completer completers[] = { +static const struct i9e_completer completers[] = { #define LSG_SERVER_CMD_CMD(_name) {.name = #_name, \ .completer = _name ## _completer} LSG_SERVER_CMD_SUBCOMMANDS diff --git a/interactive.c b/interactive.c index 3f8b265d..52a24b17 100644 --- a/interactive.c +++ b/interactive.c @@ -96,7 +96,7 @@ static void reset_completion_result(struct i9e_completion_result *cr) } static void create_matches(struct i9e_completion_info *ci, - struct i9e_completer *completers, + const struct i9e_completer *completers, struct i9e_completion_result *cr) { int i, ret; @@ -126,7 +126,7 @@ static char *completion_generator(const char *word, int state) { static int list_index; static char **argv, **matches; - struct i9e_completer *completers = i9ep->ici->completers; + const struct i9e_completer *completers = i9ep->ici->completers; struct i9e_completion_info ci = { .word = (char *)word, .point = rl_point, @@ -665,7 +665,7 @@ int i9e_extract_completions(const char *word, char **string_list, * * \return See \ref i9e_extract_completions(). */ -char **i9e_complete_commands(const char *word, struct i9e_completer *completers) +char **i9e_complete_commands(const char *word, const struct i9e_completer *completers) { char **matches; const char *cmd; @@ -734,7 +734,7 @@ void i9e_complete_option(char **opts, struct i9e_completion_info *ci, * * \return Standard. */ -int i9e_print_completions(struct i9e_completer *completers) +int i9e_print_completions(const struct i9e_completer *completers) { struct i9e_completion_result cr; struct i9e_completion_info ci; diff --git a/interactive.h b/interactive.h index 1dbaaddb..015d8a92 100644 --- a/interactive.h +++ b/interactive.h @@ -70,7 +70,7 @@ struct i9e_client_info { * completing the first word (the command) and for calling the right * completer if the cursor is not on the first word. */ - struct i9e_completer *completers; + const struct i9e_completer *completers; /** * If non-NULL, this node is attached immediately to the stdout btr * node of the i9e subsystem. @@ -87,10 +87,10 @@ __printf_2_3 void i9e_log(int ll, const char* fmt,...); int i9e_poll(struct pollfd *fds, nfds_t nfds, int timeout); int i9e_extract_completions(const char *word, char **string_list, char ***result); -char **i9e_complete_commands(const char *word, struct i9e_completer *completers); +char **i9e_complete_commands(const char *word, const struct i9e_completer *completers); void i9e_complete_option(char **opts, struct i9e_completion_info *ci, struct i9e_completion_result *cr); -int i9e_print_completions(struct i9e_completer *completers); +int i9e_print_completions(const struct i9e_completer *completers); int i9e_get_error(void); void i9e_ll_completer(struct i9e_completion_info *ci, struct i9e_completion_result *cr); diff --git a/play.c b/play.c index 815dc609..a43a1e53 100644 --- a/play.c +++ b/play.c @@ -642,7 +642,7 @@ static char **get_mapped_keyseqs(void) return result; } -static struct i9e_completer pp_completers[]; +static const struct i9e_completer pp_completers[]; I9E_DUMMY_COMPLETER(jmp); I9E_DUMMY_COMPLETER(next); @@ -669,7 +669,7 @@ static void help_completer(struct i9e_completion_info *ci, cr->matches = i9e_complete_commands(ci->word, pp_completers); } -static struct i9e_completer pp_completers[] = { +static const struct i9e_completer pp_completers[] = { #define LSG_PLAY_CMD_CMD(_name) {.name = #_name, \ .completer = _name ## _completer} LSG_PLAY_CMD_SUBCOMMANDS