]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
i9e: Constify completer arrays. master
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 2 Jun 2025 21:25:47 +0000 (23:25 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 10 Jun 2025 13:25:48 +0000 (15:25 +0200)
This way the array of completers goes into the rodata section.

audioc.c
client.c
interactive.c
interactive.h
play.c

index 996459f90029d83be54441cd591fdb883218be2d..36f9f040101ca74afcbf6b3eacc7a917516a20dd 100644 (file)
--- a/audioc.c
+++ b/audioc.c
@@ -84,7 +84,7 @@ struct audioc_task {
        struct task *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);
 
 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);
 }
 
        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
 #define LSG_AUDIOD_CMD_CMD(_name) {.name = #_name, \
        .completer = _name ## _completer}
        LSG_AUDIOD_CMD_SUBCOMMANDS
index 77d0d2b584ea005b70f0fc4d3bc96ff6271b0b05..a5a8af5337ea67310a01332a9f02b22c389c0442 100644 (file)
--- a/client.c
+++ b/client.c
@@ -242,7 +242,7 @@ I9E_DUMMY_COMPLETER(stop);
 I9E_DUMMY_COMPLETER(addatt);
 I9E_DUMMY_COMPLETER(init);
 
 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)
 
 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;
 }
 
        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
 #define LSG_SERVER_CMD_CMD(_name) {.name = #_name, \
        .completer = _name ## _completer}
        LSG_SERVER_CMD_SUBCOMMANDS
index 3f8b265d89603f18b78dd085a110074305c704d7..52a24b17c9b6e58ca524cb54546735dcdfa52c3a 100644 (file)
@@ -96,7 +96,7 @@ static void reset_completion_result(struct i9e_completion_result *cr)
 }
 
 static void create_matches(struct i9e_completion_info *ci,
 }
 
 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;
                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;
 {
        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,
        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().
  */
  *
  * \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;
 {
        char **matches;
        const char *cmd;
@@ -734,7 +734,7 @@ void i9e_complete_option(char **opts, struct i9e_completion_info *ci,
  *
  * \return Standard.
  */
  *
  * \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;
 {
        struct i9e_completion_result cr;
        struct i9e_completion_info ci;
index 1dbaaddbe4fdb3d855284b91b2dde4ba49d26782..015d8a9275ac3c9ff972c539c8cf154993b70abd 100644 (file)
@@ -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.
         */
         * 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.
        /**
         * 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);
 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);
 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);
 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 815dc60990d5cf14dc41187f8f2b702642471cbb..a43a1e53301a21e118d51b682dad0ec7116355f3 100644 (file)
--- a/play.c
+++ b/play.c
@@ -642,7 +642,7 @@ static char **get_mapped_keyseqs(void)
        return result;
 }
 
        return result;
 }
 
-static struct i9e_completer pp_completers[];
+static const struct i9e_completer pp_completers[];
 
 I9E_DUMMY_COMPLETER(jmp);
 I9E_DUMMY_COMPLETER(next);
 
 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);
 }
 
        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
 #define LSG_PLAY_CMD_CMD(_name) {.name = #_name, \
        .completer = _name ## _completer}
        LSG_PLAY_CMD_SUBCOMMANDS