updated on Wed Jan 11 20:01:35 UTC 2012
[aur-mirror.git] / mc-suse / 00-70-utf8-common.patch
blob88ae606ef8cec0bf32357bd70be8553e21861ad1
1 Some common stuff used by other UTF-8 patches.
3 ================================================================================
4 --- mc-4.6.2-pre1/src/util.c
5 +++ mc-4.6.2-pre1/src/util.c
6 @@ -140,6 +140,30 @@
7 return strlen (str);
10 +int
11 +columns_to_bytes (const char *str, int col)
13 + int bytes = 0;
14 + int columns = 0;
15 + int i;
16 +#ifdef UTF8
17 + if (SLsmg_Is_Unicode) {
18 + static mbstate_t s;
19 + while (columns < col) {
20 + memset (&s, 0, sizeof (s));
21 + i = mbrlen (str + bytes, -1, &s);
22 + if (i <= 0) {
23 + return col + bytes - columns;
24 + }
25 + bytes += i;
26 + columns ++;
27 + }
28 + return col + bytes - columns;
29 + } else
30 +#endif
31 + return col;
34 #ifdef UTF8
36 void
37 --- mc-4.6.2-pre1/src/util.h
38 +++ mc-4.6.2-pre1/src/util.h
39 @@ -105,6 +105,7 @@
41 void fix_utf8(char *str);
42 size_t mbstrlen (const char *);
43 +int columns_to_bytes (const char *, int);
44 wchar_t *mbstr_to_wchar (const char *);
45 char *wchar_to_mbstr (const wchar_t *);
46 char *utf8_to_local(char *str);