finch/libgnt/gntentry.c

changeset 34306
4fb8809f2f97
parent 31294
73607ab89c6f
child 35379
ea1a0327001e
child 35456
821aa4bcb6fa
equal deleted inserted replaced
34305:5804117fb298 34306:4fb8809f2f97
182 182
183 static gboolean 183 static gboolean
184 show_suggest_dropdown(GntEntry *entry) 184 show_suggest_dropdown(GntEntry *entry)
185 { 185 {
186 char *suggest = NULL; 186 char *suggest = NULL;
187 int len; 187 gsize len;
188 int offset = 0, x, y; 188 int offset = 0, x, y;
189 int count = 0; 189 int count = 0;
190 GList *iter; 190 GList *iter;
191 const char *text = NULL; 191 const char *text = NULL;
192 const char *sgst = NULL; 192 const char *sgst = NULL;
813 { 813 {
814 const char *str, *next; 814 const char *str, *next;
815 815
816 for (str = text; *str; str = next) 816 for (str = text; *str; str = next)
817 { 817 {
818 int len; 818 gsize len;
819 next = g_utf8_find_next_char(str, NULL); 819 next = g_utf8_find_next_char(str, NULL);
820 len = next - str; 820 len = next - str;
821 821
822 /* Valid input? */ 822 /* Valid input? */
823 /* XXX: Is it necessary to use _unichar_ variants here? */ 823 /* XXX: Is it necessary to use _unichar_ variants here? */
832 832
833 /* Reached the max? */ 833 /* Reached the max? */
834 if (entry->max && g_utf8_pointer_to_offset(entry->start, entry->end) >= entry->max) 834 if (entry->max && g_utf8_pointer_to_offset(entry->start, entry->end) >= entry->max)
835 continue; 835 continue;
836 836
837 if (entry->end + len - entry->start >= entry->buffer) 837 if ((gsize)(entry->end + len - entry->start) >= entry->buffer)
838 { 838 {
839 /* This will cause the buffer to grow */ 839 /* This will cause the buffer to grow */
840 char *tmp = g_strdup(entry->start); 840 char *tmp = g_strdup(entry->start);
841 gnt_entry_set_text_internal(entry, tmp); 841 gnt_entry_set_text_internal(entry, tmp);
842 g_free(tmp); 842 g_free(tmp);
1182 1182
1183 void gnt_entry_add_to_history(GntEntry *entry, const char *text) 1183 void gnt_entry_add_to_history(GntEntry *entry, const char *text)
1184 { 1184 {
1185 g_return_if_fail(entry->history != NULL); /* Need to set_history_length first */ 1185 g_return_if_fail(entry->history != NULL); /* Need to set_history_length first */
1186 1186
1187 if (g_list_length(entry->history) >= entry->histlength) 1187 if (entry->histlength >= 0 &&
1188 g_list_length(entry->history) >= (gsize)entry->histlength)
1189 {
1188 return; 1190 return;
1191 }
1189 1192
1190 entry->history = g_list_first(entry->history); 1193 entry->history = g_list_first(entry->history);
1191 g_free(entry->history->data); 1194 g_free(entry->history->data);
1192 entry->history->data = g_strdup(text); 1195 entry->history->data = g_strdup(text);
1193 entry->history = g_list_prepend(entry->history, NULL); 1196 entry->history = g_list_prepend(entry->history, NULL);

mercurial