summaryrefslogtreecommitdiff
path: root/ui/tap-sequence-analysis.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2013-11-12 17:02:17 +0000
committerGerald Combs <gerald@wireshark.org>2013-11-12 17:02:17 +0000
commit89db79a6aa686cb98d30618a7d6ec594000353b7 (patch)
treed3c27e9284f1e17cbdaf09d8980723e1258d5138 /ui/tap-sequence-analysis.c
parent76bfa2ce1af4867baf4f6990ac233d04a1b3af23 (diff)
downloadwireshark-89db79a6aa686cb98d30618a7d6ec594000353b7.tar.gz
When we dump a sequence diagram to text, make sure labels are truncated.
svn path=/trunk/; revision=53275
Diffstat (limited to 'ui/tap-sequence-analysis.c')
-rw-r--r--ui/tap-sequence-analysis.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/ui/tap-sequence-analysis.c b/ui/tap-sequence-analysis.c
index bf1b5e95fb..dfbf2f3c3b 100644
--- a/ui/tap-sequence-analysis.c
+++ b/ui/tap-sequence-analysis.c
@@ -305,6 +305,8 @@ static void overwrite (GString *gstr, char *text_to_insert, guint32 p1, guint32
gsize len;
gsize pos;
+ gsize ins_len;
+ gchar *ins_str = NULL;
if (p1 == p2)
return;
@@ -318,20 +320,22 @@ static void overwrite (GString *gstr, char *text_to_insert, guint32 p1, guint32
len = p2 - p1;
}
- if (len > strlen(text_to_insert)) {
- len = strlen(text_to_insert);
+ ins_len = g_utf8_strlen(text_to_insert, -1);
+ if (len > ins_len) {
+ len = ins_len;
+ } else if (len < ins_len) {
+ ins_str = g_utf8_substring(text_to_insert, 0, len);
}
+ if (!ins_str) ins_str = g_strdup(text_to_insert);
+
if (pos > gstr->len)
pos = gstr->len;
- /* ouch this is ugly but gtk1 needs it */
- if ((pos + len) > gstr->len)
- g_string_truncate(gstr, pos);
- else
- g_string_erase(gstr, pos, len);
+ g_string_erase(gstr, pos, len);
- g_string_insert(gstr, pos, text_to_insert);
+ g_string_insert(gstr, pos, ins_str);
+ g_free(ins_str);
}
/* Return the index array if the node is in the array. Return -1 if there is room in the array