aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-07-18 01:12:45 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-07-18 01:12:45 +0300
commit45b9dea901cec7045be1a98f61d48d41dc965a9f (patch)
treed3d09c2340f815ae17820ce46fc677f8d9c5d6d2 /src
parent3a2583e918bcc805fe860252f8a520fc2f9b26ce (diff)
downloadsciteco-45b9dea901cec7045be1a98f61d48d41dc965a9f.tar.gz
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"`.
Diffstat (limited to 'src')
-rw-r--r--src/interface-curses/interface.c4
-rw-r--r--src/interface-gtk/interface.c2
-rw-r--r--src/qreg.c2
-rw-r--r--src/view.c2
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",