mc/mc-CVS-msglen.patch

33 lines
812 B
Diff

--- mc-4.6.1a-20041209/src/util.c.msglen 2004-12-15 11:41:12.477680704 +0100
+++ mc-4.6.1a-20041209/src/util.c 2004-12-15 12:50:23.006704384 +0100
@@ -198,16 +198,25 @@ is_printable (int c)
/* Returns the message dimensions (lines and columns) */
int msglen (const char *text, int *lines)
{
- int max = 0;
- int line_len = 0;
+ size_t max = 0, line_len = 0;
for (*lines = 1;*text; text++){
if (*text == '\n'){
line_len = 0;
(*lines)++;
} else {
- line_len++;
- if (line_len > max)
+#ifdef UTF8
+ size_t len;
+ wchar_t c;
+
+ len = mbrtowc (&c, text, MB_CUR_MAX, NULL);
+ if (len > 0) {
+ int wcsize = wcwidth(c);
+ line_len += wcsize > 0 ? wcsize-1 : -1;
+ text += len-1;
+ }
+#endif
+ if (++line_len > max)
max = line_len;
}
}