Changeset 36013
- Timestamp:
- 11/28/09 00:01:25 (3 years ago)
- Location:
- lang/objective-cplusplus/i3/trunk
- Files:
-
- 2 added
- 12 modified
-
po/POTFILES.in (modified) (2 diffs)
-
src/Mediator.cpp (modified) (2 diffs)
-
src/Mediator.h (modified) (2 diffs)
-
src/Tester.cpp (added)
-
src/Tester.h (added)
-
src/mil/include/mil/ModuleCommon.h (modified) (1 diff)
-
src/mil/include/mil/Synchronize.h (modified) (1 diff)
-
src/mil/include/mil/gui-windows/WindowProcedureRedirector.h (modified) (1 diff)
-
src/os-windows/msvc/iconv.h (modified) (1 diff)
-
src/os-windows/msvc/win_iconv.c (modified) (80 diffs)
-
windows/i3_test.vcproj (modified) (7 diffs)
-
windows/mil_test.vcproj (modified) (4 diffs)
-
windows/mingw.sh (modified) (1 diff)
-
windows/release.sh (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/objective-cplusplus/i3/trunk/po/POTFILES.in
r35922 r36013 9 9 src/gui-windows/Gui.h 10 10 src/gui-windows/InputWindowPlatform.h 11 src/gui-windows/OutputWindowPlatform.h 11 12 src/Initial.h 12 13 src/InputWindow.h … … 52 53 src/mil/include/xbyak/xbyak_bin2hex.h 53 54 src/mil/include/xbyak/xbyak_mnemonic.h 54 src/mil/src/profile/Profile.h55 55 src/mil/src/test/Test.h 56 56 src/os-unix/Os.h -
lang/objective-cplusplus/i3/trunk/src/Mediator.cpp
r35976 r36013 24 24 shellManager.start(); 25 25 delegate.start(); 26 #ifdef I3_TEST 27 inputWindow.start(); 28 Tester tester(*this); 29 tester.run(); 30 #else 26 31 inputWindow.run(); 32 #endif 33 27 34 #else 28 35 // no threaded gui … … 35 42 debug << "before loop"; 36 43 44 #ifdef I3_TEST 45 Tester tester(*this); 46 tester.start(); 47 #endif 48 37 49 global_loop(); 38 50 #endif 39 delegate.destroy(); 51 40 52 return 0; 41 53 } -
lang/objective-cplusplus/i3/trunk/src/Mediator.h
r34497 r36013 10 10 #include "Delegate.h" 11 11 #include "ShellManager.h" 12 13 #ifdef TEST_HEADER14 #include BOOST_PP_STRINGIZE(TEST_HEADER)15 #endif16 12 17 13 namespace i3 { … … 36 32 } 37 33 38 #ifdef TEST_HEADER 39 #undef CompletionWindow 40 #undef InputWindow 41 #undef OutputWindow 42 #undef ShellManager 43 #undef Delegate 34 #ifdef I3_TEST 35 #include <quicktest/quicktest.h> 36 #include "Tester.h" 44 37 #endif 45 38 -
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/ModuleCommon.h
r35976 r36013 145 145 MIL_CRTP_CLASS_MEMBERS; 146 146 147 template <class Event> 148 void beforeExecute(Event& event) { 149 } 150 151 template <class Event> 152 void afterExecute(Event& event) { 153 } 154 147 155 ModuleCommon() : tls(this->thread_id) { 148 156 set_auto_join(&MIL_MODULE_GET_SUPER_CHILD(*this)); -
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/Synchronize.h
r35685 r36013 203 203 204 204 #define synchronized(mutex) \ 205 for(mil::SynchronizeHelper synchronize_helper_instance__##mutex (mutex); (synchronize_helper_instance__##mutex ).process();) 206 205 for (mil::SynchronizeHelper synchronize_helper_instance__##mutex (mutex); \ 206 (synchronize_helper_instance__##mutex ).process();) 207 -
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-windows/WindowProcedureRedirector.h
r34448 r36013 2 2 #include "../Mil.h" 3 3 #include "../MscCrt.h" 4 #include "../Serial.h" 5 4 6 #include <windows.h> 5 #include "../Serial.h"6 7 7 8 #ifndef _WIN32_WCE -
lang/objective-cplusplus/i3/trunk/src/os-windows/msvc/iconv.h
r25302 r36013 12 12 #endif 13 13 14 typedef void* iconv_t;15 iconv_t iconv_open(const char *tocode, const char *fromcode);16 int iconv_close(iconv_t cd);17 size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);14 typedef void* iconv_t; 15 iconv_t iconv_open(const char *tocode, const char *fromcode); 16 int iconv_close(iconv_t cd); 17 size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); 18 18 19 19 #ifdef __cplusplus -
lang/objective-cplusplus/i3/trunk/src/os-windows/msvc/win_iconv.c
r35623 r36013 64 64 #if defined(MAKE_DLL) 65 65 int 66 iconvctl (iconv_t cd, int request, void* argument) { 66 iconvctl (iconv_t cd, int request, void* argument) 67 { 67 68 /* not supported */ 68 69 return 0; … … 408 409 {500, "IBM500"}, /* IBM EBCDIC International */ 409 410 {708, "ASMO-708"}, /* Arabic (ASMO 708) */ 410 /* 709 Arabic (ASMO-449+, BCON V4) */411 /* 710 Arabic - Transparent Arabic */411 /* 709 Arabic (ASMO-449+, BCON V4) */ 412 /* 710 Arabic - Transparent Arabic */ 412 413 {720, "DOS-720"}, /* Arabic (Transparent ASMO); Arabic (DOS) */ 413 414 {737, "ibm737"}, /* OEM Greek (formerly 437G); Greek (DOS) */ … … 507 508 {20949, "x-cp20949"}, /* Korean Wansung */ 508 509 {21025, "cp1025"}, /* IBM EBCDIC Cyrillic Serbian-Bulgarian */ 509 /* 21027 (deprecated) */510 /* 21027 (deprecated) */ 510 511 {21866, "koi8-u"}, /* Ukrainian (KOI8-U); Cyrillic (KOI8-U) */ 511 512 {28591, "iso-8859-1"}, /* ISO 8859-1 Latin 1; Western European (ISO) */ … … 540 541 {50225, "iso2022-kr"}, /* ISO 2022 Korean */ 541 542 {50227, "x-cp50227"}, /* ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022) */ 542 /* 50229 ISO 2022 Traditional Chinese */543 /* 50930 EBCDIC Japanese (Katakana) Extended */544 /* 50931 EBCDIC US-Canada and Japanese */545 /* 50933 EBCDIC Korean Extended and Korean */546 /* 50935 EBCDIC Simplified Chinese Extended and Simplified Chinese */547 /* 50936 EBCDIC Simplified Chinese */548 /* 50937 EBCDIC US-Canada and Traditional Chinese */549 /* 50939 EBCDIC Japanese (Latin) Extended and Japanese */543 /* 50229 ISO 2022 Traditional Chinese */ 544 /* 50930 EBCDIC Japanese (Katakana) Extended */ 545 /* 50931 EBCDIC US-Canada and Japanese */ 546 /* 50933 EBCDIC Korean Extended and Korean */ 547 /* 50935 EBCDIC Simplified Chinese Extended and Simplified Chinese */ 548 /* 50936 EBCDIC Simplified Chinese */ 549 /* 50937 EBCDIC US-Canada and Traditional Chinese */ 550 /* 50939 EBCDIC Japanese (Latin) Extended and Japanese */ 550 551 {51932, "euc-jp"}, /* EUC Japanese */ 551 552 {51936, "EUC-CN"}, /* EUC Simplified Chinese; Chinese Simplified (EUC) */ 552 553 {51949, "euc-kr"}, /* EUC Korean */ 553 /* 51950 EUC Traditional Chinese */554 /* 51950 EUC Traditional Chinese */ 554 555 {52936, "hz-gb-2312"}, /* HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ) */ 555 556 {54936, "GB18030"}, /* Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030) */ … … 673 674 674 675 static int 675 load_mlang() { 676 load_mlang() 677 { 676 678 HMODULE h; 677 679 if (ConvertINetString != NULL) … … 690 692 691 693 iconv_t 692 iconv_open(const char *tocode, const char *fromcode) { 694 iconv_open(const char *tocode, const char *fromcode) 695 { 693 696 rec_iconv_t *cd; 694 697 … … 715 718 716 719 int 717 iconv_close(iconv_t _cd) { 720 iconv_close(iconv_t _cd) 721 { 718 722 rec_iconv_t *cd = (rec_iconv_t *)_cd; 719 723 int r = cd->iconv_close(cd->cd); … … 729 733 730 734 size_t 731 iconv(iconv_t _cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { 735 iconv(iconv_t _cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) 736 { 732 737 rec_iconv_t *cd = (rec_iconv_t *)_cd; 733 738 size_t r = cd->iconv(cd->cd, inbuf, inbytesleft, outbuf, outbytesleft); … … 737 742 738 743 static int 739 win_iconv_open(rec_iconv_t *cd, const char *tocode, const char *fromcode) { 744 win_iconv_open(rec_iconv_t *cd, const char *tocode, const char *fromcode) 745 { 740 746 if (!make_csconv(fromcode, &cd->from) || !make_csconv(tocode, &cd->to)) 741 747 return FALSE; … … 748 754 749 755 static int 750 win_iconv_close(iconv_t cd) { 756 win_iconv_close(iconv_t cd) 757 { 751 758 return 0; 752 759 } 753 760 754 761 static size_t 755 win_iconv(iconv_t _cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { 762 win_iconv(iconv_t _cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) 763 { 756 764 rec_iconv_t *cd = (rec_iconv_t *)_cd; 757 765 ushort wbuf[MB_CHAR_MAX]; /* enough room for one character */ … … 765 773 int i; 766 774 767 if (inbuf == NULL || *inbuf == NULL) { 768 if (outbuf != NULL && *outbuf != NULL && cd->to.flush != NULL) { 775 if (inbuf == NULL || *inbuf == NULL) 776 { 777 if (outbuf != NULL && *outbuf != NULL && cd->to.flush != NULL) 778 { 769 779 tomode = cd->to.mode; 770 780 outsize = cd->to.flush(&cd->to, (uchar *)*outbuf, *outbytesleft); 771 if (outsize == -1) { 781 if (outsize == -1) 782 { 772 783 cd->to.mode = tomode; 773 784 return (size_t)(-1); … … 781 792 } 782 793 783 while (*inbytesleft != 0) { 794 while (*inbytesleft != 0) 795 { 784 796 frommode = cd->from.mode; 785 797 tomode = cd->to.mode; … … 787 799 788 800 insize = cd->from.mbtowc(&cd->from, (const uchar *)*inbuf, *inbytesleft, wbuf, &wsize); 789 if (insize == -1) { 801 if (insize == -1) 802 { 790 803 cd->from.mode = frommode; 791 804 return (size_t)(-1); 792 805 } 793 806 794 if (wsize == 0) { 807 if (wsize == 0) 808 { 795 809 *inbuf += insize; 796 810 *inbytesleft -= insize; … … 798 812 } 799 813 800 if (cd->from.compat != NULL) { 814 if (cd->from.compat != NULL) 815 { 801 816 wc = utf16_to_ucs4(wbuf); 802 817 cp = cd->from.compat; 803 for (i = 0; cp[i].in != 0; ++i) { 804 if ((cp[i].flag & COMPAT_IN) && cp[i].out == wc) { 818 for (i = 0; cp[i].in != 0; ++i) 819 { 820 if ((cp[i].flag & COMPAT_IN) && cp[i].out == wc) 821 { 805 822 ucs4_to_utf16(cp[i].in, wbuf, &wsize); 806 823 break; … … 809 826 } 810 827 811 if (cd->to.compat != NULL) { 828 if (cd->to.compat != NULL) 829 { 812 830 wc = utf16_to_ucs4(wbuf); 813 831 cp = cd->to.compat; 814 for (i = 0; cp[i].in != 0; ++i) { 815 if ((cp[i].flag & COMPAT_OUT) && cp[i].in == wc) { 832 for (i = 0; cp[i].in != 0; ++i) 833 { 834 if ((cp[i].flag & COMPAT_OUT) && cp[i].in == wc) 835 { 816 836 ucs4_to_utf16(cp[i].out, wbuf, &wsize); 817 837 break; … … 821 841 822 842 outsize = cd->to.wctomb(&cd->to, wbuf, wsize, (uchar *)*outbuf, *outbytesleft); 823 if (outsize == -1) { 843 if (outsize == -1) 844 { 824 845 cd->from.mode = frommode; 825 846 cd->to.mode = tomode; … … 837 858 838 859 static int 839 make_csconv(const char *_name, csconv_t *cv) { 860 make_csconv(const char *_name, csconv_t *cv) 861 { 840 862 CPINFOEX cpinfoex; 841 863 int use_compat = TRUE; … … 849 871 850 872 /* check for option "enc_name//opt1//opt2" */ 851 while ((p = strrstr(name, "//")) != NULL) { 873 while ((p = strrstr(name, "//")) != NULL) 874 { 852 875 if (_stricmp(p + 2, "nocompat") == 0) 853 876 use_compat = FALSE; … … 865 888 cv->compat = NULL; 866 889 cv->codepage = name_to_codepage(name); 867 if (cv->codepage == 1200 || cv->codepage == 1201) { 890 if (cv->codepage == 1200 || cv->codepage == 1201) 891 { 868 892 cv->mbtowc = utf16_mbtowc; 869 893 cv->wctomb = utf16_wctomb; 870 894 if (_stricmp(name, "UTF-16") == 0 || _stricmp(name, "UTF16") == 0) 871 895 cv->flags |= FLAG_USE_BOM; 872 } else if (cv->codepage == 12000 || cv->codepage == 12001) { 896 } 897 else if (cv->codepage == 12000 || cv->codepage == 12001) 898 { 873 899 cv->mbtowc = utf32_mbtowc; 874 900 cv->wctomb = utf32_wctomb; 875 901 if (_stricmp(name, "UTF-32") == 0 || _stricmp(name, "UTF32") == 0) 876 902 cv->flags |= FLAG_USE_BOM; 877 } else if (cv->codepage == 65001) { 903 } 904 else if (cv->codepage == 65001) 905 { 878 906 cv->mbtowc = kernel_mbtowc; 879 907 cv->wctomb = kernel_wctomb; 880 908 cv->mblen = utf8_mblen; 881 } else if ((cv->codepage == 50220 || cv->codepage == 50221 || cv->codepage == 50222) && load_mlang()) { 909 } 910 else if ((cv->codepage == 50220 || cv->codepage == 50221 || cv->codepage == 50222) && load_mlang()) 911 { 882 912 cv->mbtowc = iso2022jp_mbtowc; 883 913 cv->wctomb = iso2022jp_wctomb; 884 914 cv->flush = iso2022jp_flush; 885 } else if (cv->codepage == 51932 && load_mlang()) { 915 } 916 else if (cv->codepage == 51932 && load_mlang()) 917 { 886 918 cv->mbtowc = mlang_mbtowc; 887 919 cv->wctomb = mlang_wctomb; 888 920 cv->mblen = eucjp_mblen; 889 } else if (IsValidCodePage(cv->codepage) 890 && GetCPInfoEx(cv->codepage, 0, &cpinfoex) != 0) { 921 } 922 else if (IsValidCodePage(cv->codepage) 923 && GetCPInfoEx(cv->codepage, 0, &cpinfoex) != 0) 924 { 891 925 cv->mbtowc = kernel_mbtowc; 892 926 cv->wctomb = kernel_wctomb; … … 895 929 else if (cpinfoex.MaxCharSize == 2) 896 930 cv->mblen = dbcs_mblen; 897 else 898 cv->mblen = mbcs_mblen; 899 } else { 931 else 932 cv->mblen = mbcs_mblen; 933 } 934 else 935 { 900 936 /* not supported */ 901 937 free(name); … … 904 940 } 905 941 906 if (use_compat) { 907 switch (cv->codepage) { 908 case 932: 909 cv->compat = cp932_compat; 910 break; 911 case 20932: 912 cv->compat = cp20932_compat; 913 break; 914 case 51932: 915 cv->compat = cp51932_compat; 916 break; 917 case 50220: 918 case 50221: 919 case 50222: 920 cv->compat = cp5022x_compat; 921 break; 942 if (use_compat) 943 { 944 switch (cv->codepage) 945 { 946 case 932: cv->compat = cp932_compat; break; 947 case 20932: cv->compat = cp20932_compat; break; 948 case 51932: cv->compat = cp51932_compat; break; 949 case 50220: case 50221: case 50222: cv->compat = cp5022x_compat; break; 922 950 } 923 951 } … … 929 957 930 958 static int 931 name_to_codepage(const char *name) { 959 name_to_codepage(const char *name) 960 { 932 961 int i; 933 962 934 963 if (*name == '\0' || 935 strcmp(name, "char") == 0)964 strcmp(name, "char") == 0) 936 965 return GetACP(); 937 966 else if (strcmp(name, "wchar_t") == 0) … … 954 983 */ 955 984 static uint 956 utf16_to_ucs4(const ushort *wbuf) { 985 utf16_to_ucs4(const ushort *wbuf) 986 { 957 987 uint wc = wbuf[0]; 958 988 if (0xD800 <= wbuf[0] && wbuf[0] <= 0xDBFF) … … 962 992 963 993 static void 964 ucs4_to_utf16(uint wc, ushort *wbuf, int *wbufsize) { 965 if (wc < 0x10000) { 994 ucs4_to_utf16(uint wc, ushort *wbuf, int *wbufsize) 995 { 996 if (wc < 0x10000) 997 { 966 998 wbuf[0] = wc; 967 999 *wbufsize = 1; 968 } else { 1000 } 1001 else 1002 { 969 1003 wc -= 0x10000; 970 1004 wbuf[0] = 0xD800 | ((wc >> 10) & 0x3FF); … … 985 1019 */ 986 1020 static int 987 mbtowc_flags(int codepage) { 1021 mbtowc_flags(int codepage) 1022 { 988 1023 return (codepage == 50220 || codepage == 50221 || 989 codepage == 50222 || codepage == 50225 ||990 codepage == 50227 || codepage == 50229 ||991 codepage == 52936 || codepage == 54936 ||992 (codepage >= 57002 && codepage <= 57011) ||993 codepage == 65000 || codepage == 42) ? 0 : MB_ERR_INVALID_CHARS;1024 codepage == 50222 || codepage == 50225 || 1025 codepage == 50227 || codepage == 50229 || 1026 codepage == 52936 || codepage == 54936 || 1027 (codepage >= 57002 && codepage <= 57011) || 1028 codepage == 65000 || codepage == 42) ? 0 : MB_ERR_INVALID_CHARS; 994 1029 } 995 1030 … … 1003 1038 */ 1004 1039 static int 1005 must_use_null_useddefaultchar(int codepage) { 1040 must_use_null_useddefaultchar(int codepage) 1041 { 1006 1042 return (codepage == 65000 || codepage == 65001 || 1007 1043 codepage == 50220 || codepage == 50221 || … … 1014 1050 1015 1051 static char * 1016 strrstr(const char *str, const char *token) { 1052 strrstr(const char *str, const char *token) 1053 { 1017 1054 int len = strlen(token); 1018 1055 const char *p = str + strlen(str); … … 1025 1062 1026 1063 static char * 1027 xstrndup(const char *s, size_t n) { 1064 xstrndup(const char *s, size_t n) 1065 { 1028 1066 char *p; 1029 1067 … … 1037 1075 1038 1076 static int 1039 seterror(int err) { 1077 seterror(int err) 1078 { 1040 1079 errno = err; 1041 1080 return -1; … … 1044 1083 #if defined(USE_LIBICONV_DLL) 1045 1084 static int 1046 libiconv_iconv_open(rec_iconv_t *cd, const char *tocode, const char *fromcode) { 1085 libiconv_iconv_open(rec_iconv_t *cd, const char *tocode, const char *fromcode) 1086 { 1047 1087 HMODULE hlibiconv = NULL; 1048 1088 HMODULE hmsvcrt = NULL; … … 1061 1101 p = DEFAULT_LIBICONV_DLL; 1062 1102 /* parse comma separated value */ 1063 for ( ; *p != 0; p = (*e == ',') ? e + 1 : e) { 1103 for ( ; *p != 0; p = (*e == ',') ? e + 1 : e) 1104 { 1064 1105 e = strchr(p, ','); 1065 1106 if (p == e) … … 1072 1113 hlibiconv = LoadLibrary(dllname); 1073 1114 free(dllname); 1074 if (hlibiconv != NULL) { 1075 if (hlibiconv == hwiniconv) { 1115 if (hlibiconv != NULL) 1116 { 1117 if (hlibiconv == hwiniconv) 1118 { 1076 1119 FreeLibrary(hlibiconv); 1077 1120 hlibiconv = NULL; … … 1130 1173 #define TO_NT_HEADERS(base) ((PIMAGE_NT_HEADERS)((LPBYTE)(base) + TO_DOS_HEADER(base)->e_lfanew)) 1131 1174 static PVOID 1132 MyImageDirectoryEntryToData(LPVOID Base, BOOLEAN MappedAsImage, USHORT DirectoryEntry, PULONG Size) { 1175 MyImageDirectoryEntryToData(LPVOID Base, BOOLEAN MappedAsImage, USHORT DirectoryEntry, PULONG Size) 1176 { 1133 1177 /* TODO: MappedAsImage? */ 1134 1178 PIMAGE_DATA_DIRECTORY p; 1135 1179 p = TO_NT_HEADERS(Base)->OptionalHeader.DataDirectory + DirectoryEntry; 1136 1180 if (p->VirtualAddress == 0) { 1137 *Size = 0;1138 return NULL;1181 *Size = 0; 1182 return NULL; 1139 1183 } 1140 1184 *Size = p->Size; … … 1143 1187 1144 1188 static HMODULE 1145 find_imported_module_by_funcname(HMODULE hModule, const char *funcname) { 1189 find_imported_module_by_funcname(HMODULE hModule, const char *funcname) 1190 { 1146 1191 DWORD Base; 1147 1192 ULONG Size; … … 1152 1197 Base = (DWORD)hModule; 1153 1198 Imp = MyImageDirectoryEntryToData( 1154 (LPVOID)Base,1155 TRUE,1156 IMAGE_DIRECTORY_ENTRY_IMPORT,1157 &Size);1199 (LPVOID)Base, 1200 TRUE, 1201 IMAGE_DIRECTORY_ENTRY_IMPORT, 1202 &Size); 1158 1203 if (Imp == NULL) 1159 1204 return NULL; 1160 for ( ; Imp->OriginalFirstThunk != 0; ++Imp) { 1205 for ( ; Imp->OriginalFirstThunk != 0; ++Imp) 1206 { 1161 1207 Name = (PIMAGE_THUNK_DATA)(Base + Imp->OriginalFirstThunk); 1162 for ( ; Name->u1.Ordinal != 0; ++Name) { 1163 if (!IMAGE_SNAP_BY_ORDINAL(Name->u1.Ordinal)) { 1208 for ( ; Name->u1.Ordinal != 0; ++Name) 1209 { 1210 if (!IMAGE_SNAP_BY_ORDINAL(Name->u1.Ordinal)) 1211 { 1164 1212 ImpName = (PIMAGE_IMPORT_BY_NAME) 1165 (Base + (DWORD)Name->u1.AddressOfData);1213 (Base + (DWORD)Name->u1.AddressOfData); 1166 1214 if (strcmp((char *)ImpName->Name, funcname) == 0) 1167 1215 return GetModuleHandle((char *)(Base + Imp->Name)); … … 1174 1222 1175 1223 static int 1176 sbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize) { 1224 sbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize) 1225 { 1177 1226 return 1; 1178 1227 } 1179 1228 1180 1229 static int 1181 dbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize) { 1230 dbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize) 1231 { 1182 1232 int len = IsDBCSLeadByteEx(cv->codepage, buf[0]) ? 2 : 1; 1183 1233 if (bufsize < len) … … 1187 1237 1188 1238 static int 1189 mbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize) { 1239 mbcs_mblen(csconv_t *cv, const uchar *buf, int bufsize) 1240 { 1190 1241 int len = 0; 1191 1242 1192 1243 if (cv->codepage == 54936) { 1193 if (buf[0] <= 0x7F) len = 1; 1194 else if (buf[0] >= 0x81 && buf[0] <= 0xFE && 1195 bufsize >= 2 && 1196 ((buf[1] >= 0x40 && buf[1] <= 0x7E) || 1197 (buf[1] >= 0x80 && buf[1] <= 0xFE))) len = 2; 1198 else if (buf[0] >= 0x81 && buf[0] <= 0xFE && 1199 bufsize >= 4 && 1200 buf[1] >= 0x30 && buf[1] <= 0x39) len = 4; 1201 else 1202 return seterror(EINVAL); 1203 return len; 1204 } else 1205 return seterror(EINVAL); 1206 } 1207 1208 static int 1209 utf8_mblen(csconv_t *cv, const uchar *buf, int bufsize) { 1244 if (buf[0] <= 0x7F) len = 1; 1245 else if (buf[0] >= 0x81 && buf[0] <= 0xFE && 1246 bufsize >= 2 && 1247 ((buf[1] >= 0x40 && buf[1] <= 0x7E) || 1248 (buf[1] >= 0x80 && buf[1] <= 0xFE))) len = 2; 1249 else if (buf[0] >= 0x81 && buf[0] <= 0xFE && 1250 bufsize >= 4 && 1251 buf[1] >= 0x30 && buf[1] <= 0x39) len = 4; 1252 else 1253 return seterror(EINVAL); 1254 return len; 1255 } 1256 else 1257 return seterror(EINVAL); 1258 } 1259 1260 static int 1261 utf8_mblen(csconv_t *cv, const uchar *buf, int bufsize) 1262 { 1210 1263 int len = 0; 1211 1264 … … 1225 1278 1226 1279 static int 1227 eucjp_mblen(csconv_t *cv, const uchar *buf, int bufsize) { 1280 eucjp_mblen(csconv_t *cv, const uchar *buf, int bufsize) 1281 { 1228 1282 if (buf[0] < 0x80) /* ASCII */ 1229 1283 return 1; 1230 else if (buf[0] == 0x8E) { /* JIS X 0201 */ 1284 else if (buf[0] == 0x8E) /* JIS X 0201 */ 1285 { 1231 1286 if (bufsize < 2) 1232 1287 return seterror(EINVAL); … … 1234 1289 return seterror(EILSEQ); 1235 1290 return 2; 1236 } else if (buf[0] == 0x8F) { /* JIS X 0212 */ 1291 } 1292 else if (buf[0] == 0x8F) /* JIS X 0212 */ 1293 { 1237 1294 if (bufsize < 3) 1238 1295 return seterror(EINVAL); 1239 1296 else if (!(0xA1 <= buf[1] && buf[1] <= 0xFE) 1240 || !(0xA1 <= buf[2] && buf[2] <= 0xFE))1297 || !(0xA1 <= buf[2] && buf[2] <= 0xFE)) 1241 1298 return seterror(EILSEQ); 1242 1299 return 3; 1243 } else { /* JIS X 0208 */ 1300 } 1301 else /* JIS X 0208 */ 1302 { 1244 1303 if (bufsize < 2) 1245 1304 return seterror(EINVAL); 1246 1305 else if (!(0xA1 <= buf[0] && buf[0] <= 0xFE) 1247 || !(0xA1 <= buf[1] && buf[1] <= 0xFE))1306 || !(0xA1 <= buf[1] && buf[1] <= 0xFE)) 1248 1307 return seterror(EILSEQ); 1249 1308 return 2; … … 1252 1311 1253 1312 static int 1254 kernel_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize) { 1313 kernel_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize) 1314 { 1255 1315 int len; 1256 1316 … … 1259 1319 return -1; 1260 1320 *wbufsize = MultiByteToWideChar(cv->codepage, mbtowc_flags (cv->codepage), 1261 (const char *)buf, len, (wchar_t *)wbuf, *wbufsize);1321 (const char *)buf, len, (wchar_t *)wbuf, *wbufsize); 1262 1322 if (*wbufsize == 0) 1263 1323 return seterror(EILSEQ); … … 1266 1326 1267 1327 static int 1268 kernel_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize) { 1328 kernel_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize) 1329 { 1269 1330 BOOL usedDefaultChar = 0; 1270 1331 BOOL *p = NULL; … … 1274 1335 if (bufsize == 0) 1275 1336 return seterror(E2BIG); 1276 if (!must_use_null_useddefaultchar(cv->codepage)) { 1337 if (!must_use_null_useddefaultchar(cv->codepage)) 1338 { 1277 1339 p = &usedDefaultChar; 1278 1340 #ifdef WC_NO_BEST_FIT_CHARS … … 1282 1344 } 1283 1345 len = WideCharToMultiByte(cv->codepage, flags, 1284 (const wchar_t *)wbuf, wbufsize, (char *)buf, bufsize, NULL, p); 1285 if (len == 0) { 1346 (const wchar_t *)wbuf, wbufsize, (char *)buf, bufsize, NULL, p); 1347 if (len == 0) 1348 { 1286 1349 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) 1287 1350 return seterror(E2BIG); 1288 1351 return seterror(EILSEQ); 1289 } else if (usedDefaultChar) 1352 } 1353 else if (usedDefaultChar) 1290 1354 return seterror(EILSEQ); 1291 1355 else if (cv->mblen(cv, buf, len) != len) /* validate result */ … … 1303 1367 */ 1304 1368 static int 1305 mlang_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize) { 1369 mlang_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize) 1370 { 1306 1371 int len; 1307 1372 int insize; … … 1313 1378 insize = len; 1314 1379 hr = ConvertINetMultiByteToUnicode(&cv->mode, cv->codepage, 1315 (const char *)buf, &insize, (wchar_t *)wbuf, wbufsize);1380 (const char *)buf, &insize, (wchar_t *)wbuf, wbufsize); 1316 1381 if (hr != S_OK || insize != len) 1317 1382 return seterror(EILSEQ); … … 1320 1385 1321 1386 static int 1322 mlang_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize) { 1387 mlang_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize) 1388 { 1323 1389 char tmpbuf[MB_CHAR_MAX]; /* enough room for one character */ 1324 1390 int tmpsize = MB_CHAR_MAX; … … 1327 1393 1328 1394 hr = ConvertINetUnicodeToMultiByte(&cv->mode, cv->codepage, 1329 (const wchar_t *)wbuf, &wbufsize, tmpbuf, &tmpsize);1395 (const wchar_t *)wbuf, &wbufsize, tmpbuf, &tmpsize); 1330 1396 if (hr != S_OK || insize != wbufsize) 1331 1397 return seterror(EILSEQ); … … 1339 1405 1340 1406 static int 1341 utf16_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize) { 1407 utf16_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize) 1408 { 1342 1409 int codepage = cv->codepage; 1343 1410 … … 1353 1420 wbuf[0] = (buf[0] << 8) | buf[1]; 1354 1421 1355 if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE)) { 1422 if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE)) 1423 { 1356 1424 cv->mode |= UNICODE_MODE_BOM_DONE; 1357 if (wbuf[0] == 0xFFFE) { 1425 if (wbuf[0] == 0xFFFE) 1426 { 1358 1427 cv->mode |= UNICODE_MODE_SWAPPED; 1359 1428 *wbufsize = 0; 1360 1429 return 2; 1361 } else if (wbuf[0] == 0xFEFF) { 1430 } 1431 else if (wbuf[0] == 0xFEFF) 1432 { 1362 1433 *wbufsize = 0; 1363 1434 return 2; … … 1367 1438 if (0xDC00 <= wbuf[0] && wbuf[0] <= 0xDFFF) 1368 1439 return seterror(EILSEQ); 1369 if (0xD800 <= wbuf[0] && wbuf[0] <= 0xDBFF) { 1440 if (0xD800 <= wbuf[0] && wbuf[0] <= 0xDBFF) 1441 { 1370 1442 if (bufsize < 4) 1371 1443 return seterror(EINVAL); … … 1384 1456 1385 1457 static int 1386 utf16_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize) { 1387 if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE)) { 1458 utf16_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize) 1459 { 1460 if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE)) 1461 { 1388 1462 int r; 1389 1463 … … 1404 1478 if (bufsize < 2) 1405 1479 return seterror(E2BIG); 1406 if (cv->codepage == 1200) { /* little endian */ 1480 if (cv->codepage == 1200) /* little endian */ 1481 { 1407 1482 buf[0] = (wbuf[0] & 0x00FF); 1408 1483 buf[1] = (wbuf[0] & 0xFF00) >> 8; 1409 } else if (cv->codepage == 1201) { /* big endian */ 1484 } 1485 else if (cv->codepage == 1201) /* big endian */ 1486 { 1410 1487 buf[0] = (wbuf[0] & 0xFF00) >> 8; 1411 1488 buf[1] = (wbuf[0] & 0x00FF); 1412 1489 } 1413 if (0xD800 <= wbuf[0] && wbuf[0] <= 0xDBFF) { 1490 if (0xD800 <= wbuf[0] && wbuf[0] <= 0xDBFF) 1491 { 1414 1492 if (bufsize < 4) 1415 1493 return seterror(E2BIG); 1416 if (cv->codepage == 1200) { /* little endian */ 1494 if (cv->codepage == 1200) /* little endian */ 1495 { 1417 1496 buf[2] = (wbuf[1] & 0x00FF); 1418 1497 buf[3] = (wbuf[1] & 0xFF00) >> 8; 1419 } else if (cv->codepage == 1201) { /* big endian */ 1498 } 1499 else if (cv->codepage == 1201) /* big endian */ 1500 { 1420 1501 buf[2] = (wbuf[1] & 0xFF00) >> 8; 1421 1502 buf[3] = (wbuf[1] & 0x00FF); … … 1427 1508 1428 1509 static int 1429 utf32_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize) { 1510 utf32_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize) 1511 { 1430 1512 int codepage = cv->codepage; 1431 uint wc ;1513 uint wc = 0; 1432 1514 1433 1515 /* swap endian: 12000 <-> 12001 */ … … 1442 1524 wc = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; 1443 1525 1444 if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE)) { 1526 if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE)) 1527 { 1445 1528 cv->mode |= UNICODE_MODE_BOM_DONE; 1446 if (wc == 0xFFFE0000) { 1529 if (wc == 0xFFFE0000) 1530 { 1447 1531 cv->mode |= UNICODE_MODE_SWAPPED; 1448 1532 *wbufsize = 0; 1449 1533 return 4; 1450 } else if (wc == 0x0000FEFF) { 1534 } 1535 else if (wc == 0x0000FEFF) 1536 { 1451 1537 *wbufsize = 0; 1452 1538 return 4; … … 1461 1547 1462 1548 static int 1463 utf32_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize) { 1549 utf32_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize) 1550 { 1464 1551 uint wc; 1465 1552 1466 if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE)) { 1553 if ((cv->flags & FLAG_USE_BOM) && !(cv->mode & UNICODE_MODE_BOM_DONE)) 1554 { 1467 1555 int r; 1468 1556 … … 1484 1572 return seterror(E2BIG); 1485 1573 wc = utf16_to_ucs4(wbuf); 1486 if (cv->codepage == 12000) { /* little endian */ 1574 if (cv->codepage == 12000) /* little endian */ 1575 { 1487 1576 buf[0] = wc & 0x000000FF; 1488 1577 buf[1] = (wc & 0x0000FF00) >> 8; 1489 1578 buf[2] = (wc & 0x00FF0000) >> 16; 1490 1579 buf[3] = (wc & 0xFF000000) >> 24; 1491 } else if (cv->codepage == 12001) { /* big endian */ 1580 } 1581 else if (cv->codepage == 12001) /* big endian */ 1582 { 1492 1583 buf[0] = (wc & 0xFF000000) >> 24; 1493 1584 buf[1] = (wc & 0x00FF0000) >> 16; … … 1549 1640 1550 1641 static int 1551 iso2022jp_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize) { 1642 iso2022jp_mbtowc(csconv_t *cv, const uchar *buf, int bufsize, ushort *wbuf, int *wbufsize) 1643 { 1552 1644 iso2022_esc_t *iesc = iso2022jp_esc; 1553 1645 char tmp[MB_CHAR_MAX]; … … 1561 1653 int i; 1562 1654 1563 if (buf[0] == 0x1B) { 1564 for (i = 0; iesc[i].esc != NULL; ++i) { 1655 if (buf[0] == 0x1B) 1656 { 1657 for (i = 0; iesc[i].esc != NULL; ++i) 1658 { 1565 1659 esc_len = iesc[i].esc_len; 1566 if (bufsize < esc_len) { 1660 if (bufsize < esc_len) 1661 { 1567 1662 if (strncmp((char *)buf, iesc[i].esc, bufsize) == 0) 1568 1663 return seterror(EINVAL); 1569 } else { 1570 if (strncmp((char *)buf, iesc[i].esc, esc_len) == 0) { 1664 } 1665 else 1666 { 1667 if (strncmp((char *)buf, iesc[i].esc, esc_len) == 0) 1668 { 1571 1669 cv->mode = ISO2022_MODE(iesc[i].cs, ISO2022_SI); 1572 1670 *wbufsize = 0; … … 1577 1675 /* not supported escape sequence */ 1578 1676 return seterror(EILSEQ); 1579 } else if (buf[0] == iso2022_SO_seq[0]) { 1677 } 1678 else if (buf[0] == iso2022_SO_seq[0]) 1679 { 1580 1680 cv->mode = ISO2022_MODE(ISO2022_MODE_CS(cv->mode), ISO2022_SO); 1581 1681 *wbufsize = 0; 1582 1682 return 1; 1583 } else if (buf[0] == iso2022_SI_seq[0]) { 1683 } 1684 else if (buf[0] == iso2022_SI_seq[0]) 1685 { 1584 1686 cv->mode = ISO2022_MODE(ISO2022_MODE_CS(cv->mode), ISO2022_SI); 1585 1687 *wbufsize = 0; … … 1591 1693 1592 1694 /* reset the mode for informal sequence */ 1593 if (buf[0] < 0x20) { 1695 if (buf[0] < 0x20) 1696 { 1594 1697 cs = ISO2022JP_CS_ASCII; 1595 1698 shift = ISO2022_SI; … … 1604 1707 esc_len = iesc[cs].esc_len; 1605 1708 memcpy(tmp, iesc[cs].esc, esc_len); 1606 if (shift == ISO2022_SO) { 1709 if (shift == ISO2022_SO) 1710 { 1607 1711 memcpy(tmp + esc_len, iso2022_SO_seq, 1); 1608 1712 esc_len += 1; … … 1611 1715 1612 1716 if ((cv->codepage == 50220 || cv->codepage == 50221 1613 || cv->codepage == 50222) && shift == ISO2022_SO) { 1717 || cv->codepage == 50222) && shift == ISO2022_SO) 1718 { 1614 1719 /* XXX: shift-out cannot be used for mbtowc (both kernel and 1615 1720 * mlang) */ … … 1621 1726 insize = len + esc_len; 1622 1727 hr = ConvertINetMultiByteToUnicode(&dummy, cv->codepage, 1623 (const char *)tmp, &insize, (wchar_t *)wbuf, wbufsize);1728 (const char *)tmp, &insize, (wchar_t *)wbuf, wbufsize); 1624 1729 if (hr != S_OK || insize != len + esc_len) 1625 1730 return seterror(EILSEQ); … … 1639 1744 1640 1745 static int 1641 iso2022jp_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize) { 1746 iso2022jp_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize) 1747 { 1642 1748 iso2022_esc_t *iesc = iso2022jp_esc; 1643 1749 char tmp[MB_CHAR_MAX]; … … 1659 1765 */ 1660 1766 hr = ConvertINetUnicodeToMultiByte(&dummy, cv->codepage, 1661 (const wchar_t *)wbuf, &wbufsize, tmp, &tmpsize);1767 (const wchar_t *)wbuf, &wbufsize, tmp, &tmpsize); 1662 1768 if (hr != S_OK || insize != wbufsize) 1663 1769 return seterror(EILSEQ); … … 1665 1771 return seterror(E2BIG); 1666 1772 1667 if (tmpsize == 1) { 1773 if (tmpsize == 1) 1774 { 1668 1775 cs = ISO2022JP_CS_ASCII; 1669 1776 esc_len = 0; 1670 } else { 1671 for (i = 1; iesc[i].esc != NULL; ++i) { 1777 } 1778 else 1779 { 1780 for (i = 1; iesc[i].esc != NULL; ++i) 1781 { 1672 1782 esc_len = iesc[i].esc_len; 1673 if (strncmp(tmp, iesc[i].esc, esc_len) == 0) { 1783 if (strncmp(tmp, iesc[i].esc, esc_len) == 0) 1784 { 1674 1785 cs = iesc[i].cs; 1675 1786 break; … … 1682 1793 1683 1794 shift = ISO2022_SI; 1684 if (tmp[esc_len] == iso2022_SO_seq[0]) { 1795 if (tmp[esc_len] == iso2022_SO_seq[0]) 1796 { 1685 1797 shift = ISO2022_SO; 1686 1798 esc_len += 1; … … 1696 1808 return seterror(EILSEQ); 1697 1809 1698 if (cv->mode == ISO2022_MODE(cs, shift)) { 1810 if (cv->mode == ISO2022_MODE(cs, shift)) 1811 { 1699 1812 /* remove escape sequence */ 1700 1813 if (esc_len != 0) 1701 1814 memmove(tmp, tmp + esc_len, len); 1702 1815 esc_len = 0; 1703 } else { 1704 if (cs == ISO2022JP_CS_ASCII) { 1816 } 1817 else 1818 { 1819 if (cs == ISO2022JP_CS_ASCII) 1820 { 1705 1821 esc_len = iesc[ISO2022JP_CS_ASCII].esc_len; 1706 1822 memmove(tmp + esc_len, tmp, len); 1707 1823 memcpy(tmp, iesc[ISO2022JP_CS_ASCII].esc, esc_len); 1708 1824 } 1709 if (ISO2022_MODE_SHIFT(cv->mode) == ISO2022_SO) { 1825 if (ISO2022_MODE_SHIFT(cv->mode) == ISO2022_SO) 1826 { 1710 1827 /* shift-in before changing to other mode */ 1711 1828 memmove(tmp + 1, tmp, len + esc_len); … … 1723 1840 1724 1841 static int 1725 iso2022jp_flush(csconv_t *cv, uchar *buf, int bufsize) { 1842 iso2022jp_flush(csconv_t *cv, uchar *buf, int bufsize) 1843 { 1726 1844 iso2022_esc_t *iesc = iso2022jp_esc; 1727 1845 int esc_len; 1728 1846 1729 if (cv->mode != ISO2022_MODE(ISO2022JP_CS_ASCII, ISO2022_SI)) { 1847 if (cv->mode != ISO2022_MODE(ISO2022JP_CS_ASCII, ISO2022_SI)) 1848 { 1730 1849 esc_len = 0; 1731 1850 if (ISO2022_MODE_SHIFT(cv->mode) != ISO2022_SI) … … 1737 1856 1738 1857 esc_len = 0; 1739 if (ISO2022_MODE_SHIFT(cv->mode) != ISO2022_SI) { 1858 if (ISO2022_MODE_SHIFT(cv->mode) != ISO2022_SI) 1859 { 1740 1860 memcpy(buf, iso2022_SI_seq, 1); 1741 1861 esc_len += 1; 1742 1862 } 1743 if (ISO2022_MODE_CS(cv->mode) != ISO2022JP_CS_ASCII) { 1863 if (ISO2022_MODE_CS(cv->mode) != ISO2022JP_CS_ASCII) 1864 { 1744 1865 memcpy(buf + esc_len, iesc[ISO2022JP_CS_ASCII].esc, 1745 iesc[ISO2022JP_CS_ASCII].esc_len);1866 iesc[ISO2022JP_CS_ASCII].esc_len); 1746 1867 esc_len += iesc[ISO2022JP_CS_ASCII].esc_len; 1747 1868 } … … 1753 1874 #if defined(MAKE_DLL) && defined(USE_LIBICONV_DLL) 1754 1875 BOOL WINAPI 1755 DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) { 1756 switch ( fdwReason ) { 1876 DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) 1877 { 1878 switch( fdwReason ) 1879 { 1757 1880 case DLL_PROCESS_ATTACH: 1758 1881 hwiniconv = (HMODULE)hinstDLL; … … 1772 1895 #include <io.h> 1773 1896 int 1774 main(int argc, char **argv) { 1897 main(int argc, char **argv) 1898 { 1775 1899 char *fromcode = NULL; 1776 1900 char *tocode = NULL; … … 1790 1914 _setmode(_fileno(stdout), _O_BINARY); 1791 1915 1792 for (i = 1; i < argc; ++i) { 1793 if (strcmp(argv[i], "-l") == 0) { 1916 for (i = 1; i < argc; ++i) 1917 { 1918 if (strcmp(argv[i], "-l") == 0) 1919 { 1794 1920 for (i = 0; codepage_alias[i].name != NULL; ++i) 1795 1921 printf("%s\n", codepage_alias[i].name); … … 1801 1927 else if (strcmp(argv[i], "-t") == 0) 1802 1928 tocode = argv[++i]; 1803 else { 1929 else 1930 { 1804 1931 in = fopen(argv[i], "rb"); 1805 if (in == NULL) { 1932 if (in == NULL) 1933 { 1806 1934 fprintf(stderr, "cannot open %s\n", argv[i]); 1807 1935 return 1; … … 1811 1939 } 1812 1940 1813 if (fromcode == NULL || tocode == NULL) { 1941 if (fromcode == NULL || tocode == NULL) 1942 { 1814 1943 printf("usage: %s -f from-enc -t to-enc [file]\n", argv[0]); 1815 1944 return 0; … … 1817 1946 1818 1947 cd = iconv_open(tocode, fromcode); 1819 if (cd == (iconv_t)(-1)) { 1948 if (cd == (iconv_t)(-1)) 1949 { 1820 1950 perror("iconv_open error"); 1821 1951 return 1; … … 1823 1953 1824 1954 while ((inbytesleft = fread(inbuf + rest, 1, sizeof(inbuf) - rest, in)) != 0 1825 || rest != 0) { 1955 || rest != 0) 1956 { 1826 1957 inbytesleft += rest; 1827 1958 pin = inbuf; … … 1830 1961 r = iconv(cd, &pin, &inbytesleft, &pout, &outbytesleft); 1831 1962 fwrite(outbuf, 1, sizeof(outbuf) - outbytesleft, stdout); 1832 if (r == (size_t)(-1) && errno != E2BIG && (errno != EINVAL || feof(in))) { 1963 if (r == (size_t)(-1) && errno != E2BIG && (errno != EINVAL || feof(in))) 1964 { 1833 1965 perror("conversion error"); 1834 1966 return 1; … … 1841 1973 r = iconv(cd, NULL, NULL, &pout, &outbytesleft); 1842 1974 fwrite(outbuf, 1, sizeof(outbuf) - outbytesleft, stdout); 1843 if (r == (size_t)(-1)) { 1975 if (r == (size_t)(-1)) 1976 { 1844 1977 perror("conversion error"); 1845 1978 return 1; -
lang/objective-cplusplus/i3/trunk/windows/i3_test.vcproj
r35922 r36013 54 54 Optimization="0" 55 55 AdditionalIncludeDirectories="..\src\;"..\src\gui-windows";..\src\mil\include;"..\src\os-windows";"..\src\os-windows\msvc"" 56 PreprocessorDefinitions="I3_TEST" 56 57 MinimalRebuild="true" 57 58 BasicRuntimeChecks="3" … … 146 147 EnableFiberSafeOptimizations="true" 147 148 AdditionalIncludeDirectories="..\src\;"..\src\gui-windows";..\src\mil\include;"..\src\os-windows";"..\src\os-windows\msvc"" 149 PreprocessorDefinitions="I3_TEST" 148 150 StringPooling="true" 149 151 RuntimeLibrary="2" … … 232 234 Optimization="0" 233 235 AdditionalIncludeDirectories="..\src\;"..\src\gui-windows";..\src\mil\include;"..\src\os-windows";"..\src\os-windows\msvc"" 236 PreprocessorDefinitions="I3_TEST" 234 237 MinimalRebuild="true" 235 238 BasicRuntimeChecks="3" … … 603 606 </File> 604 607 <File 608 RelativePath="..\src\mil\src\test\Main.cpp" 609 > 610 <FileConfiguration 611 Name="Debug|Win32" 612 > 613 <Tool 614 Name="VCCLCompilerTool" 615 UsePrecompiledHeader="0" 616 /> 617 </FileConfiguration> 618 </File> 619 <File 605 620 RelativePath="..\src\Mediator.cpp" 606 621 > … … 667 682 </File> 668 683 <File 669 RelativePath="..\src\mil\src\test\TestMain.cpp" 670 > 671 <FileConfiguration 672 Name="Debug|Win32" 673 > 674 <Tool 675 Name="VCCLCompilerTool" 676 UsePrecompiledHeader="0" 677 /> 678 </FileConfiguration> 684 RelativePath="..\src\Tester.cpp" 685 > 679 686 </File> 680 687 <File … … 819 826 </File> 820 827 <File 828 RelativePath="..\src\Tester.h" 829 > 830 </File> 831 <File 821 832 RelativePath="..\src\os-windows\Utf8ToUtf16Stream.h" 822 833 > … … 827 838 </File> 828 839 </Filter> 840 <File 841 RelativePath="..\src\gui-windows\OutputWindowPlatform.cpp" 842 > 843 </File> 829 844 </Files> 830 845 <Globals> -
lang/objective-cplusplus/i3/trunk/windows/mil_test.vcproj
r35836 r36013 965 965 </File> 966 966 <File 967 RelativePath="..\src\mil\include\mil\os-windows\Debug.h" 968 > 969 </File> 970 <File 967 971 RelativePath="..\src\mil\include\mil\Debug.h" 968 972 > 969 973 </File> 970 974 <File 971 RelativePath="..\src\mil\include\mil\os-windows\Debug.h"972 >973 </File>974 <File975 975 RelativePath="..\src\mil\include\mil\gui-windows\DummyMessageHandler-inl.h" 976 976 > … … 985 985 </File> 986 986 <File 987 RelativePath="..\src\mil\include\mil\GuiModule.h" 988 > 989 </File> 990 <File 987 991 RelativePath="..\src\mil\include\mil\gui-windows\GuiModule.h" 988 992 > 989 993 </File> 990 994 <File 991 RelativePath="..\src\mil\include\mil\GuiModule.h"992 >993 </File>994 <File995 995 RelativePath="..\src\mil\include\mil\Memory.h" 996 996 > … … 1021 1021 </File> 1022 1022 <File 1023 RelativePath="..\src\mil\include\mil\os-windows\PrecompiledHeaders.h" 1024 > 1025 </File> 1026 <File 1027 RelativePath="..\src\mil\include\mil\PrecompiledHeaders.h" 1028 > 1029 </File> 1030 <File 1023 1031 RelativePath="..\src\mil\include\mil\gui-windows\PrecompiledHeaders.h" 1024 1032 > 1025 1033 </File> 1026 1034 <File 1027 RelativePath="..\src\mil\include\mil\os-windows\PrecompiledHeaders.h"1028 >1029 </File>1030 <File1031 RelativePath="..\src\mil\include\mil\PrecompiledHeaders.h"1032 >1033 </File>1034 <File1035 1035 RelativePath="..\src\mil\include\quicktest\quicktest.h" 1036 1036 > … … 1053 1053 </File> 1054 1054 <File 1055 RelativePath="..\src\mil\ src\Test.h"1055 RelativePath="..\src\mil\include\mil\Thread.h" 1056 1056 > 1057 1057 </File> 1058 1058 <File 1059 1059 RelativePath="..\src\mil\include\mil\os-windows\Thread.h" 1060 >1061 </File>1062 <File1063 RelativePath="..\src\mil\include\mil\Thread.h"1064 1060 > 1065 1061 </File> -
lang/objective-cplusplus/i3/trunk/windows/mingw.sh
r35951 r36013 2 2 3 3 export CFLAGS="-O3 -DNDEBUG -U_DEBUG -march=i486 -Wno-missing-field-initializers -Wno-unused-value -Wno-unused-parameter" 4 export CXXFLAGS="$CFLAGS" 4 export CXXFLAGS="$CFLAGS" 5 5 export LDFLAGS="-s" 6 7 sh scripts/potfiles.sh 6 8 7 9 ./configure \ -
lang/objective-cplusplus/i3/trunk/windows/release.sh
r35922 r36013 25 25 # ./configure --prefix=/usr/local/$CROSS_HOST --host=$CROSS_HOST --disable-shared && make && make install 26 26 27 sh scripts/potfiles.sh 28 27 29 ./configure \ 28 30 --host=$CROSS_HOST \
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)