suppressed gcc warning
@@ -6,7 +6,7 @@ | ||
6 | 6 | from setuptools import setup, Extension |
7 | 7 | |
8 | 8 | setup (name = "pykf", |
9 | - version = "0.3.5", | |
9 | + version = "0.3.6", | |
10 | 10 | description = "Japanese Kanji code filter", |
11 | 11 | author = "Atsuo Ishimoto", |
12 | 12 | author_email = "ishimoto@gembook.org", |
@@ -1,7 +1,7 @@ | ||
1 | 1 | |
2 | 2 | |
3 | 3 | /* kanji conversion tables */ |
4 | -extern int tbl_jis0213[]; | |
4 | +extern unsigned int tbl_jis0213[]; | |
5 | 5 | extern int tbl_sjis2jis[]; |
6 | 6 | extern int tbl_jis2sjis[]; |
7 | 7 |
@@ -9,17 +9,17 @@ | ||
9 | 9 | /* Japanese character encodings */ |
10 | 10 | enum {ERROR=-1, UNKNOWN=0, ASCII=1, SJIS=2, EUC=3, JIS=4, UTF8=5, UTF16_LE=7, UTF16_BE=8}; |
11 | 11 | |
12 | -int guess(int imax, char buf[], int strict); | |
13 | -int sjistojis(int len, char *buf, char **ret, int *retlen, int jis0208); | |
14 | -int euctojis(int len, char *buf, char **ret, int *retlen, int jis0208); | |
15 | -int sjistoeuc(int len, char *buf, char **ret, int *retlen); | |
16 | -int jistoeuc(int len, char *buf, char **ret, int *retlen); | |
17 | -int jistosjis(int len, char *buf, char **ret, int *retlen); | |
18 | -int euctosjis(int len, char *buf, char **ret, int *retlen); | |
12 | +int guess(int imax, unsigned char buf[], int strict); | |
13 | +int sjistojis(int len, unsigned char *buf, unsigned char **ret, int *retlen, int jis0208); | |
14 | +int euctojis(int len, unsigned char *buf, unsigned char **ret, int *retlen, int jis0208); | |
15 | +int sjistoeuc(int len, unsigned char *buf, unsigned char **ret, int *retlen); | |
16 | +int jistoeuc(int len, unsigned char *buf, unsigned char **ret, int *retlen); | |
17 | +int jistosjis(int len, unsigned char *buf, unsigned char **ret, int *retlen); | |
18 | +int euctosjis(int len, unsigned char *buf, unsigned char **ret, int *retlen); | |
19 | 19 | |
20 | -int sjistohankana(int len, char *buf, char **ret, int *retlen); | |
21 | -int euctohankana(int len, char *buf, char **ret, int *retlen); | |
22 | -int sjistofullkana(int len, char *buf, char **ret, int *retlen); | |
23 | -int euctofullkana(int len, char *buf, char **ret, int *retlen); | |
20 | +int sjistohankana(int len, unsigned char *buf, unsigned char **ret, int *retlen); | |
21 | +int euctohankana(int len, unsigned char *buf, unsigned char **ret, int *retlen); | |
22 | +int sjistofullkana(int len, unsigned char *buf, unsigned char **ret, int *retlen); | |
23 | +int euctofullkana(int len, unsigned char *buf, unsigned char **ret, int *retlen); | |
24 | 24 | |
25 | 25 |
@@ -55,7 +55,7 @@ | ||
55 | 55 | |
56 | 56 | |
57 | 57 | |
58 | -int guess(int imax, char buf[], int strict) | |
58 | +int guess(int imax, unsigned char buf[], int strict) | |
59 | 59 | { |
60 | 60 | int i, n; |
61 | 61 | int ascii, euc, sjis, utf8, bad_euc, bad_sjis, bad_utf8; |
@@ -339,12 +339,12 @@ | ||
339 | 339 | } |
340 | 340 | |
341 | 341 | LOCAL_INLINE |
342 | -void jis_to_sjis2(char *ph, char *pl); | |
342 | +void jis_to_sjis2(unsigned char *ph, unsigned char *pl); | |
343 | 343 | |
344 | 344 | LOCAL_INLINE |
345 | -int isjis0213(char h, char l) { | |
346 | - int *p; | |
347 | - int jis = (h << 8 | l) & 0xffff; | |
345 | +int isjis0213(unsigned char h, unsigned char l) { | |
346 | + unsigned int *p; | |
347 | + unsigned int jis = (h << 8 | l) & 0xffff; | |
348 | 348 | |
349 | 349 | for (p=tbl_jis0213; *(p+2) < jis; p+=2); |
350 | 350 |
@@ -358,7 +358,7 @@ | ||
358 | 358 | |
359 | 359 | |
360 | 360 | LOCAL_INLINE |
361 | -int mskanji_to_jis(char *ph, char *pl) { | |
361 | +int mskanji_to_jis(unsigned char *ph, unsigned char *pl) { | |
362 | 362 | int *p; |
363 | 363 | int sjis = (*ph << 8 | *pl) & 0xffff; |
364 | 364 |
@@ -379,7 +379,7 @@ | ||
379 | 379 | } |
380 | 380 | |
381 | 381 | LOCAL_INLINE |
382 | -void sjis_to_jis(char *ph, char *pl) | |
382 | +void sjis_to_jis(unsigned char *ph, unsigned char *pl) | |
383 | 383 | { |
384 | 384 | if (*ph <= 0x9f) { |
385 | 385 | if (*pl < 0x9f) |
@@ -389,7 +389,7 @@ | ||
389 | 389 | } else { |
390 | 390 | if (*pl < 0x9f) |
391 | 391 | *ph = (*ph << 1) - 0x161; |
392 | - else | |
392 | + else | |
393 | 393 | *ph = (*ph << 1) - 0x160; |
394 | 394 | } |
395 | 395 | if (*pl < 0x7f) |
@@ -401,7 +401,7 @@ | ||
401 | 401 | } |
402 | 402 | |
403 | 403 | LOCAL_INLINE |
404 | -void sjis_to_jis2(char *ph, char *pl) | |
404 | +void sjis_to_jis2(unsigned char *ph, unsigned char *pl) | |
405 | 405 | { |
406 | 406 | if (mskanji_to_jis(ph, pl)) |
407 | 407 | return; |
@@ -411,7 +411,7 @@ | ||
411 | 411 | |
412 | 412 | |
413 | 413 | LOCAL_INLINE |
414 | -void jis_to_sjis(char *ph, char *pl) | |
414 | +void jis_to_sjis(unsigned char *ph, unsigned char *pl) | |
415 | 415 | { |
416 | 416 | if (*ph & 1) { |
417 | 417 | if (*pl < 0x60) |
@@ -429,7 +429,7 @@ | ||
429 | 429 | |
430 | 430 | |
431 | 431 | LOCAL_INLINE |
432 | -int jis_to_mskanji(char *ph, char *pl) { | |
432 | +int jis_to_mskanji(unsigned char *ph, unsigned char *pl) { | |
433 | 433 | int *p; |
434 | 434 | int jis = (*ph << 8 | *pl) & 0xffff; |
435 | 435 |
@@ -446,7 +446,7 @@ | ||
446 | 446 | |
447 | 447 | |
448 | 448 | LOCAL_INLINE |
449 | -void jis_to_sjis2(char *ph, char *pl) | |
449 | +void jis_to_sjis2(unsigned char *ph, unsigned char *pl) | |
450 | 450 | { |
451 | 451 | if (jis_to_mskanji(ph, pl)) |
452 | 452 | return; |
@@ -458,12 +458,12 @@ | ||
458 | 458 | |
459 | 459 | |
460 | 460 | |
461 | -int sjistojis(int len, char *buf, char **ret, int *retlen, int j0208) | |
461 | +int sjistojis(int len, unsigned char *buf, unsigned char **ret, int *retlen, int j0208) | |
462 | 462 | { |
463 | - char c, d; | |
463 | + unsigned char c, d; | |
464 | 464 | int pos, tmplen, retpos=0; |
465 | 465 | char tmp[10]; |
466 | - char *newbuf; | |
466 | + unsigned char *newbuf; | |
467 | 467 | enum {NORMAL, KANJI, HANKANA, JIS0213} mode = NORMAL; |
468 | 468 | |
469 | 469 | if (!len) { |
@@ -570,12 +570,12 @@ | ||
570 | 570 | return 1; |
571 | 571 | } |
572 | 572 | |
573 | -int euctojis(int len, char *buf, char **ret, int *retlen, int j0208) | |
573 | +int euctojis(int len, unsigned char *buf, unsigned char **ret, int *retlen, int j0208) | |
574 | 574 | { |
575 | - char c, d; | |
575 | + unsigned char c, d; | |
576 | 576 | int pos, tmplen, retpos=0; |
577 | 577 | char tmp[10]; |
578 | - char *newbuf; | |
578 | + unsigned char *newbuf; | |
579 | 579 | enum {NORMAL, KANJI, HANKANA, JIS0213} mode = NORMAL; |
580 | 580 | |
581 | 581 | if (!len) { |
@@ -685,12 +685,12 @@ | ||
685 | 685 | } |
686 | 686 | |
687 | 687 | |
688 | -int sjistoeuc(int len, char *buf, char **ret, int *retlen) | |
688 | +int sjistoeuc(int len, unsigned char *buf, unsigned char **ret, int *retlen) | |
689 | 689 | { |
690 | - char c, d; | |
690 | + unsigned char c, d; | |
691 | 691 | int pos, tmplen, retpos=0; |
692 | 692 | char tmp[10]; |
693 | - char *newbuf; | |
693 | + unsigned char *newbuf; | |
694 | 694 | |
695 | 695 | if (!len) { |
696 | 696 | *retlen = 0; |
@@ -753,11 +753,11 @@ | ||
753 | 753 | return 1; |
754 | 754 | } |
755 | 755 | |
756 | -int jistoeuc(int len, char *buf, char **ret, int *retlen) | |
756 | +int jistoeuc(int len, unsigned char *buf, unsigned char **ret, int *retlen) | |
757 | 757 | { |
758 | 758 | int pos, tmplen, retpos=0; |
759 | 759 | char tmp[10]; |
760 | - char *newbuf; | |
760 | + unsigned char *newbuf; | |
761 | 761 | |
762 | 762 | enum {NORMAL, KANJI, HANKANA} mode = NORMAL; |
763 | 763 |
@@ -846,12 +846,12 @@ | ||
846 | 846 | } |
847 | 847 | |
848 | 848 | |
849 | -int jistosjis(int len, char *buf, char **ret, int *retlen) | |
849 | +int jistosjis(int len, unsigned char *buf, unsigned char **ret, int *retlen) | |
850 | 850 | { |
851 | - char c, d; | |
851 | + unsigned char c, d; | |
852 | 852 | int pos, tmplen, retpos=0; |
853 | 853 | char tmp[10]; |
854 | - char *newbuf; | |
854 | + unsigned char *newbuf; | |
855 | 855 | |
856 | 856 | enum {NORMAL, KANJI, HANKANA} mode = NORMAL; |
857 | 857 |
@@ -942,12 +942,12 @@ | ||
942 | 942 | return 1; |
943 | 943 | } |
944 | 944 | |
945 | -int euctosjis(int len, char *buf, char **ret, int *retlen) | |
945 | +int euctosjis(int len, unsigned char *buf, unsigned char **ret, int *retlen) | |
946 | 946 | { |
947 | - char c, d; | |
947 | + unsigned char c, d; | |
948 | 948 | int pos, tmplen, retpos=0; |
949 | 949 | char tmp[10]; |
950 | - char *newbuf; | |
950 | + unsigned char *newbuf; | |
951 | 951 | |
952 | 952 | if (!len) { |
953 | 953 | *retlen = 0; |
@@ -1009,7 +1009,7 @@ | ||
1009 | 1009 | return 1; |
1010 | 1010 | } |
1011 | 1011 | |
1012 | -static const char *h_kana[] = { | |
1012 | +static const char *s_h_kana[] = { | |
1013 | 1013 | "\xdd", "\xdc", "\xdb", "\xda", "\xd9", "\xd8", "\xd7", "\xd6", "\xd5", "\xd4", |
1014 | 1014 | "\xd3", "\xd2", "\xd1", "\xd0", "\xcf", "\xce\xdf", "\xce\xde", "\xce", "\xcd\xdf", |
1015 | 1015 | "\xcd\xde", "\xcd", "\xcc\xdf", "\xcc\xde", "\xcc", "\xcb\xdf", "\xcb\xde", |
@@ -1021,7 +1021,9 @@ | ||
1021 | 1021 | "\xb3", "\xb2", "\xb1", "\xb0", "\xaf", "\xae", "\xad", "\xac", "\xab", |
1022 | 1022 | "\xaa", "\xa9", "\xa8", "\xa7", "\xa6", "\xa5", "\xa4", "\xa3", "\xa2", "\xa1", NULL}; |
1023 | 1023 | |
1024 | -static const char *euc_h_kana[] = { | |
1024 | +static const unsigned char **h_kana = (const unsigned char **)s_h_kana; | |
1025 | + | |
1026 | +static const char *s_euc_h_kana[] = { | |
1025 | 1027 | "\x8e\xdd", "\x8e\xdc", "\x8e\xdb", "\x8e\xda", "\x8e\xd9", "\x8e\xd8", "\x8e\xd7", "\x8e\xd6", "\x8e\xd5", "\x8e\xd4", |
1026 | 1028 | "\x8e\xd3", "\x8e\xd2", "\x8e\xd1", "\x8e\xd0", "\x8e\xcf", "\x8e\xce\x8e\xdf", "\x8e\xce\x8e\xde", "\x8e\xce", "\x8e\xcd\x8e\xdf", |
1027 | 1029 | "\x8e\xcd\x8e\xde", "\x8e\xcd", "\x8e\xcc\x8e\xdf", "\x8e\xcc\x8e\xde", "\x8e\xcc", "\x8e\xcb\x8e\xdf", "\x8e\xcb\x8e\xde", |
@@ -1033,7 +1035,11 @@ | ||
1033 | 1035 | "\x8e\xb3", "\x8e\xb2", "\x8e\xb1", "\x8e\xb0", "\x8e\xaf", "\x8e\xae", "\x8e\xad", "\x8e\xac", "\x8e\xab", |
1034 | 1036 | "\x8e\xaa", "\x8e\xa9", "\x8e\xa8", "\x8e\xa7", "\x8e\xa6", "\x8e\xa5", "\x8e\xa4", "\x8e\xa3", "\x8e\xa2", "\x8e\xa1", NULL}; |
1035 | 1037 | |
1036 | -static const char *sjis_f_kana[] = { | |
1038 | +static const unsigned char **euc_h_kana = (const unsigned char **)s_euc_h_kana; | |
1039 | + | |
1040 | + | |
1041 | + | |
1042 | +static const char *s_sjis_f_kana[] = { | |
1037 | 1043 | "\x83\x93", "\x83\x8f", "\x83\x8d", "\x83\x8c", "\x83\x8b", "\x83\x8a", |
1038 | 1044 | "\x83\x89", "\x83\x88", "\x83\x86", "\x83\x84", "\x83\x82", "\x83\x81", |
1039 | 1045 | "\x83\x80", "\x83\x7e", "\x83\x7d", "\x83\x7c", "\x83\x7b", "\x83\x7a", |
@@ -1050,8 +1056,10 @@ | ||
1050 | 1056 | "\x83\x44", "\x83\x42", "\x83\x40", "\x83\x92", "\x81\x45", "\x81\x41", |
1051 | 1057 | "\x81\x76", "\x81\x75", "\x81\x42", NULL}; |
1052 | 1058 | |
1059 | +static const unsigned char **sjis_f_kana = (const unsigned char **)s_sjis_f_kana; | |
1053 | 1060 | |
1054 | -static const char *euc_f_kana[] = { | |
1061 | + | |
1062 | +static const char *s_euc_f_kana[] = { | |
1055 | 1063 | "\xa5\xf3", "\xa5\xef", "\xa5\xed", "\xa5\xec", "\xa5\xeb", "\xa5\xea", |
1056 | 1064 | "\xa5\xe9", "\xa5\xe8", "\xa5\xe6", "\xa5\xe4", "\xa5\xe2", "\xa5\xe1", |
1057 | 1065 | "\xa5\xe0", "\xa5\xdf", "\xa5\xde", "\xa5\xdd", "\xa5\xdc", "\xa5\xdb", |
@@ -1068,11 +1076,12 @@ | ||
1068 | 1076 | "\xa5\xa5", "\xa5\xa3", "\xa5\xa1", "\xa5\xf2", "\xa1\xa6", "\xa1\xa2", |
1069 | 1077 | "\xa1\xd7", "\xa1\xd6", "\xa1\xa3", NULL}; |
1070 | 1078 | |
1079 | +static const unsigned char **euc_f_kana = (const unsigned char **)s_euc_f_kana; | |
1071 | 1080 | |
1072 | -int sjistohankana(int len, char *buf, char **ret, int *retlen) { | |
1081 | +int sjistohankana(int len, unsigned char *buf, unsigned char **ret, int *retlen) { | |
1073 | 1082 | int pos, tmplen, retpos=0; |
1074 | 1083 | char tmp[10]; |
1075 | - char *newbuf; | |
1084 | + unsigned char *newbuf; | |
1076 | 1085 | int i; |
1077 | 1086 | |
1078 | 1087 | if (!len) { |
@@ -1142,10 +1151,10 @@ | ||
1142 | 1151 | } |
1143 | 1152 | |
1144 | 1153 | |
1145 | -int sjistofullkana(int len, char *buf, char **ret, int *retlen) { | |
1154 | +int sjistofullkana(int len, unsigned char *buf, unsigned char **ret, int *retlen) { | |
1146 | 1155 | int pos, tmplen, retpos=0; |
1147 | 1156 | char tmp[10]; |
1148 | - char *newbuf; | |
1157 | + unsigned char *newbuf; | |
1149 | 1158 | int i, j; |
1150 | 1159 | |
1151 | 1160 | if (!len) { |
@@ -1170,7 +1179,7 @@ | ||
1170 | 1179 | } |
1171 | 1180 | } |
1172 | 1181 | if (!h_kana[i][j]) { |
1173 | - const char *p; | |
1182 | + const unsigned char *p; | |
1174 | 1183 | for (p = sjis_f_kana[i]; *p; p++) { |
1175 | 1184 | tmp[tmplen++] = *p; |
1176 | 1185 | } |
@@ -1223,10 +1232,10 @@ | ||
1223 | 1232 | return 1; |
1224 | 1233 | } |
1225 | 1234 | |
1226 | -int euctohankana(int len, char *buf, char **ret, int *retlen) { | |
1235 | +int euctohankana(int len, unsigned char *buf, unsigned char **ret, int *retlen) { | |
1227 | 1236 | int pos, tmplen, retpos=0; |
1228 | 1237 | char tmp[10]; |
1229 | - char *newbuf; | |
1238 | + unsigned char *newbuf; | |
1230 | 1239 | int i; |
1231 | 1240 | |
1232 | 1241 | if (!len) { |
@@ -1302,10 +1311,10 @@ | ||
1302 | 1311 | } |
1303 | 1312 | |
1304 | 1313 | |
1305 | -int euctofullkana(int len, char *buf, char **ret, int *retlen) { | |
1314 | +int euctofullkana(int len, unsigned char *buf, unsigned char **ret, int *retlen) { | |
1306 | 1315 | int pos, tmplen, retpos=0; |
1307 | 1316 | char tmp[10]; |
1308 | - char *newbuf; | |
1317 | + unsigned char *newbuf; | |
1309 | 1318 | int i, j; |
1310 | 1319 | |
1311 | 1320 | if (!len) { |
@@ -1330,7 +1339,7 @@ | ||
1330 | 1339 | } |
1331 | 1340 | } |
1332 | 1341 | if (!euc_h_kana[i][j]) { |
1333 | - const char *p; | |
1342 | + const unsigned char *p; | |
1334 | 1343 | for (p = euc_f_kana[i]; *p; p++) { |
1335 | 1344 | tmp[tmplen++] = *p; |
1336 | 1345 | } |
@@ -110,7 +110,7 @@ | ||
110 | 110 | static PyObject* |
111 | 111 | pykf_guess(PyObject* self, PyObject* args) |
112 | 112 | { |
113 | - char *s; | |
113 | + unsigned char *s; | |
114 | 114 | int ret, len; |
115 | 115 | int strict = check_strict; |
116 | 116 |
@@ -129,7 +129,7 @@ | ||
129 | 129 | static PyObject* |
130 | 130 | pykf_tojis(PyObject* self, PyObject* args, PyObject* kwds) |
131 | 131 | { |
132 | - char *s, *conv; | |
132 | + unsigned char *s, *conv; | |
133 | 133 | int enc=UNKNOWN, len, convlen; |
134 | 134 | PyObject *ret; |
135 | 135 | int strict = check_strict; |
@@ -156,7 +156,7 @@ | ||
156 | 156 | case SJIS: |
157 | 157 | if (sjistojis(len, s, &conv, &convlen, j0208)) { |
158 | 158 | if (convlen) { |
159 | - ret = PyString_FromStringAndSize(conv, convlen); | |
159 | + ret = PyString_FromStringAndSize((char*)conv, convlen); | |
160 | 160 | free(conv); |
161 | 161 | } |
162 | 162 | else { |
@@ -168,7 +168,7 @@ | ||
168 | 168 | case EUC: |
169 | 169 | if (euctojis(len, s, &conv, &convlen, j0208)) { |
170 | 170 | if (convlen) { |
171 | - ret = PyString_FromStringAndSize(conv, convlen); | |
171 | + ret = PyString_FromStringAndSize((char*)conv, convlen); | |
172 | 172 | free(conv); |
173 | 173 | } |
174 | 174 | else { |
@@ -179,7 +179,7 @@ | ||
179 | 179 | break; |
180 | 180 | case JIS: |
181 | 181 | case ASCII: |
182 | - return PyString_FromStringAndSize(s, len); | |
182 | + return PyString_FromStringAndSize((char*)s, len); | |
183 | 183 | default: |
184 | 184 | BADENCODING(enc); return NULL; |
185 | 185 | } |
@@ -193,7 +193,7 @@ | ||
193 | 193 | static PyObject* |
194 | 194 | pykf_toeuc(PyObject* self, PyObject* args, PyObject* kwds) |
195 | 195 | { |
196 | - char *s, *conv; | |
196 | + unsigned char *s, *conv; | |
197 | 197 | int enc=UNKNOWN, len, convlen; |
198 | 198 | PyObject *ret; |
199 | 199 | int strict = check_strict; |
@@ -218,7 +218,7 @@ | ||
218 | 218 | case SJIS: |
219 | 219 | if (sjistoeuc(len, s, &conv, &convlen)) { |
220 | 220 | if (convlen) { |
221 | - ret = PyString_FromStringAndSize(conv, convlen); | |
221 | + ret = PyString_FromStringAndSize((char*)conv, convlen); | |
222 | 222 | free(conv); |
223 | 223 | } |
224 | 224 | else { |
@@ -230,7 +230,7 @@ | ||
230 | 230 | case JIS: |
231 | 231 | if (jistoeuc(len, s, &conv, &convlen)) { |
232 | 232 | if (convlen) { |
233 | - ret = PyString_FromStringAndSize(conv, convlen); | |
233 | + ret = PyString_FromStringAndSize((char*)conv, convlen); | |
234 | 234 | free(conv); |
235 | 235 | } |
236 | 236 | else { |
@@ -241,7 +241,7 @@ | ||
241 | 241 | break; |
242 | 242 | case EUC: |
243 | 243 | case ASCII: |
244 | - return PyString_FromStringAndSize(s, len); | |
244 | + return PyString_FromStringAndSize((char*)s, len); | |
245 | 245 | default: |
246 | 246 | BADENCODING(enc); return NULL; |
247 | 247 | } |
@@ -256,7 +256,7 @@ | ||
256 | 256 | static PyObject* |
257 | 257 | pykf_tosjis(PyObject* self, PyObject* args, PyObject *kwds) |
258 | 258 | { |
259 | - char *s, *conv; | |
259 | + unsigned char *s, *conv; | |
260 | 260 | int enc=UNKNOWN, len, convlen; |
261 | 261 | PyObject *ret; |
262 | 262 | int strict = check_strict; |
@@ -281,11 +281,11 @@ | ||
281 | 281 | switch (enc) { |
282 | 282 | case SJIS: |
283 | 283 | case ASCII: |
284 | - return PyString_FromStringAndSize(s, len); | |
284 | + return PyString_FromStringAndSize((char*)s, len); | |
285 | 285 | case JIS: |
286 | 286 | if (jistosjis(len, s, &conv, &convlen)) { |
287 | 287 | if (convlen) { |
288 | - ret = PyString_FromStringAndSize(conv, convlen); | |
288 | + ret = PyString_FromStringAndSize((char*)conv, convlen); | |
289 | 289 | free(conv); |
290 | 290 | } |
291 | 291 | else { |
@@ -297,7 +297,7 @@ | ||
297 | 297 | case EUC: |
298 | 298 | if (euctosjis(len, s, &conv, &convlen)) { |
299 | 299 | if (convlen) { |
300 | - ret = PyString_FromStringAndSize(conv, convlen); | |
300 | + ret = PyString_FromStringAndSize((char*)conv, convlen); | |
301 | 301 | free(conv); |
302 | 302 | } |
303 | 303 | else { |
@@ -319,7 +319,7 @@ | ||
319 | 319 | static PyObject* |
320 | 320 | pykf_tohalfkana(PyObject* self, PyObject* args, PyObject *kwds) |
321 | 321 | { |
322 | - char *s, *conv; | |
322 | + unsigned char *s, *conv; | |
323 | 323 | int enc=UNKNOWN, len, convlen; |
324 | 324 | PyObject *ret; |
325 | 325 | int strict = check_strict; |
@@ -344,7 +344,7 @@ | ||
344 | 344 | case SJIS: |
345 | 345 | if (sjistohankana(len, s, &conv, &convlen)) { |
346 | 346 | if (convlen) { |
347 | - ret = PyString_FromStringAndSize(conv, convlen); | |
347 | + ret = PyString_FromStringAndSize((char*)conv, convlen); | |
348 | 348 | free(conv); |
349 | 349 | } |
350 | 350 | else { |
@@ -356,7 +356,7 @@ | ||
356 | 356 | case EUC: |
357 | 357 | if (euctohankana(len, s, &conv, &convlen)) { |
358 | 358 | if (convlen) { |
359 | - ret = PyString_FromStringAndSize(conv, convlen); | |
359 | + ret = PyString_FromStringAndSize((char*)conv, convlen); | |
360 | 360 | free(conv); |
361 | 361 | } |
362 | 362 | else { |
@@ -379,7 +379,7 @@ | ||
379 | 379 | static PyObject* |
380 | 380 | pykf_tofullkana(PyObject* self, PyObject* args, PyObject *kwds) |
381 | 381 | { |
382 | - char *s, *conv; | |
382 | + unsigned char *s, *conv; | |
383 | 383 | int enc=UNKNOWN, len, convlen; |
384 | 384 | int strict = check_strict; |
385 | 385 | PyObject *ret; |
@@ -405,7 +405,7 @@ | ||
405 | 405 | case SJIS: |
406 | 406 | if (sjistofullkana(len, s, &conv, &convlen)) { |
407 | 407 | if (convlen) { |
408 | - ret = PyString_FromStringAndSize(conv, convlen); | |
408 | + ret = PyString_FromStringAndSize((char*)conv, convlen); | |
409 | 409 | free(conv); |
410 | 410 | } |
411 | 411 | else { |
@@ -417,7 +417,7 @@ | ||
417 | 417 | case EUC: |
418 | 418 | if (euctofullkana(len, s, &conv, &convlen)) { |
419 | 419 | if (convlen) { |
420 | - ret = PyString_FromStringAndSize(conv, convlen); | |
420 | + ret = PyString_FromStringAndSize((char*)conv, convlen); | |
421 | 421 | free(conv); |
422 | 422 | } |
423 | 423 | else { |
@@ -440,7 +440,7 @@ | ||
440 | 440 | static PyObject* |
441 | 441 | pykf_split(PyObject* self, PyObject* args, PyObject *kwds) |
442 | 442 | { |
443 | - char *s; | |
443 | + unsigned char *s; | |
444 | 444 | int enc=UNKNOWN, len; |
445 | 445 | int pos; |
446 | 446 | PyObject *ret, *o; |
@@ -471,11 +471,11 @@ | ||
471 | 471 | case SJIS: |
472 | 472 | for (pos = 0; pos < len; pos++) { |
473 | 473 | if (issjis1(s[pos]) && (pos + 1 < len) && issjis2(s[pos+1])) { |
474 | - o = PyString_FromStringAndSize(s+pos, 2); | |
474 | + o = PyString_FromStringAndSize((char*)s+pos, 2); | |
475 | 475 | pos++; |
476 | 476 | } |
477 | 477 | else { |
478 | - o = PyString_FromStringAndSize(s+pos, 1); | |
478 | + o = PyString_FromStringAndSize((char*)s+pos, 1); | |
479 | 479 | } |
480 | 480 | if (!o) { |
481 | 481 | Py_DECREF(ret); |
@@ -490,7 +490,7 @@ | ||
490 | 490 | return ret; |
491 | 491 | case ASCII: |
492 | 492 | for (pos = 0; pos < len; pos++) { |
493 | - o = PyString_FromStringAndSize(s+pos, 1); | |
493 | + o = PyString_FromStringAndSize((char*)s+pos, 1); | |
494 | 494 | if (!o) { |
495 | 495 | Py_DECREF(ret); |
496 | 496 | return NULL; |
@@ -510,12 +510,12 @@ | ||
510 | 510 | !memcmp(s+pos, "\x1b$B", 3))) { |
511 | 511 | |
512 | 512 | mode = KANJI; |
513 | - o = PyString_FromStringAndSize(s+pos, 3); | |
513 | + o = PyString_FromStringAndSize((char*)s+pos, 3); | |
514 | 514 | pos += 2; |
515 | 515 | } |
516 | 516 | else if ((pos + 3 < len) && !memcmp(s+pos, "\x1b$(O", 4)) { |
517 | 517 | mode = KANJI; |
518 | - o = PyString_FromStringAndSize(s+pos, 3); | |
518 | + o = PyString_FromStringAndSize((char*)s+pos, 3); | |
519 | 519 | pos += 3; |
520 | 520 | } |
521 | 521 | else if ((pos + 2 < len) && |
@@ -523,29 +523,29 @@ | ||
523 | 523 | !memcmp(s+pos, "\x1b(J", 3))) { |
524 | 524 | |
525 | 525 | mode = NORMAL; |
526 | - o = PyString_FromStringAndSize(s+pos, 3); | |
526 | + o = PyString_FromStringAndSize((char*)s+pos, 3); | |
527 | 527 | pos += 2; |
528 | 528 | } |
529 | 529 | else if ((pos + 2 < len) && !memcmp(s+pos, "\x1b(I", 3)) { |
530 | 530 | mode = HANKANA; |
531 | - o = PyString_FromStringAndSize(s+pos, 3); | |
531 | + o = PyString_FromStringAndSize((char*)s+pos, 3); | |
532 | 532 | pos += 2; |
533 | 533 | } |
534 | 534 | else if (s[pos] == '\x0e') { |
535 | 535 | mode = HANKANA; |
536 | - o = PyString_FromStringAndSize(s+pos, 1); | |
536 | + o = PyString_FromStringAndSize((char*)s+pos, 1); | |
537 | 537 | } |
538 | 538 | else if (s[pos] == '\x0f') { |
539 | 539 | mode = NORMAL; |
540 | - o = PyString_FromStringAndSize(s+pos, 1); | |
540 | + o = PyString_FromStringAndSize((char*)s+pos, 1); | |
541 | 541 | } |
542 | 542 | else if (mode == KANJI && isjis(s[pos]) && (pos+1 < len) && isjis(s[pos+1])) { |
543 | - o = PyString_FromStringAndSize(s+pos, 2); | |
543 | + o = PyString_FromStringAndSize((char*)s+pos, 2); | |
544 | 544 | pos++; |
545 | 545 | } else if (mode == HANKANA && s[pos] >= 0x20 && s[pos] <= 0x5f) { |
546 | - o = PyString_FromStringAndSize(s+pos, 1); | |
546 | + o = PyString_FromStringAndSize((char*)s+pos, 1); | |
547 | 547 | } else { |
548 | - o = PyString_FromStringAndSize(s+pos, 1); | |
548 | + o = PyString_FromStringAndSize((char*)s+pos, 1); | |
549 | 549 | } |
550 | 550 | if (!o) { |
551 | 551 | Py_DECREF(ret); |
@@ -561,14 +561,14 @@ | ||
561 | 561 | case EUC: |
562 | 562 | for (pos = 0; pos < len; pos++) { |
563 | 563 | if (iseuc(s[pos]) && (pos + 1 < len) && iseuc(s[pos+1])) { |
564 | - o = PyString_FromStringAndSize(s+pos, 2); | |
564 | + o = PyString_FromStringAndSize((char*)s+pos, 2); | |
565 | 565 | pos++; |
566 | 566 | } else if ((s[pos] == 0x8e) && (pos + 1 < len) && ishankana(s[pos+1])) { |
567 | - o = PyString_FromStringAndSize(s+pos, 2); | |
567 | + o = PyString_FromStringAndSize((char*)s+pos, 2); | |
568 | 568 | pos++; |
569 | 569 | } |
570 | 570 | else { |
571 | - o = PyString_FromStringAndSize(s+pos, 1); | |
571 | + o = PyString_FromStringAndSize((char*)s+pos, 1); | |
572 | 572 | } |
573 | 573 | if (!o) { |
574 | 574 | Py_DECREF(ret); |