Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,21 @@ str_xml_sanitize(const char* const str)
return g_string_free(sanitized, FALSE);
}

gint
str_ascii_casecmp0(const char* s1, const char* s2)
{
if (s1 == s2) {
return 0;
}
if (s1 == NULL) {
return -1;
}
if (s2 == NULL) {
return 1;
}
return g_ascii_strcasecmp(s1, s2);
}

char*
release_get_latest(void)
{
Expand Down
1 change: 1 addition & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ char* str_replace(const char* string, const char* substr, const char* replacemen
gboolean strtoi_range(const char* str, int* saveptr, int min, int max, char** err_msg);
int utf8_display_len(const char* const str);
gchar* str_xml_sanitize(const char* const str);
gint str_ascii_casecmp0(const char* s1, const char* s2);

gboolean string_matches_one_of(const char* what, const char* is, gboolean is_can_be_null, const char* first, ...) __attribute__((sentinel));
gboolean valid_tls_policy_option(const char* is);
Expand Down
7 changes: 5 additions & 2 deletions src/ui/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -2002,8 +2002,11 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
_win_indent(win, indent + pad_indent);
}

gchar copy[wordi + 1];
g_utf8_strncpy(copy, word_ch, 1);
gchar* next = g_utf8_next_char(word_ch);
gsize bytes_to_copy = next - word_ch;
gchar copy[bytes_to_copy + 1];
memcpy(copy, word_ch, bytes_to_copy);
copy[bytes_to_copy] = '\0';
waddstr(win, copy);

word_ch = g_utf8_next_char(word_ch);
Expand Down
6 changes: 3 additions & 3 deletions src/ui/window_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ wins_get_chat(const char* const barejid)
ProfWin* window = curr->data;
if (window->type == WIN_CHAT) {
ProfChatWin* chatwin = (ProfChatWin*)window;
if (g_strcmp0(chatwin->barejid, barejid) == 0) {
if (str_ascii_casecmp0(chatwin->barejid, barejid) == 0) {
return chatwin;
}
}
Expand Down Expand Up @@ -147,7 +147,7 @@ wins_get_conf(const char* const roomjid)
ProfWin* window = curr->data;
if (window->type == WIN_CONFIG) {
ProfConfWin* confwin = (ProfConfWin*)window;
if (g_strcmp0(confwin->roomjid, roomjid) == 0) {
if (str_ascii_casecmp0(confwin->roomjid, roomjid) == 0) {
return confwin;
}
}
Expand All @@ -166,7 +166,7 @@ wins_get_muc(const char* const roomjid)
ProfWin* window = curr->data;
if (window->type == WIN_MUC) {
ProfMucWin* mucwin = (ProfMucWin*)window;
if (g_strcmp0(mucwin->roomjid, roomjid) == 0) {
if (str_ascii_casecmp0(mucwin->roomjid, roomjid) == 0) {
return mucwin;
}
}
Expand Down
Loading