Wrap utf-8 patch.
- From: "nshmyrev" <nshmyrev yandex ru>
- To: balsa-list gnome org
- Subject: Wrap utf-8 patch.
- Date: Fri, 14 Mar 2003 19:41:33 +0300 (MSK)
Hello all.
There is 9!!! bug-fix versions of balsa since balsa 2 is out. But wrong wrapping with utf-8 symbols is not corrected!
Apply patch to do this.
_____________________________
Index: balsa/libbalsa/misc.c
===================================================================
RCS file: /cvs/gnome/balsa/libbalsa/misc.c,v
retrieving revision 1.100
diff -u -r1.100 misc.c
--- balsa/libbalsa/misc.c 4 Mar 2003 16:26:05 -0000 1.100
+++ balsa/libbalsa/misc.c 14 Mar 2003 16:33:39 -0000
@@ -358,11 +350,17 @@
libbalsa_wrap_string(gchar * str, int width)
{
const int minl = width / 2;
- gchar *lnbeg, *sppos, *ptr;
+
+ gchar *space_pos, *ptr;
gint te = 0;
+ gint ptr_offset, line_begin_offset, space_pos_offset;
+
g_return_if_fail(str != NULL);
- lnbeg = sppos = ptr = str;
+
+
+ line_begin_offset = ptr_offset = space_pos_offset = 0;
+ space_pos = ptr = str;
while (*ptr) {
switch (*ptr) {
@@ -370,19 +368,22 @@
te += 7;
break;
case '\n':
- lnbeg = ptr + 1;
+ line_begin_offset = ptr_offset + 1;
te = 0;
break;
case ' ':
- sppos = ptr;
+ space_pos = ptr;
+ space_pos_offset = ptr_offset;
break;
}
- if (ptr - lnbeg >= width - te && sppos >= lnbeg + minl) {
- *sppos = '\n';
- lnbeg = sppos + 1;
+ if (ptr_offset - line_begin_offset >= width - te
+ && space_pos_offset >= line_begin_offset + minl) {
+ *space_pos = '\n';
+ line_begin_offset = space_pos_offset + 1;
te = 0;
}
- ptr++;
+ ptr=g_utf8_next_char(ptr);
+ ptr_offset++;
}
}
@@ -543,16 +542,16 @@
* one word per inner loop
* */
while (*str) {
while (*str && !isspace((int)*str) && len < max_width) {
len++;
- str++;
+ str=g_utf8_next_char(str);
}
while (len < max_width && isspace((int)*str)) {
if (*str == '\t')
len += 8 - len % 8;
else
len++;
- str++;
+ str=g_utf8_next_char(str);;
}
/*
* to avoid some unnecessary space-stuffing,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]