Some common stuff used by other UTF-8 patches.
diff -Naurdp mc-4.6.1.orig/src/util.c mc-4.6.1/src/util.c
old
|
new
|
mbstrlen (const char *str) |
113 | 113 | return strlen (str); |
114 | 114 | } |
115 | 115 | |
| 116 | int |
| 117 | columns_to_bytes (const char *str, int col) |
| 118 | { |
| 119 | int bytes = 0; |
| 120 | int columns = 0; |
| 121 | int i; |
| 122 | #ifdef UTF8 |
| 123 | if (SLsmg_Is_Unicode) { |
| 124 | static mbstate_t s; |
| 125 | while (columns < col) { |
| 126 | memset (&s, 0, sizeof (s)); |
| 127 | i = mbrlen (str + bytes, -1, &s); |
| 128 | if (i <= 0) { |
| 129 | return col + bytes - columns; |
| 130 | } |
| 131 | bytes += i; |
| 132 | columns ++; |
| 133 | } |
| 134 | return col + bytes - columns; |
| 135 | } else |
| 136 | #endif |
| 137 | return col; |
| 138 | } |
| 139 | |
116 | 140 | #ifdef UTF8 |
117 | 141 | |
118 | 142 | void |
diff -Naurdp mc-4.6.1.orig/src/util.h mc-4.6.1/src/util.h
old
|
new
|
char *get_owner (int); |
95 | 95 | |
96 | 96 | void fix_utf8(char *str); |
97 | 97 | size_t mbstrlen (const char *); |
| 98 | int columns_to_bytes (const char *, int); |
98 | 99 | wchar_t *mbstr_to_wchar (const char *); |
99 | 100 | char *wchar_to_mbstr (const wchar_t *); |
100 | 101 | char *utf8_to_local(char *str); |