Re: Bug#317549: tin: Linebreaks between words when lines are longer than window width
Michael Bienia <[email protected]>
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Message-ID | <[email protected]> |
On 2005-07-10 02:23:51 +0200, Urs JanÃen wrote: > On Sat, Jul 09, 2005 at 08:04:35PM +0200, Urs JanÃen wrote: > > > There is a small issue related to this though. tin generates a warning > > > when a line in a composed message exceeds 78 characters. It's good > > > feature but actually it counts bytes not characters. I use UTF-8 locale > > > and messages often contain multibyte characters. Even when I save my > > > message with no longer lines than 72 characters I get this warning from > > > lines which contain enough multibyte characters to exceed the limit of 78 > > > bytes per line. > > > > yes, this is a bug in post.c:check_article_to_be_posted() ~ line 1118 > > the code is much older than tins multibyte support and when we added > > the multibyte stuff we failed to update that bits of code as well... > > something like the following (untested) should fix this: Attached is an improvement which also counts the width of the char instead of assuming it fits into one column. Michael
patch-20040713.diff
(text/plain, 870 B)
diff -Nurp tin-1.7.9/src/post.c tin-1.7.9.new/src/post.c
--- tin-1.7.9/src/post.c 2005-07-13 13:58:50.889106485 +0200
+++ tin-1.7.9.new/src/post.c 2005-07-13 14:19:19.118330081 +0200
@@ -1122,7 +1122,7 @@ check_article_to_be_posted(
{
#if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
- int num_bytes;
+ int num_bytes, wc_width;
wchar_t wc;
#endif /* MULTIBYTE_ABLE && !NO_LOCALE */
@@ -1137,14 +1137,21 @@ check_article_to_be_posted(
cp += num_bytes;
if (!contains_8bit && num_bytes > 1)
contains_8bit = TRUE;
- } else
+
+ if (iswprint(wc) && (wc_width = wcwidth(wc)) != -1)
+ col += wc_width;
+ else
+ col++;
+ } else {
cp++;
+ col++;
+ }
#else
if (!contains_8bit && !isascii(*cp))
contains_8bit = TRUE;
cp++;
+ col++;
#endif
- col++;
}
}
}