diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/chatwin.c | 2 | ||||
-rw-r--r-- | src/ui/confwin.c | 2 | ||||
-rw-r--r-- | src/ui/inputwin.c | 8 | ||||
-rw-r--r-- | src/ui/mucwin.c | 16 | ||||
-rw-r--r-- | src/ui/ui.h | 2 |
5 files changed, 16 insertions, 14 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/confwin.c b/src/ui/confwin.c index 85abe748..a49b7010 100644 --- a/src/ui/confwin.c +++ b/src/ui/confwin.c @@ -70,7 +70,7 @@ confwin_show_form(ProfConfWin* confwin) win_println(window, THEME_DEFAULT, "-", "%s", value); } } else if (g_strcmp0(field->type, "hidden") != 0 && field->var) { - char* tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var); + gchar* tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var); _confwin_form_field(window, tag, field); } 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/mucwin.c b/src/ui/mucwin.c index 550b05e2..a2c31421 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -391,7 +391,7 @@ _mucwin_print_mention(ProfWin* window, const char* const message, const char* co while (curr) { pos = GPOINTER_TO_INT(curr->data); - char* before_str = g_utf8_substring(message, last_pos, pos); + auto_gchar gchar* before_str = g_utf8_substring(message, last_pos, pos); if (last_pos == 0 && strncmp(before_str, "/me ", 4) == 0) { win_print_them(window, THEME_ROOMMENTION, ch, flags, ""); @@ -404,11 +404,9 @@ _mucwin_print_mention(ProfWin* window, const char* const message, const char* co } win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str); } - g_free(before_str); - char* mynick_str = g_utf8_substring(message, pos, pos + mynick_len); + auto_gchar gchar* mynick_str = g_utf8_substring(message, pos, pos + mynick_len); win_append_highlight(window, THEME_ROOMMENTION_TERM, "%s", mynick_str); - g_free(mynick_str); last_pos = pos + mynick_len; @@ -418,7 +416,7 @@ _mucwin_print_mention(ProfWin* window, const char* const message, const char* co glong message_len = g_utf8_strlen(message, -1); if (last_pos < message_len) { // get tail without allocating a new string - char* rest = g_utf8_offset_to_pointer(message, last_pos); + gchar* rest = g_utf8_offset_to_pointer(message, last_pos); win_appendln_highlight(window, THEME_ROOMMENTION, "%s", rest); } else { win_appendln_highlight(window, THEME_ROOMMENTION, ""); @@ -449,15 +447,15 @@ _mucwin_print_triggers(ProfWin* window, const char* const message, GList* trigge curr = g_list_next(curr); } - char* message_lower = g_utf8_strdown(message, -1); + auto_gchar gchar* message_lower = g_utf8_strdown(message, -1); // find earliest trigger in message int first_trigger_pos = -1; int first_trigger_len = -1; curr = weighted_triggers; while (curr) { - char* trigger_lower = g_utf8_strdown(curr->data, -1); - char* trigger_ptr = g_strstr_len(message_lower, -1, trigger_lower); + auto_gchar gchar* trigger_lower = g_utf8_strdown(curr->data, -1); + gchar* trigger_ptr = g_strstr_len(message_lower, -1, trigger_lower); // not found, try next if (trigger_ptr == NULL) { @@ -472,11 +470,9 @@ _mucwin_print_triggers(ProfWin* window, const char* const message, GList* trigge first_trigger_len = strlen(trigger_lower); } - g_free(trigger_lower); curr = g_list_next(curr); } - g_free(message_lower); g_list_free(weighted_triggers); // no triggers found 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); |