From ad843755c305b089dcba5ebd3c43946c4b4f3723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Sun, 4 Oct 2015 20:27:08 +0200 Subject: [PATCH] Fix issue in the diplaying of the chat messages The end of messages containing at least one hypertext link was not displayed --- gtk/chat.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gtk/chat.c b/gtk/chat.c index bd878e897..9991fb8e9 100644 --- a/gtk/chat.c +++ b/gtk/chat.c @@ -166,6 +166,7 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from, struct tm *tm; int tnow_day; int tnow_year; + int pos = 0, start, end; gtk_text_buffer_get_end_iter(buffer, &iter); if (g_strcmp0(from_message,from_str)!=0){ @@ -180,17 +181,15 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from, ms_free(from_str); // Inserts message body and tags URIs as hypertext links - if(g_regex_match(uri_regex, message, 0, &match_info)) { - int pos = 0, start, end; - do { - g_match_info_fetch_pos(match_info, 0, &start, &end); - if(pos < start) write_body(buffer, &iter, &message[pos], start-pos, me, FALSE); - write_body(buffer, &iter, &message[start], end-start, me, TRUE); - pos = end; - } while(g_match_info_next(match_info, NULL)); - } else { - write_body(buffer, &iter, message, -1, me, FALSE); + g_regex_match(uri_regex, message, 0, &match_info); + while(g_match_info_matches(match_info)) { + g_match_info_fetch_pos(match_info, 0, &start, &end); + if(pos < start) write_body(buffer, &iter, &message[pos], start-pos, me, FALSE); + write_body(buffer, &iter, &message[start], end-start, me, TRUE); + pos = end; + g_match_info_next(match_info, NULL); } + if(pos < strlen(message)) write_body(buffer, &iter, &message[pos], -1, me, FALSE); gtk_text_buffer_insert(buffer,&iter,"\n",-1); g_match_info_free(match_info);