diff options
author | John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> | 2023-04-19 02:44:19 +0200 |
---|---|---|
committer | John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> | 2023-05-04 16:15:09 +0200 |
commit | 7f3fca2bd081a729d425184f7a0484025862257e (patch) | |
tree | 20f1cd78bf48f7d6ceb95bb0262faf691001bcf9 /src/ui | |
parent | faccf24c759d7bddb4d3062c7f044e0c7640ffe7 (diff) | |
download | profani-tty-7f3fca2bd081a729d425184f7a0484025862257e.tar.gz |
Cleanup: gchar as gchar instead of char
Use gchar instead of char in most of the cases where gchar is intended. Reason: improve compatibility and stability. Issue #1819 Minor refactoring.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/confwin.c | 2 | ||||
-rw-r--r-- | src/ui/mucwin.c | 16 |
2 files changed, 7 insertions, 11 deletions
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/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 |