annotate src/os_macosx.c @ 1821:9913ff570616 v7.2.119

updated for version 7.2-119
author vimboss
date Sun, 22 Feb 2009 00:14:58 +0000
parents 25a70b1cd2da
children cccb71c2c5c1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
574
25a70b1cd2da updated for version 7.0163
vimboss
parents: 492
diff changeset
11 * os_macosx.c -- Mac specific things for Mac OS/X.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #ifdef MACOS_X_UNIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 # ifdef HAVE_CONFIG_H /* Using Makefile. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 # include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 # include "os_unix.c" /* Using Project Builder */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 #else
574
25a70b1cd2da updated for version 7.0163
vimboss
parents: 492
diff changeset
21 Error: MACOS 9 is no longer supported in Vim 7
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 #ifdef _DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 Trace(char* fmt, ...)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 char buf[2048];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 va_list args;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 va_start(args, fmt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 /* vsnprintf(buf, sizeof(buf), fmt, args);*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 fprintf(stderr, "%s", buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 va_end(args);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 #ifdef MACOS_X_ICONVEMU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 * Libiconv emulation layer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 struct _iconv_t
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 TECObjectRef tec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 TECObjectRef tecReverse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 TECSnifferObjectRef sniff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 TextEncoding from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 TextEncoding to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 /* typedef struct _iconv_t *iconv_t; */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 static int last_errno = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 * Get TextEncoding from iconv's encoding name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 static TextEncoding
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 get_textencoding(const char* encodename)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 static struct {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 const char* name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 TextEncoding encode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 } encodetable[] = {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 /* ISO-8859 encodings family */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 {"latin1", kTextEncodingISOLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 {"latin2", kTextEncodingISOLatin2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 {"latin3", kTextEncodingISOLatin3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 {"latin4", kTextEncodingISOLatin4},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 {"latin5", kTextEncodingISOLatin5},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 {"latin6", kTextEncodingISOLatin6},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 {"latin7", kTextEncodingISOLatin7},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 {"latin8", kTextEncodingISOLatin8},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 {"latin9", kTextEncodingISOLatin9},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 {"iso-8859-1", kTextEncodingISOLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 {"iso-8859-2", kTextEncodingISOLatin2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 {"iso-8859-3", kTextEncodingISOLatin3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 {"iso-8859-4", kTextEncodingISOLatin4},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 {"iso-8859-5", kTextEncodingISOLatinCyrillic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 {"iso-8859-6", kTextEncodingISOLatinArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 {"iso-8859-7", kTextEncodingISOLatinGreek},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 {"iso-8859-8", kTextEncodingISOLatinHebrew},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 {"iso-8859-9", kTextEncodingISOLatin5},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 {"iso-8859-10", kTextEncodingISOLatin6},
492
81c06952fb1d updated for version 7.0135
vimboss
parents: 18
diff changeset
86 {"iso-8859-15", kTextEncodingISOLatin9},
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 /* Unicode encodings. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 /* TODO: Add other type of unicode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 {"ucs-2", kTextEncodingMacUnicode},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 /* Japanese encoding aliases */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 {"cp932", kTextEncodingShiftJIS},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 {"shift-jis", kTextEncodingShiftJIS},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 {"euc-jp", kTextEncodingEUC_JP},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 {"iso-2022-jp", kTextEncodingISO_2022_JP},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 {"iso-2022-jp-1", kTextEncodingISO_2022_JP_1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 {"iso-2022-jp-2", kTextEncodingISO_2022_JP_2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 {"iso-2022-jp-3", kTextEncodingISO_2022_JP_3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 /* Other aliases. These aliases in this block are just guessed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 /* TODO: Must be verified. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 {"gb2312", kTextEncodingGB_2312_80},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 {"cp936", kTextEncodingMacChineseSimp},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 {"euc-cn", kTextEncodingEUC_CN},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 {"cp950", kTextEncodingMacChineseTrad},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 {"euc-tw", kTextEncodingEUC_TW},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 {"cp949", kTextEncodingMacKorean},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 {"euc-kr", kTextEncodingEUC_KR},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 * All encodings supported by Macintosh. You can find these values
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 * in a file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 * /System/Library/Frameworks/CoreServices.framework/Versions/A/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 * Frameworks/CarbonCore.framework/Versions/A/Headers/TextCommon.h
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 {"MacRoman", kTextEncodingMacRoman},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 {"MacJapanese", kTextEncodingMacJapanese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 {"MacChineseTrad", kTextEncodingMacChineseTrad},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 {"MacKorean", kTextEncodingMacKorean},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 {"MacArabic", kTextEncodingMacArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 {"MacHebrew", kTextEncodingMacHebrew},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 {"MacGreek", kTextEncodingMacGreek},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 {"MacCyrillic", kTextEncodingMacCyrillic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 {"MacDevanagari", kTextEncodingMacDevanagari},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 {"MacGurmukhi", kTextEncodingMacGurmukhi},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 {"MacGujarati", kTextEncodingMacGujarati},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 {"MacOriya", kTextEncodingMacOriya},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 {"MacBengali", kTextEncodingMacBengali},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 {"MacTamil", kTextEncodingMacTamil},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 {"MacTelugu", kTextEncodingMacTelugu},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 {"MacKannada", kTextEncodingMacKannada},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 {"MacMalayalam", kTextEncodingMacMalayalam},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 {"MacSinhalese", kTextEncodingMacSinhalese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 {"MacBurmese", kTextEncodingMacBurmese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 {"MacKhmer", kTextEncodingMacKhmer},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 {"MacThai", kTextEncodingMacThai},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 {"MacLaotian", kTextEncodingMacLaotian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 {"MacGeorgian", kTextEncodingMacGeorgian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 {"MacArmenian", kTextEncodingMacArmenian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 {"MacChineseSimp", kTextEncodingMacChineseSimp},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 {"MacTibetan", kTextEncodingMacTibetan},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 {"MacMongolian", kTextEncodingMacMongolian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 {"MacEthiopic", kTextEncodingMacEthiopic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 {"MacCentralEurRoman", kTextEncodingMacCentralEurRoman},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 {"MacVietnamese", kTextEncodingMacVietnamese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 {"MacExtArabic", kTextEncodingMacExtArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 {"MacSymbol", kTextEncodingMacSymbol},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 {"MacDingbats", kTextEncodingMacDingbats},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 {"MacTurkish", kTextEncodingMacTurkish},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 {"MacCroatian", kTextEncodingMacCroatian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 {"MacIcelandic", kTextEncodingMacIcelandic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 {"MacRomanian", kTextEncodingMacRomanian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 {"MacCeltic", kTextEncodingMacCeltic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 {"MacGaelic", kTextEncodingMacGaelic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 {"MacKeyboardGlyphs", kTextEncodingMacKeyboardGlyphs},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 {"MacTradChinese", kTextEncodingMacTradChinese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 {"MacRSymbol", kTextEncodingMacRSymbol},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 {"MacSimpChinese", kTextEncodingMacSimpChinese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 {"MacGeez", kTextEncodingMacGeez},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 {"MacEastEurRoman", kTextEncodingMacEastEurRoman},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 {"MacUninterp", kTextEncodingMacUninterp},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 {"MacUnicode", kTextEncodingMacUnicode},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 {"MacFarsi", kTextEncodingMacFarsi},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 {"MacUkrainian", kTextEncodingMacUkrainian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 {"MacInuit", kTextEncodingMacInuit},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 {"MacVT100", kTextEncodingMacVT100},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 {"MacHFS", kTextEncodingMacHFS},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 {"UnicodeDefault", kTextEncodingUnicodeDefault},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 {"UnicodeV1_1", kTextEncodingUnicodeV1_1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 {"ISO10646_1993", kTextEncodingISO10646_1993},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 {"UnicodeV2_0", kTextEncodingUnicodeV2_0},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 {"UnicodeV2_1", kTextEncodingUnicodeV2_1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 {"UnicodeV3_0", kTextEncodingUnicodeV3_0},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 {"UnicodeV3_1", kTextEncodingUnicodeV3_1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 {"UnicodeV3_2", kTextEncodingUnicodeV3_2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 {"ISOLatin1", kTextEncodingISOLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 {"ISOLatin2", kTextEncodingISOLatin2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 {"ISOLatin3", kTextEncodingISOLatin3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 {"ISOLatin4", kTextEncodingISOLatin4},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 {"ISOLatinCyrillic", kTextEncodingISOLatinCyrillic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 {"ISOLatinArabic", kTextEncodingISOLatinArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 {"ISOLatinGreek", kTextEncodingISOLatinGreek},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 {"ISOLatinHebrew", kTextEncodingISOLatinHebrew},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 {"ISOLatin5", kTextEncodingISOLatin5},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 {"ISOLatin6", kTextEncodingISOLatin6},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 {"ISOLatin7", kTextEncodingISOLatin7},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 {"ISOLatin8", kTextEncodingISOLatin8},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 {"ISOLatin9", kTextEncodingISOLatin9},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 {"DOSLatinUS", kTextEncodingDOSLatinUS},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 {"DOSGreek", kTextEncodingDOSGreek},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 {"DOSBalticRim", kTextEncodingDOSBalticRim},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 {"DOSLatin1", kTextEncodingDOSLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 {"DOSGreek1", kTextEncodingDOSGreek1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 {"DOSLatin2", kTextEncodingDOSLatin2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 {"DOSCyrillic", kTextEncodingDOSCyrillic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 {"DOSTurkish", kTextEncodingDOSTurkish},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 {"DOSPortuguese", kTextEncodingDOSPortuguese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 {"DOSIcelandic", kTextEncodingDOSIcelandic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 {"DOSHebrew", kTextEncodingDOSHebrew},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 {"DOSCanadianFrench", kTextEncodingDOSCanadianFrench},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 {"DOSArabic", kTextEncodingDOSArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 {"DOSNordic", kTextEncodingDOSNordic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 {"DOSRussian", kTextEncodingDOSRussian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 {"DOSGreek2", kTextEncodingDOSGreek2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 {"DOSThai", kTextEncodingDOSThai},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 {"DOSJapanese", kTextEncodingDOSJapanese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 {"DOSChineseSimplif", kTextEncodingDOSChineseSimplif},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 {"DOSKorean", kTextEncodingDOSKorean},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 {"DOSChineseTrad", kTextEncodingDOSChineseTrad},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 {"WindowsLatin1", kTextEncodingWindowsLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 {"WindowsANSI", kTextEncodingWindowsANSI},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 {"WindowsLatin2", kTextEncodingWindowsLatin2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 {"WindowsCyrillic", kTextEncodingWindowsCyrillic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 {"WindowsGreek", kTextEncodingWindowsGreek},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 {"WindowsLatin5", kTextEncodingWindowsLatin5},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 {"WindowsHebrew", kTextEncodingWindowsHebrew},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 {"WindowsArabic", kTextEncodingWindowsArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 {"WindowsBalticRim", kTextEncodingWindowsBalticRim},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 {"WindowsVietnamese", kTextEncodingWindowsVietnamese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 {"WindowsKoreanJohab", kTextEncodingWindowsKoreanJohab},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 {"US_ASCII", kTextEncodingUS_ASCII},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 {"JIS_X0201_76", kTextEncodingJIS_X0201_76},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 {"JIS_X0208_83", kTextEncodingJIS_X0208_83},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 {"JIS_X0208_90", kTextEncodingJIS_X0208_90},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 {"JIS_X0212_90", kTextEncodingJIS_X0212_90},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 {"JIS_C6226_78", kTextEncodingJIS_C6226_78},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 {"ShiftJIS_X0213_00", kTextEncodingShiftJIS_X0213_00},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 {"GB_2312_80", kTextEncodingGB_2312_80},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 {"GBK_95", kTextEncodingGBK_95},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 {"GB_18030_2000", kTextEncodingGB_18030_2000},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 {"KSC_5601_87", kTextEncodingKSC_5601_87},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 {"KSC_5601_92_Johab", kTextEncodingKSC_5601_92_Johab},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 {"CNS_11643_92_P1", kTextEncodingCNS_11643_92_P1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 {"CNS_11643_92_P2", kTextEncodingCNS_11643_92_P2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 {"CNS_11643_92_P3", kTextEncodingCNS_11643_92_P3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 {"ISO_2022_JP", kTextEncodingISO_2022_JP},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 {"ISO_2022_JP_2", kTextEncodingISO_2022_JP_2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 {"ISO_2022_JP_1", kTextEncodingISO_2022_JP_1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 {"ISO_2022_JP_3", kTextEncodingISO_2022_JP_3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 {"ISO_2022_CN", kTextEncodingISO_2022_CN},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 {"ISO_2022_CN_EXT", kTextEncodingISO_2022_CN_EXT},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 {"ISO_2022_KR", kTextEncodingISO_2022_KR},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 {"EUC_JP", kTextEncodingEUC_JP},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 {"EUC_CN", kTextEncodingEUC_CN},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 {"EUC_TW", kTextEncodingEUC_TW},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 {"EUC_KR", kTextEncodingEUC_KR},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 {"ShiftJIS", kTextEncodingShiftJIS},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 {"KOI8_R", kTextEncodingKOI8_R},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 {"Big5", kTextEncodingBig5},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 {"MacRomanLatin1", kTextEncodingMacRomanLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 {"HZ_GB_2312", kTextEncodingHZ_GB_2312},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 {"Big5_HKSCS_1999", kTextEncodingBig5_HKSCS_1999},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 {"NextStepLatin", kTextEncodingNextStepLatin},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 {"EBCDIC_US", kTextEncodingEBCDIC_US},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 {"EBCDIC_CP037", kTextEncodingEBCDIC_CP037},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 {"MultiRun", kTextEncodingMultiRun},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 /* Terminator */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 {NULL, -1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 for (i = 0; encodetable[i].name != NULL; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 if (STRICMP(encodename, encodetable[i].name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 return encodetable[i].encode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 * iconv interfaces
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 iconv_t
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 iconv_open(const char* tocode, const char* fromcode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 TextEncoding toEnc, fromEnc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 iconv_t cd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 OSStatus st;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 /* Verify to/from encoding name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 toEnc = get_textencoding(tocode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 fromEnc = get_textencoding(fromcode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 if (toEnc < 0 || fromEnc < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 goto ICONV_OPEN_ERR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 /* Allocate memory to object */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 cd = (iconv_t)alloc(sizeof(struct _iconv_t));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 if (!cd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 goto ICONV_OPEN_ERR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 memset(cd, 0, sizeof(struct _iconv_t));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 /* Create converter */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 if (fromEnc != toEnc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 TRACE("*** fromEnc=%d toEnc=%d\n", (int)fromEnc, (int)toEnc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 st = TECCreateConverter(&cd->tec, fromEnc, toEnc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 if (st != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 TRACE("*** TECCreateConverter()=%d\n", (int)st);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 goto ICONV_OPEN_ERR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 /* Create reverse converter */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 st = TECCreateConverter(&cd->tecReverse, toEnc, fromEnc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 if (st != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 TRACE("*** TECCreateConverter()=%d (reverse)\n", (int)st);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 goto ICONV_OPEN_ERR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 /* Create Sniffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 st = TECCreateSniffer(&cd->sniff, &fromEnc, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 if (st != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 TRACE("*** TECCreateSniffer()=%d\n", (int)st);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 goto ICONV_OPEN_ERR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 cd->from = fromEnc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 cd->to = toEnc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 last_errno = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 return cd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 ICONV_OPEN_ERR:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 if (cd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 iconv_close(cd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 last_errno = EINVAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 return (iconv_t)-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 * Used when there are same value in 'from encoding' and 'to encoding'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 * TEC doesn't support conversion between same encodings, and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 * TECCreateConverter() failed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 static size_t
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
340 null_conv(iconv_t cd, const char **inbuf, size_t *inbytesleft,
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
341 char **outbuf, size_t *outbytesleft)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 const char* buf_in = inbuf && *inbuf ? *inbuf : NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 char* buf_out = outbuf && *outbuf ? *outbuf : NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 if (buf_in)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 int in_len = inbytesleft ? *inbytesleft : 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 int out_len = outbytesleft ? *outbytesleft : 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 if (!buf_out || out_len <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 last_errno = E2BIG;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 else if (in_len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 int len = in_len < out_len ? in_len : out_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 memcpy (buf_out, buf_in, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 *inbuf += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 *outbuf += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 *inbytesleft -= len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 *outbytesleft -= len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 if (*outbytesleft <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 last_errno = E2BIG;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 last_errno = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 size_t
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
377 iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft,
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
378 char **outbuf, size_t *outbytesleft)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 {
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
380 ConstTextPtr buf_in;
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
381 TextPtr buf_out;
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
382 ByteCount out_len, out_true;
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
383 ByteCount in_len, in_true;
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
384 OSStatus st;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 if (!cd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 last_errno = ENOENT; /* TODO: Another error code should be set */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 if (cd->from == cd->to)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 return null_conv(cd, inbuf, inbytesleft, outbuf, outbytesleft) ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 buf_in = (TextPtr) inbuf ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 buf_out = (TextPtr) outbuf ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 out_len = out_true = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 in_len = in_true = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 if (buf_in && buf_out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 ItemCount error, feature;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 /* Normal convert mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 if (!inbytesleft || !outbytesleft)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 last_errno = EFAULT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 in_len = *inbytesleft;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 out_len = *outbytesleft;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 /* Check stream is form in expected encoding or not */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 st = TECSniffTextEncoding(cd->sniff, (TextPtr)buf_in, in_len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 &cd->from, 1, &error, 1, &feature, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 TRACE("TECSniffTextEncoding()=%d error=%d feature=%d\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 (int)st, (int)error, (int)feature);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 if ((error != 0 || feature == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 && !(error == 0xffffffff && feature == 0xffffffff))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 /* Not expected encoding */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 st = kTECUnmappableElementErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 /* Do convert */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 st = TECConvertText(cd->tec,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 buf_in, in_len, &in_true,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 buf_out, out_len, &out_true);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 /* Verify converted text. Compare original text with reverse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 * converted text. If not match, there is some problem on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 * converting. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 if (st == 0 && in_true > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 ByteCount rev_in, rev_out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 TextPtr buf_rev = (TextPtr)alloc(in_true);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 if (buf_rev)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 st = TECConvertText(cd->tecReverse,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 buf_out, out_true, &rev_in,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 buf_rev, in_true, &rev_out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 if (st != 0 || rev_in != out_true || rev_out != in_true
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 || memcmp(buf_rev, buf_in, rev_out) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 #ifdef ICONVOSX_DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 fprintf(stderr, " reverse conversion failed.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 st = kTECUnmappableElementErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 vim_free(buf_rev);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 st = kTECUnmappableElementErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 else if (!buf_in && buf_out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 /* Flush all buffered strings to buffer, and reset status */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 if (!outbytesleft)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 last_errno = EFAULT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 out_len = *outbytesleft;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 st = TECFlushText(cd->tec,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 buf_out, out_len, &out_true);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 else if (!buf_in && !buf_out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 /* Reset cd's status and cancel buffered strings */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 unsigned char tmp_out[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 buf_out = tmp_out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 out_len = sizeof(tmp_out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 st = TECFlushText(cd->tec,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 buf_out, out_len, &out_true);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 last_errno = EFAULT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 TRACE("st=%d, buf_in=%p, in_len=%d, in_true=%d\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 " buf_out=%p, out_len=%d, out_true=%d\n", (int)st,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 buf_in, (int)in_len, (int)in_true,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 buf_out, (int)out_len, (int)out_true);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 switch (st)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 case 0:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 /* No error */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 if (inbytesleft)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 *inbytesleft -= in_true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 if (outbytesleft)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 *outbytesleft -= out_true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 if (inbuf && *inbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 *inbuf += in_true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 if (outbuf && *outbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 *outbuf += out_true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 last_errno = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 return 0; /* No error */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 case kTECUnmappableElementErr:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 last_errno = EILSEQ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 case kTECIncompleteElementErr:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 last_errno = EINVAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 case kTECOutputBufferFullStatus:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 last_errno = E2BIG;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 TRACE("iconv(%p, %p, %p, %p, %p) failed. (%d)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 cd, inbuf, inbytesleft, outbuf, outbytesleft, (int)st);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 last_errno = EFAULT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 iconv_close(iconv_t cd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 if (cd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 /* Free all elements of iconv_t */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 if (cd->tec)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 TECDisposeConverter(cd->tec);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 if (cd->tecReverse)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 TECDisposeConverter(cd->tecReverse);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 if (cd->sniff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 TECDisposeSniffer(cd->sniff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 vim_free(cd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 last_errno = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 last_errno = EINVAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
539 int *
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 iconv_errno()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 return &last_errno;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 #endif /* MACOS_X_ICONVEMU */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 #ifdef USE_MCH_GETTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 #define GETTEXT_BUFNUM 64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 #define GETTEXT_BUFSIZE 256
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
551 char *
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
552 mch_gettext(const char *msgid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 static char buf[GETTEXT_BUFNUM][GETTEXT_BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 static int bufnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 const char *msg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 CFStringRef strkey = NULL, strmsg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 CFStringEncoding enc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 if (!msgid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 goto MCH_GETTEXT_FINISH;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 enc = CFStringGetSystemEncoding();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 TRACE("mch_gettext(%s)\n", msgid);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 strkey = CFStringCreateWithCString(NULL, msgid, enc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 if (!strkey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 TRACE(" Can't create a CFString for msgid.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 goto MCH_GETTEXT_FINISH;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 strmsg = CFCopyLocalizedString(strkey, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 if (!strmsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 TRACE(" No localized strings for msgid.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 goto MCH_GETTEXT_FINISH;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 msg = CFStringGetCStringPtr(strmsg, enc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 if (!msg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 /* This is as backup when CFStringGetCStringPtr was failed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 CFStringGetCString(strmsg, buf[bufnum], GETTEXT_BUFSIZE, enc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 msg = buf[bufnum];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 if (++bufnum >= GETTEXT_BUFNUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 bufnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 TRACE(" Localized to: %s\n", msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 MCH_GETTEXT_FINISH:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 if (strkey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 CFRelease(strkey);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 if (strmsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 CFRelease(strmsg);
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
595 return (char *)(msg ? msg : msgid);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
598 char *
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
599 mch_bindtextdomain(const char *domain, const char *dirname)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 TRACE("mch_bindtextdomain(%s, %s)\n", domain, dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 return (char*)dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
605 char *
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
606 mch_textdomain(const char *domain)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 TRACE("mch_textdomain(%s)\n", domain);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 return (char*)domain;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 #endif