From 45b9dea901cec7045be1a98f61d48d41dc965a9f Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 18 Jul 2025 01:12:45 +0300 Subject: make some array declarations real constants * `static const char *p = "FOO"` is not a true constant since the variable p can still be changed. It has to be declared as `static const char *const p = "FOO"`, so that the pointer itself is constant. * In case of string constants, it's easier however to use `static const char p[] = "FOO"`. --- src/interface-curses/interface.c | 4 ++-- src/interface-gtk/interface.c | 2 +- src/qreg.c | 2 +- src/view.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index 127e0b6..770062e 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -1518,7 +1518,7 @@ teco_interface_set_clipboard(const gchar *name, const gchar *str, gsize str_len, if (teco_interface_osc52_is_enabled()) return teco_interface_osc52_set_clipboard(name, str, str_len, error); - static const gchar *reg_name = "$SCITECO_CLIPBOARD_SET"; + static const gchar reg_name[] = "$SCITECO_CLIPBOARD_SET"; teco_qreg_t *reg = teco_qreg_table_find(&teco_qreg_table_globals, reg_name, strlen(reg_name)); if (!reg) { @@ -1579,7 +1579,7 @@ teco_interface_get_clipboard(const gchar *name, gchar **str, gsize *len, GError if (teco_interface_osc52_is_enabled()) return teco_interface_osc52_get_clipboard(name, str, len, error); - static const gchar *reg_name = "$SCITECO_CLIPBOARD_GET"; + static const gchar reg_name[] = "$SCITECO_CLIPBOARD_GET"; teco_qreg_t *reg = teco_qreg_table_find(&teco_qreg_table_globals, reg_name, strlen(reg_name)); if (!reg) { diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c index b2316bc..973225e 100644 --- a/src/interface-gtk/interface.c +++ b/src/interface-gtk/interface.c @@ -1224,7 +1224,7 @@ teco_interface_event_loop(GError **error) * This is not necessary on Windows since the icon included * as a resource will be used by default. */ - static const gchar *icon_files[] = { + static const gchar *const icon_files[] = { "sciteco-48.png", "sciteco-32.png", "sciteco-16.png" }; GList *icon_list = NULL; diff --git a/src/qreg.c b/src/qreg.c index 67cc19c..c8c4614 100644 --- a/src/qreg.c +++ b/src/qreg.c @@ -1341,7 +1341,7 @@ teco_ed_hook(teco_ed_hook_t type, GError **error) return teco_expressions_discard_args(error) && teco_expressions_brace_close(error); - static const gchar *type2name[] = { + static const gchar *const type2name[] = { [TECO_ED_HOOK_ADD-1] = "ADD", [TECO_ED_HOOK_EDIT-1] = "EDIT", [TECO_ED_HOOK_CLOSE-1] = "CLOSE", diff --git a/src/view.c b/src/view.c index 972828a..0fc1986 100644 --- a/src/view.c +++ b/src/view.c @@ -149,7 +149,7 @@ TECO_DEFINE_UNDO_CALL(teco_view_ssm, teco_view_t *, unsigned int, uptr_t, sptr_t void teco_view_set_representations(teco_view_t *ctx) { - static const char *reps[] = { + static const gchar reps[][4] = { "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "TAB" /* ^I */, "LF" /* ^J */, "^K", "^L", "CR" /* ^M */, "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W", -- cgit v1.2.3