Index: /lang/cplusplus/i3/src/LibintlUtf16le.cpp
===================================================================
--- /lang/cplusplus/i3/src/LibintlUtf16le.cpp (revision 16633)
+++ /lang/cplusplus/i3/src/LibintlUtf16le.cpp (revision 16635)
@@ -3,63 +3,63 @@
 
 namespace i3 {
-namespace ascii_to_utf16 {
-boost::ptr_map<const char*, const boost::uint16_t*> cache;
-const boost::uint16_t error_default[] = {0,0,0,0,0}; // what is invalid value?
+    namespace ascii_to_utf16 {
+        boost::ptr_map<const char*, const boost::uint16_t*> cache;
+        const boost::uint16_t error_default[] = {0,0,0,0,0}; // what is invalid value?
 
 #ifdef MOL_OS_WINDOWSAA
-class lock {
-    static LONG mutex;
-public:
-    lock() {
-        while (InterlockedExchange(&mutex, 0)) {
-            Sleep(100);
-        }
-    }
-    ~lock() {
-        InterlockedExchange(&mutex, 1);
-    }
-};
-LONG lock::mutex = 1;
-const boost::uint16_t* convert(const char* msgid) {
-    // �L���b�V�����
-    {
-        const boost::uint16_t* cached = NULL;
-        {
-            lock l;
-            cached = cache[msgid];
-        }
-        if (cached) {
-            return cached;
-        }
-    }
-
-    // �Ȃ�����������ăL���b�V���ɕۑ�
-    {
-        // �ϊ����        boost::array<wchar_t,2000> wideCharStr = {{}};	//XXX2000!!!
-        // XXX error?
-        int result = MultiByteToWideChar(
-                         CP_THREAD_ACP,  //XXX codepage??
-                         MB_PRECOMPOSED, // �����̎���肷�����O
-                         msgid,
-                         -1,// �}�b�v��������o�C�g��
-                         &wideCharStr[0],  // �}�b�v�惏�C�h�������o�b�t�@�̃A�h���X
-                         wideCharStr.size());        // XXX size type
-
-        if (result == 0) {
-            return error_default;
-        }
-        const wchar_t* w = _wcsdup(wideCharStr.data());
-        if (w == NULL) {
-            return error_default;
-        }
-
-        // �ϊ��ɐ���       {
-            lock l;
-            cache[msgid] = reinterpret_cast<const boost::uint16_t*>(w);
-        }
-        return reinterpret_cast<const boost::uint16_t*>(w);
-    }
-}
-#else
+        class lock {
+            static LONG mutex;
+        public:
+            lock() {
+                while (InterlockedExchange(&mutex, 0)) {
+                    Sleep(100);
+                }
+            }
+            ~lock() {
+                InterlockedExchange(&mutex, 1);
+            }
+        };
+        LONG lock::mutex = 1;
+        const boost::uint16_t* convert(const char* msgid) {
+            // �L���b�V�����
+            {
+                const boost::uint16_t* cached = NULL;
+                {
+                    lock l;
+                    cached = cache[msgid];
+                }
+                if (cached) {
+                    return cached;
+                }
+            }
+
+            // �Ȃ�����������ăL���b�V���ɕۑ�
+            {
+                // �ϊ����                boost::array<wchar_t,2000> wideCharStr = {{}};	//XXX2000!!!
+                // XXX error?
+                int result = MultiByteToWideChar(
+                    CP_THREAD_ACP,  //XXX codepage??
+                    MB_PRECOMPOSED, // �����̎���肷�����O
+                    msgid,
+                    -1,// �}�b�v��������o�C�g��
+                    &wideCharStr[0],  // �}�b�v�惏�C�h�������o�b�t�@�̃A�h���X
+                    wideCharStr.size());        // XXX size type
+
+                if (result == 0) {
+                    return error_default;
+                }
+                const wchar_t* w = _wcsdup(wideCharStr.data());
+                if (w == NULL) {
+                    return error_default;
+                }
+
+                // �ϊ��ɐ���               {
+                    lock l;
+                    cache[msgid] = reinterpret_cast<const boost::uint16_t*>(w);
+                }
+                return reinterpret_cast<const boost::uint16_t*>(w);
+            }
+        }
+#else //MOL_OS_WINDOWSAA
 #include <stdio.h>
 #include <string.h>
@@ -68,110 +68,109 @@
 
 // �߂��͏������񂾃o�C�g��
-unsigned int cdn_convert(ICONV_CONST char* in_buf, char* out_buf,
-             size_t out_buf_bytes,
-             const char* in_encoding,
-             const char* out_encoding)
-{
-    char* out_buf_backup;
-    iconv_t cd;
-    size_t in_bytes_left, out_bytes_left;
-    int result;
-    out_buf_backup = out_buf;
-    in_bytes_left = strlen(in_buf);
-
-    // NULL�I�[�̗̈��󂯂邽�߁Aout_buf�̃T�C�Y��   // ��ۂ�1�o�C�g���Ȃ��Ƃ����l�ɂ��Ă���
-    out_bytes_left = out_buf_bytes-1; 
-
-    cd = iconv_open(out_encoding, in_encoding);
-
-    // iconv_open�Ŏw�肵���G���R�[�f�B���O�ŕϊ����
-    // �ϊ�����������(in|out)_buf�̃|�C���^���
-    // (in|out)_bytes_left��炷
-    result = iconv(cd, &in_buf, &in_bytes_left,
-                       &out_buf, &out_bytes_left);
-    if (result == -1) {
-        // �G���[�̏������        return 0;
+        unsigned int cdn_convert(ICONV_CONST char* in_buf, char* out_buf,
+                                 size_t out_buf_bytes,
+                                 const char* in_encoding,
+                                 const char* out_encoding)
+        {
+            char* out_buf_backup;
+            iconv_t cd;
+            size_t in_bytes_left, out_bytes_left;
+            int result;
+            out_buf_backup = out_buf;
+            in_bytes_left = strlen(in_buf);
+
+            // NULL�I�[�̗̈��󂯂邽�߁Aout_buf�̃T�C�Y��           // ��ۂ�1�o�C�g���Ȃ��Ƃ����l�ɂ��Ă���
+            out_bytes_left = out_buf_bytes-1; 
+
+            cd = iconv_open(out_encoding, in_encoding);
+
+            // iconv_open�Ŏw�肵���G���R�[�f�B���O�ŕϊ����
+            // �ϊ�����������(in|out)_buf�̃|�C���^���
+            // (in|out)_bytes_left��炷
+            result = iconv(cd, &in_buf, &in_bytes_left,
+                           &out_buf, &out_bytes_left);
+            if (result == -1) {
+                // �G���[�̏������                return 0;
+            }
+
+            // �o�̓G���R�[�f�B���O��stateful�ȏꍇ��
+            // state��ɖ߂��V�[�P���X���
+            result = iconv(cd, NULL, NULL,
+                           &out_buf, &out_bytes_left);
+            if (result == -1) {
+                // �G���[�̏������                return 0;
+            }
+
+            // iconv()�ɂ�out_buf��
+            // �ϊ��㕶����[�̎�����悤�ɕύX��������            *out_buf = '\0';
+
+            iconv_close(cd);
+
+            // XXX KIKENN!!??
+            return static_cast<unsigned int>(out_buf - out_buf_backup);
+        }
+
+        const boost::uint16_t* convert(const char* msgid) {
+            // �L���b�V�����    
+            const boost::uint16_t* cached = NULL;
+            {
+                cached = cache[msgid];// XXX lock!
+            }
+            if (cached) {
+                return cached;
+            }
+
+            // �Ȃ��̂ŕϊ�
+            // ���̂�������������������댯������肷���z�C��
+            char buf[2000]; //XXX2000!!!
+
+            // XXXXXXXXXXXXXXXXXX
+            char* d = strdup(msgid);
+            if (!d) {
+                return error_default;
+            }
+//    unsigned int bytes = cdn_convert(msgid, buf, sizeof(buf), 
+            unsigned int bytes = cdn_convert(d, buf, sizeof(buf), 
+                                             "ASCII", "UTF-16LE");
+            free(d);
+            // XXXXXXXXXXXXXXXXXX
+
+            using namespace std;
+            if (!bytes) {
+                return error_default;
+            }
+
+            char* new_buf = (char*)calloc(bytes +2, 1);
+            if (!new_buf) {
+                return error_default;
+            }
+            memcpy(new_buf, buf, bytes);
+            new_buf[bytes] = 0; //NULL�I�[
+            new_buf[bytes+1] = 0;
+
+            {
+                cache[msgid] = reinterpret_cast<const boost::uint16_t*>(new_buf); // XXX lock!
+            }
+            return reinterpret_cast<const boost::uint16_t*>(new_buf);
+        }
+#endif //MOL_OS_WINDOWSAA
+
     }
 
-    // �o�̓G���R�[�f�B���O��stateful�ȏꍇ��
-    // state��ɖ߂��V�[�P���X���
-    result = iconv(cd, NULL, NULL,
-                       &out_buf, &out_bytes_left);
-    if (result == -1) {
-        // �G���[�̏������        return 0;
+    const boost::uint16_t* utf16_gettext(const char* msgid) {
+        const char* translated = gettext(msgid);
+        if (translated != msgid) {
+            return reinterpret_cast<const boost::uint16_t*>(translated);
+        }
+        return ascii_to_utf16::convert(msgid);
     }
 
-    // iconv()�ɂ�out_buf��
-    // �ϊ��㕶����[�̎�����悤�ɕύX��������    *out_buf = '\0';
-
-    iconv_close(cd);
-
-    // XXX KIKENN!!??
-    return static_cast<unsigned int>(out_buf - out_buf_backup);
-}
-
-const boost::uint16_t* convert(const char* msgid) {
-    // �L���b�V�����    
-    const boost::uint16_t* cached = NULL;
-    {
-        cached = cache[msgid];// XXX lock!
-    }
-    if (cached) {
-        return cached;
-    }
-
-    // �Ȃ��̂ŕϊ�
-    // ���̂�������������������댯������肷���z�C��
-    char buf[2000]; //XXX2000!!!
-
-    // XXXXXXXXXXXXXXXXXX
-    char* d = strdup(msgid);
-    if (!d) {
-        return error_default;
-    }
-//    unsigned int bytes = cdn_convert(msgid, buf, sizeof(buf), 
-    unsigned int bytes = cdn_convert(d, buf, sizeof(buf), 
-                                     "ASCII", "UTF-16LE");
-    free(d);
-    // XXXXXXXXXXXXXXXXXX
-
-    using namespace std;
-    if (!bytes) {
-        return error_default;
-    }
-
-    char* new_buf = (char*)calloc(bytes +2, 1);
-    if (!new_buf) {
-        return error_default;
-    }
-    memcpy(new_buf, buf, bytes);
-    new_buf[bytes] = 0; //NULL�I�[
-    new_buf[bytes+1] = 0;
-
-    {
-        cache[msgid] = reinterpret_cast<const boost::uint16_t*>(new_buf); // XXX lock!
-    }
-    return reinterpret_cast<const boost::uint16_t*>(new_buf);
-}
-#endif
-
-
-}
-
-const boost::uint16_t* utf16_gettext(const char* msgid) {
-    const char* translated = gettext(msgid);
-    if (translated != msgid) {
-        return reinterpret_cast<const boost::uint16_t*>(translated);
-    }
-    return ascii_to_utf16::convert(msgid);
-}
-
 #ifdef MOL_OS_WINDOWS
 
-char windows_locale_dir[2000] = {};
-char* windows_locale_dir_ = windows_locale_dir;
-
-void init_windows_gettext() {
-    using namespace std;
+    char windows_locale_dir[2000] = {};
+    char* windows_locale_dir_ = windows_locale_dir;
+
+    void init_windows_gettext() {
+        using namespace std;
 
 #undef printf
@@ -182,43 +181,43 @@
 #endif
 
-    //XXX abort???
-    //XXX MAX_PATH safe???
-    DWORD result = GetModuleFileNameA(
-                       GetModuleHandleA(NULL),
-                       windows_locale_dir,
-                       sizeof(windows_locale_dir));
-
-    if (result == 0 || result == sizeof(windows_locale_dir)) { // error
-        mol_abort();
+        //XXX abort???
+        //XXX MAX_PATH safe???
+        DWORD result = GetModuleFileNameA(
+            GetModuleHandleA(NULL),
+            windows_locale_dir,
+            sizeof(windows_locale_dir));
+
+        if (result == 0 || result == sizeof(windows_locale_dir)) { // error
+            mol_abort();
+        }
+        if (PathRemoveFileSpecA(windows_locale_dir) == FALSE) {
+            mol_abort();
+        }
+        if (PathAppendA(windows_locale_dir,"locale") == FALSE) {
+            mol_abort();
+        }
+
+        cout << "setlocale: " << setlocale(LC_ALL, "") << endl;
+        cout << "bindtextdomain: " << bindtextdomain(PACKAGE_NAME, LOCALEDIR) << endl;
+#if defined(UNICODE) || defined(_UNICODE)
+        cout << "bind_textdomain_codeset: " << bind_textdomain_codeset(PACKAGE_NAME,"UTF-16LE") << endl;
+#endif
+        cout << "textdomain: " << textdomain(PACKAGE_NAME) << endl;
+
+#ifdef MOL_GUI_WINDOWS
+        const TCHAR* j = _("Japanese");
+        cout << "Japanese = [" << flush;
+        for (int i=0; ((char*)j)[i]; i++) {
+            printf("%2x ", (char)(((char*)j)[i]));
+        }
+        cout << "]" << endl;
+
+        tcout << _T("Hello, the world: ") << _("Hello, the world.") << endl;
+        tcout << _T("The quick brown fox jumps over the lazy dog: ") << _("The quick brown fox jumps over the lazy dog") << endl;
+        tcout << _T("URYYYYYYYYYYYYYYYYYYYYYY: ") << _("URYYYYYYYYYYYYYYYYYYYYYY") << endl;
+#endif
     }
-    if (PathRemoveFileSpecA(windows_locale_dir) == FALSE) {
-        mol_abort();
-    }
-    if (PathAppendA(windows_locale_dir,"locale") == FALSE) {
-        mol_abort();
-    }
-
-    cout << "setlocale: " << setlocale(LC_ALL, "") << endl;
-    cout << "bindtextdomain: " << bindtextdomain(PACKAGE_NAME, LOCALEDIR) << endl;
-#if defined(UNICODE) || defined(_UNICODE)
-    cout << "bind_textdomain_codeset: " << bind_textdomain_codeset(PACKAGE_NAME,"UTF-16LE") << endl;
-#endif
-    cout << "textdomain: " << textdomain(PACKAGE_NAME) << endl;
-
-#ifdef MOL_GUI_WINDOWS
-    const TCHAR* j = _("Japanese");
-    cout << "Japanese = [" << flush;
-    for (int i=0; ((char*)j)[i]; i++) {
-        printf("%2x ", (char)(((char*)j)[i]));
-    }
-    cout << "]" << endl;
-
-    tcout << _T("Hello, the world: ") << _("Hello, the world.") << endl;
-    tcout << _T("The quick brown fox jumps over the lazy dog: ") << _("The quick brown fox jumps over the lazy dog") << endl;
-    tcout << _T("URYYYYYYYYYYYYYYYYYYYYYY: ") << _("URYYYYYYYYYYYYYYYYYYYYYY") << endl;
-#endif
 }
-}
-
-#endif
-
+
+#endif
+
