ToDo:
XIM入力を含めFreeBSD+X.org環境の不具合は概ね原因特定・パッチ完了〜
残る問題は、
あと、ports運用上ストレスになる問題
--- lib/libiconv_modules/UTF8/citrus_utf8.c.orig +++ lib/libiconv_modules/UTF8/citrus_utf8.c @@ -116,7 +116,9 @@ typedef struct { char ch[6]; } _UTF8State; -typedef void *_UTF8EncodingInfo; +typedef struct { + bool ms; +} _UTF8EncodingInfo; #define _CEI_TO_EI(_cei_) (&(_cei_)->ei) #define _CEI_TO_STATE(_ei_, _func_) (_ei_)->states.s_##_func_ @@ -149,6 +151,35 @@ _UTF8_surrogate(wchar_t wc) return (wc >= 0xd800 && wc <= 0xdfff); } +static __inline wchar_t +_UTF8_ms_map(wchar_t wc, bool to_utf8_ms) +{ + switch(wc) { + case 0x301c: return to_utf8_ms ? 0xff5e : wc; + case 0xff5e: return to_utf8_ms ? wc : 0x301c; + + case 0x2016: return to_utf8_ms ? 0x2225 : wc; + case 0x2225: return to_utf8_ms ? wc : 0x2016; + + case 0x2212: return to_utf8_ms ? 0xff0d : wc; + case 0xff0d: return to_utf8_ms ? wc : 0x2212; + + case 0x00a2: return to_utf8_ms ? 0xffe0 : wc; + case 0xffe0: return to_utf8_ms ? wc : 0x00a2; + + case 0x00a3: return to_utf8_ms ? 0xffe1 : wc; + case 0xffe1: return to_utf8_ms ? wc : 0x00a3; + + case 0x00ac: return to_utf8_ms ? 0xffe2 : wc; + case 0xffe2: return to_utf8_ms ? wc : 0x00ac; + + case 0x2014: return to_utf8_ms ? 0x2015 : wc; + case 0x2015: return to_utf8_ms ? wc : 0x2014; + + default: return wc; + } +} + static __inline void /*ARGSUSED*/ _citrus_UTF8_init_state(_UTF8EncodingInfo *ei __unused, _UTF8State *s) @@ -223,6 +254,9 @@ _citrus_UTF8_mbrtowc_priv(_UTF8EncodingInfo *ei, wchar_t *pwc, char **s, if (_UTF8_surrogate(wchar) || _UTF8_findlen(wchar) != c) goto ilseq; } + if(ei->ms) { + wchar = _UTF8_ms_map(wchar, true); + } if (pwc != NULL) *pwc = wchar; *nresult = (wchar == 0) ? 0 : s0 - *s; @@ -242,13 +276,16 @@ _citrus_UTF8_mbrtowc_priv(_UTF8EncodingInfo *ei, wchar_t *pwc, char **s, } static int -_citrus_UTF8_wcrtomb_priv(_UTF8EncodingInfo *ei __unused, char *s, size_t n, +_citrus_UTF8_wcrtomb_priv(_UTF8EncodingInfo *ei, char *s, size_t n, wchar_t wc, _UTF8State *psenc __unused, size_t *nresult) { wchar_t c; size_t cnt; int i, ret; + if(ei->ms) { + wc = _UTF8_ms_map(wc, false); + } if (_UTF8_surrogate(wc)) { ret = EILSEQ; goto err; @@ -326,12 +363,35 @@ _citrus_UTF8_stdenc_get_state_desc_generic(_UTF8EncodingInfo * __restrict ei __u return (0); } +static void +parse_variable(_UTF8EncodingInfo * __restrict ei, + const void * __restrict var, size_t lenvar) +{ + const char *p; + + p = var; + while (lenvar > 0) { + switch (*p) { + case 'M': + case 'm': + MATCH(ms, ei->ms = true); + break; + } + p++; + lenvar--; + } +} + static int /*ARGSUSED*/ -_citrus_UTF8_encoding_module_init(_UTF8EncodingInfo * __restrict ei __unused, +_citrus_UTF8_encoding_module_init(_UTF8EncodingInfo * __restrict ei, const void * __restrict var __unused, size_t lenvar __unused) { + memset((void *)ei, 0, sizeof(*ei)); + + parse_variable(ei, var, lenvar); + return (0); } --- share/i18n/esdb/UTF/Makefile.orig +++ share/i18n/esdb/UTF/Makefile @@ -25,6 +25,8 @@ UTF-32-SWAPPED-mod= UTF1632 UTF-32-SWAPPED-var= utf32,swapped,force UTF-8-mod= UTF8 UTF-8-var= utf8 +UTF-8-MS-mod= UTF8 +UTF-8-MS-var= utf8,ms UTF-7-mod= UTF7 UTF-7-var= utf7 --- share/i18n/esdb/UTF/UTF.part.orig +++ share/i18n/esdb/UTF/UTF.part @@ -2,6 +2,7 @@ 7 8 +8-MS 16 16BE 16LE
一応、Windows側のUnicode符号位置の利用状況を許容して、FreeBSD側でEUC-JP互換なUnicode符号位置でSambaを運用する準備が出来たはず…
カテゴリー: Admin | Emacs | EPICS | Fortran | FreeBSD | GCC | hgsubversion | IPv6 | KEKB | LHC | Lisp | LLVM | MADX | Ryzen | SAD | samba | tDiary | unix | WWW | YaSAI | お仕事 | イベント | 出張 | 宴会 | 数学 | 艦これ | 買いもの | 追記 | 雑記