diff options
author | Stanislav Brabec <utx@penguin.cz> | 2009-02-23 15:14:35 +0000 |
---|---|---|
committer | utx@penguin.cz <utx@penguin.cz> | 2009-02-23 15:14:35 +0000 |
commit | 2598f7b63e147f15f07a2b66d89fd97863196993 (patch) | |
tree | 596c59ca735d3a062a45aed44f4481e0d513fd87 /packages/mc/mc-4.6.2/00-70-utf8-common.patch | |
parent | a7653f0e9ca08570b88dc35c9e9866eb64818ce8 (diff) |
mc: Updated to 4.6.2 + openSUSE and Debian UTF-8 patches.
Diffstat (limited to 'packages/mc/mc-4.6.2/00-70-utf8-common.patch')
-rw-r--r-- | packages/mc/mc-4.6.2/00-70-utf8-common.patch | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/packages/mc/mc-4.6.2/00-70-utf8-common.patch b/packages/mc/mc-4.6.2/00-70-utf8-common.patch new file mode 100644 index 0000000000..244a01580a --- /dev/null +++ b/packages/mc/mc-4.6.2/00-70-utf8-common.patch @@ -0,0 +1,46 @@ +Some common stuff used by other UTF-8 patches. + +================================================================================ +--- mc-4.6.2/src/util.c ++++ mc-4.6.2/src/util.c +@@ -145,6 +145,30 @@ + return strlen (str); + } + ++int ++columns_to_bytes (const char *str, int col) ++{ ++ int bytes = 0; ++ int columns = 0; ++ int i; ++#ifdef UTF8 ++ if (SLsmg_Is_Unicode) { ++ static mbstate_t s; ++ while (columns < col) { ++ memset (&s, 0, sizeof (s)); ++ i = mbrlen (str + bytes, -1, &s); ++ if (i <= 0) { ++ return col + bytes - columns; ++ } ++ bytes += i; ++ columns ++; ++ } ++ return col + bytes - columns; ++ } else ++#endif ++ return col; ++} ++ + #ifdef UTF8 + + void +--- mc-4.6.2/src/util.h ++++ mc-4.6.2/src/util.h +@@ -104,6 +104,7 @@ + + void fix_utf8(char *str); + size_t mbstrlen (const char *); ++int columns_to_bytes (const char *, int); + wchar_t *mbstr_to_wchar (const char *); + char *wchar_to_mbstr (const wchar_t *); + char *utf8_to_local(char *str); |