about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2023-05-12 08:40:51 +0200
committerGitHub <noreply@github.com>2023-05-12 08:40:51 +0200
commit879525c61b8ec540279a58cffe19dd2fab668c2f (patch)
tree7f05070275d5cc3405cbe9ca7f7305a9aeaf8151 /src/ui
parentf3265565e853ecf993f12093c6a0c94acf3f212e (diff)
parentd8eea87f6001ef6ba1b2b4c127a6b090ed00226e (diff)
downloadprofani-tty-879525c61b8ec540279a58cffe19dd2fab668c2f.tar.gz
Merge pull request #1848 from profanity-im/minor-improvements
Minor improvements
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/chatwin.c2
-rw-r--r--src/ui/inputwin.c8
-rw-r--r--src/ui/ui.h2
3 files changed, 9 insertions, 3 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index 0c540998..b470dbd6 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -598,7 +598,7 @@ _chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid)
 // first entry's timestamp in the buffer is used. Flip true to prepend to buffer.
 // Timestamps should be in iso8601
 gboolean
-chatwin_db_history(ProfChatWin* chatwin, char* start_time, char* end_time, gboolean flip)
+chatwin_db_history(ProfChatWin* chatwin, const char* start_time, char* end_time, gboolean flip)
 {
     if (!end_time) {
         end_time = buffer_size(((ProfWin*)chatwin)->layout->buffer) == 0 ? NULL : g_date_time_format_iso8601(buffer_get_entry(((ProfWin*)chatwin)->layout->buffer, 0)->time);
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index bc689d5f..9b652f1c 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -36,6 +36,7 @@
 #define _XOPEN_SOURCE_EXTENDED
 #include "config.h"
 
+#include <assert.h>
 #include <stdio.h>
 #include <sys/select.h>
 #include <stdlib.h>
@@ -140,6 +141,11 @@ static int _inp_rl_send_to_editor(int count, int key);
 void
 create_input_window(void)
 {
+    /* MB_CUR_MAX is evaluated at runtime depending on the current
+     * locale, therefore we check that our own version is big enough
+     * and bail out if it isn't.
+     */
+    assert(MB_CUR_MAX <= PROF_MB_CUR_MAX);
 #ifdef NCURSES_REENTRANT
     set_escdelay(25);
 #else
@@ -331,7 +337,7 @@ _inp_write(char* line, int offset)
 
     for (size_t i = 0; line[i] != '\0'; i++) {
         char* c = &line[i];
-        char retc[MB_CUR_MAX];
+        char retc[PROF_MB_CUR_MAX] = { 0 };
 
         size_t ch_len = mbrlen(c, MB_CUR_MAX, NULL);
         if ((ch_len == (size_t)-2) || (ch_len == (size_t)-1)) {
diff --git a/src/ui/ui.h b/src/ui/ui.h
index d9534ed5..79fafd75 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -145,7 +145,7 @@ void chatwin_set_incoming_char(ProfChatWin* chatwin, const char* const ch);
 void chatwin_unset_incoming_char(ProfChatWin* chatwin);
 void chatwin_set_outgoing_char(ProfChatWin* chatwin, const char* const ch);
 void chatwin_unset_outgoing_char(ProfChatWin* chatwin);
-gboolean chatwin_db_history(ProfChatWin* chatwin, char* start_time, char* end_time, gboolean flip);
+gboolean chatwin_db_history(ProfChatWin* chatwin, const char* start_time, char* end_time, gboolean flip);
 
 // MUC window
 ProfMucWin* mucwin_new(const char* const barejid);