Skip to content

Commit 96b32a0

Browse files
committed
Merge nkf v2.1.5
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 2812ffc commit 96b32a0

File tree

3 files changed

+120
-93
lines changed

3 files changed

+120
-93
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,10 @@ sufficient information, see the ChangeLog file or Redmine
426426
* Add Net::HTTPClientException to deprecate Net::HTTPServerException,
427427
whose name is misleading. [Bug #14688]
428428

429+
[NKF]
430+
431+
* Upgrade to nkf v2.1.5
432+
429433
[Psych]
430434

431435
* Upgrade to Psych 3.1.0.pre2

ext/nkf/nkf-utf8/nkf.c

+32-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
3-
* Copyright (c) 1996-2013, The nkf Project.
3+
* Copyright (c) 1996-2018, The nkf Project.
44
*
55
* This software is provided 'as-is', without any express or implied
66
* warranty. In no event will the authors be held liable for any damages
@@ -20,11 +20,11 @@
2020
*
2121
* 3. This notice may not be removed or altered from any source distribution.
2222
*/
23-
#define NKF_VERSION "2.1.4"
24-
#define NKF_RELEASE_DATE "2015-12-12"
23+
#define NKF_VERSION "2.1.5"
24+
#define NKF_RELEASE_DATE "2018-12-15"
2525
#define COPY_RIGHT \
2626
"Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).\n" \
27-
"Copyright (C) 1996-2015, The nkf Project."
27+
"Copyright (C) 1996-2018, The nkf Project."
2828

2929
#include "config.h"
3030
#include "nkf.h"
@@ -1111,18 +1111,26 @@ encode_fallback_java(nkf_char c)
11111111
(*oconv)(0, '\\');
11121112
c &= VALUE_MASK;
11131113
if(!nkf_char_unicode_bmp_p(c)){
1114-
(*oconv)(0, 'U');
1115-
(*oconv)(0, '0');
1116-
(*oconv)(0, '0');
1117-
(*oconv)(0, bin2hex(c>>20));
1118-
(*oconv)(0, bin2hex(c>>16));
1114+
int high = (c >> 10) + NKF_INT32_C(0xD7C0); /* high surrogate */
1115+
int low = (c & 0x3FF) + NKF_INT32_C(0xDC00); /* low surrogate */
1116+
(*oconv)(0, 'u');
1117+
(*oconv)(0, bin2hex(high>>12));
1118+
(*oconv)(0, bin2hex(high>> 8));
1119+
(*oconv)(0, bin2hex(high>> 4));
1120+
(*oconv)(0, bin2hex(high ));
1121+
(*oconv)(0, '\\');
1122+
(*oconv)(0, 'u');
1123+
(*oconv)(0, bin2hex(low>>12));
1124+
(*oconv)(0, bin2hex(low>> 8));
1125+
(*oconv)(0, bin2hex(low>> 4));
1126+
(*oconv)(0, bin2hex(low ));
11191127
}else{
11201128
(*oconv)(0, 'u');
1129+
(*oconv)(0, bin2hex(c>>12));
1130+
(*oconv)(0, bin2hex(c>> 8));
1131+
(*oconv)(0, bin2hex(c>> 4));
1132+
(*oconv)(0, bin2hex(c ));
11211133
}
1122-
(*oconv)(0, bin2hex(c>>12));
1123-
(*oconv)(0, bin2hex(c>> 8));
1124-
(*oconv)(0, bin2hex(c>> 4));
1125-
(*oconv)(0, bin2hex(c ));
11261134
return;
11271135
}
11281136

@@ -1947,12 +1955,17 @@ unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_c
19471955
ret = unicode_to_jis_common2(c1, c0, ppp[c2 - 0xE0], sizeof_utf8_to_euc_C2, p2, p1);
19481956
}else return -1;
19491957
#ifdef SHIFTJIS_CP932
1950-
if (!ret && !cp932inv_f && is_eucg3(*p2)) {
1951-
nkf_char s2, s1;
1952-
if (e2s_conv(*p2, *p1, &s2, &s1) == 0) {
1953-
s2e_conv(s2, s1, p2, p1);
1954-
}else{
1955-
ret = 1;
1958+
if (!ret&& is_eucg3(*p2)) {
1959+
if (cp932inv_f) {
1960+
if (encode_fallback) ret = 1;
1961+
}
1962+
else {
1963+
nkf_char s2, s1;
1964+
if (e2s_conv(*p2, *p1, &s2, &s1) == 0) {
1965+
s2e_conv(s2, s1, p2, p1);
1966+
}else{
1967+
ret = 1;
1968+
}
19561969
}
19571970
}
19581971
#endif

0 commit comments

Comments
 (0)