nkfのGitリポジトリのfork
Révision | 5d213c263b33494a0af1e45cf3414151f0daaf2e (tree) |
---|---|
l'heure | 2010-04-14 09:20:25 |
Auteur | NARUSE, Yui <naruse@user...> |
Commiter | NARUSE, Yui |
Refix [nkf-bug:21393]. (explicit -X)
patched by Anonymous person:
http://sourceforge.jp/ticket/browse.php?group_id=248&tid=21393
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* |
2 | 2 | * Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA). |
3 | - * Copyright (c) 1996-2009, The nkf Project. | |
3 | + * Copyright (c) 1996-2010, The nkf Project. | |
4 | 4 | * |
5 | 5 | * This software is provided 'as-is', without any express or implied |
6 | 6 | * warranty. In no event will the authors be held liable for any damages |
@@ -21,7 +21,7 @@ | ||
21 | 21 | * 3. This notice may not be removed or altered from any source distribution. |
22 | 22 | */ |
23 | 23 | #define NKF_VERSION "2.1.1" |
24 | -#define NKF_RELEASE_DATE "2010-04-13" | |
24 | +#define NKF_RELEASE_DATE "2010-04-14" | |
25 | 25 | #define COPY_RIGHT \ |
26 | 26 | "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).\n" \ |
27 | 27 | "Copyright (C) 1996-2010, The nkf Project." |
@@ -382,6 +382,8 @@ static unsigned char stdibuf[IOBUF_SIZE]; | ||
382 | 382 | static unsigned char stdobuf[IOBUF_SIZE]; |
383 | 383 | #endif |
384 | 384 | |
385 | +#define NKF_UNSPECIFIED (-TRUE) | |
386 | + | |
385 | 387 | /* flags */ |
386 | 388 | static int unbuf_f = FALSE; |
387 | 389 | static int estab_f = FALSE; |
@@ -396,7 +398,7 @@ static int mimebuf_f = FALSE; /* MIME buffered input */ | ||
396 | 398 | static int broken_f = FALSE; /* convert ESC-less broken JIS */ |
397 | 399 | static int iso8859_f = FALSE; /* ISO8859 through */ |
398 | 400 | static int mimeout_f = FALSE; /* base64 mode */ |
399 | -static int x0201_f = X0201_DEFAULT; /* convert JIS X 0201 */ | |
401 | +static int x0201_f = NKF_UNSPECIFIED; /* convert JIS X 0201 */ | |
400 | 402 | static int iso2022jp_f = FALSE; /* replace non ISO-2022-JP with GETA */ |
401 | 403 | |
402 | 404 | #ifdef UNICODE_NORMALIZATION |
@@ -1209,7 +1211,7 @@ set_input_encoding(nkf_encoding *enc) | ||
1209 | 1211 | case CP50220: |
1210 | 1212 | case CP50221: |
1211 | 1213 | case CP50222: |
1212 | - x0201_f = FALSE; | |
1214 | + if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */ | |
1213 | 1215 | #ifdef SHIFTJIS_CP932 |
1214 | 1216 | cp51932_f = TRUE; |
1215 | 1217 | #endif |
@@ -1231,7 +1233,7 @@ set_input_encoding(nkf_encoding *enc) | ||
1231 | 1233 | case SHIFT_JIS: |
1232 | 1234 | break; |
1233 | 1235 | case WINDOWS_31J: |
1234 | - x0201_f = FALSE; | |
1236 | + if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */ | |
1235 | 1237 | #ifdef SHIFTJIS_CP932 |
1236 | 1238 | cp51932_f = TRUE; |
1237 | 1239 | #endif |
@@ -1253,7 +1255,7 @@ set_input_encoding(nkf_encoding *enc) | ||
1253 | 1255 | case EUCJP_NKF: |
1254 | 1256 | break; |
1255 | 1257 | case CP51932: |
1256 | - x0201_f = FALSE; | |
1258 | + if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */ | |
1257 | 1259 | #ifdef SHIFTJIS_CP932 |
1258 | 1260 | cp51932_f = TRUE; |
1259 | 1261 | #endif |
@@ -1324,7 +1326,7 @@ set_output_encoding(nkf_encoding *enc) | ||
1324 | 1326 | { |
1325 | 1327 | switch (nkf_enc_to_index(enc)) { |
1326 | 1328 | case CP50220: |
1327 | - x0201_f = TRUE; | |
1329 | + if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */ | |
1328 | 1330 | #ifdef SHIFTJIS_CP932 |
1329 | 1331 | if (cp932inv_f == TRUE) cp932inv_f = FALSE; |
1330 | 1332 | #endif |
@@ -1333,7 +1335,7 @@ set_output_encoding(nkf_encoding *enc) | ||
1333 | 1335 | #endif |
1334 | 1336 | break; |
1335 | 1337 | case CP50221: |
1336 | - x0201_f = FALSE; | |
1338 | + if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */ | |
1337 | 1339 | #ifdef SHIFTJIS_CP932 |
1338 | 1340 | if (cp932inv_f == TRUE) cp932inv_f = FALSE; |
1339 | 1341 | #endif |
@@ -1362,7 +1364,7 @@ set_output_encoding(nkf_encoding *enc) | ||
1362 | 1364 | case SHIFT_JIS: |
1363 | 1365 | break; |
1364 | 1366 | case WINDOWS_31J: |
1365 | - x0201_f = FALSE; | |
1367 | + if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */ | |
1366 | 1368 | #ifdef UTF8_OUTPUT_ENABLE |
1367 | 1369 | ms_ucs_map_f = UCS_MAP_CP932; |
1368 | 1370 | #endif |
@@ -1391,7 +1393,7 @@ set_output_encoding(nkf_encoding *enc) | ||
1391 | 1393 | #endif |
1392 | 1394 | break; |
1393 | 1395 | case CP51932: |
1394 | - x0201_f = FALSE; | |
1396 | + if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */ | |
1395 | 1397 | #ifdef SHIFTJIS_CP932 |
1396 | 1398 | if (cp932inv_f == TRUE) cp932inv_f = FALSE; |
1397 | 1399 | #endif |
@@ -5188,7 +5190,7 @@ reinit(void) | ||
5188 | 5190 | broken_f = FALSE; |
5189 | 5191 | iso8859_f = FALSE; |
5190 | 5192 | mimeout_f = FALSE; |
5191 | - x0201_f = X0201_DEFAULT; | |
5193 | + x0201_f = NKF_UNSPECIFIED; | |
5192 | 5194 | iso2022jp_f = FALSE; |
5193 | 5195 | #if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE) |
5194 | 5196 | ms_ucs_map_f = UCS_MAP_ASCII; |
@@ -5301,6 +5303,10 @@ module_connection(void) | ||
5301 | 5303 | if (nkf_enc_unicode_p(output_encoding)) |
5302 | 5304 | output_mode = UTF_8; |
5303 | 5305 | |
5306 | + if (x0201_f == NKF_UNSPECIFIED) { | |
5307 | + x0201_f = X0201_DEFAULT; | |
5308 | + } | |
5309 | + | |
5304 | 5310 | /* replace continucation module, from output side */ |
5305 | 5311 | |
5306 | 5312 | /* output redicrection */ |
@@ -2,8 +2,6 @@ | ||
2 | 2 | # |
3 | 3 | # nkf test program for nkf-2 |
4 | 4 | # |
5 | -# $Id: nkf_test.pl,v 1.31 2008/11/18 21:43:19 naruse Exp $ | |
6 | -# | |
7 | 5 | # Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
8 | 6 | # Sun Aug 18 12:25:40 JST 1996 |
9 | 7 | # Sun Nov 8 00:16:06 JST 1998 |
@@ -1041,11 +1039,16 @@ printf "%-40s", "[nkf-forum:48850] "; | ||
1041 | 1039 | "From: =?ISO-2022-JP?B?GyRCJCIkIiQiJCIkIiQiJCIkIiQiGyhC?=" . |
1042 | 1040 | " <x-xxxx@xxxxxxxxxxxx.co.jp>\n"); |
1043 | 1041 | |
1044 | -printf "%-40s", "[nkf-bug:21393] "; | |
1042 | +printf "%-40s", "[nkf-bug:21393]-x "; | |
1045 | 1043 | &test("$nkf --ic=UTF-8 --oc=CP932", |
1046 | 1044 | "\xEF\xBD\xBC\xEF\xBE\x9E\xEF\xBD\xAC\xEF\xBD\xB0\xEF\xBE\x8F\xEF\xBE\x9D\xEF\xBD\xA5\xEF\xBE\x8E\xEF\xBE\x9F\xEF\xBE\x83\xEF\xBE\x84\xEF\xBD\xA1", |
1047 | 1045 | "\xBC\xDE\xAC\xB0\xCF\xDD\xA5\xCE\xDF\xC3\xC4\xA1"); |
1048 | 1046 | |
1047 | +printf "%-40s", "[nkf-bug:21393]-X "; | |
1048 | + &test("$nkf --ic=UTF-8 --oc=CP932 -X", | |
1049 | + "\xEF\xBD\xBC\xEF\xBE\x9E\xEF\xBD\xAC\xEF\xBD\xB0\xEF\xBE\x8F\xEF\xBE\x9D\xEF\xBD\xA5\xEF\xBE\x8E\xEF\xBE\x9F\xEF\xBE\x83\xEF\xBE\x84\xEF\xBD\xA1", | |
1050 | + "\x83W\x83\x83\x81[\x83}\x83\x93\x81E\x83|\x83e\x83g\x81B"); | |
1051 | + | |
1049 | 1052 | if (!NKF) { |
1050 | 1053 | printf "%-40s", "Guess NL"; |
1051 | 1054 | &command_tests( |