mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enc/windows_1252.c, test/ruby/enc/test_case_comprehensive.rb:
Implement non-ASCII case conversion for Windows-1252, by Serina Tai. * test/ruby/enc/test_case_comprehensive.rb: Fix order of encodings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6a52a5488a
commit
9f74ae4cf5
3 changed files with 59 additions and 4 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Wed Jul 13 17:21:24 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||||
|
|
||||||
|
* enc/windows_1252.c, test/ruby/enc/test_case_comprehensive.rb:
|
||||||
|
Implement non-ASCII case conversion for Windows-1252, by Serina Tai.
|
||||||
|
|
||||||
|
* test/ruby/enc/test_case_comprehensive.rb: Fix order of encodings.
|
||||||
|
|
||||||
Wed Jul 13 16:19:14 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
Wed Jul 13 16:19:14 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||||
|
|
||||||
* enc/iso_8859_7.c, test/ruby/enc/test_case_comprehensive.rb:
|
* enc/iso_8859_7.c, test/ruby/enc/test_case_comprehensive.rb:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
windows_1252.c - Oniguruma (regular expression library)
|
cp1252.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2006-2007 Byte <byte AT mail DOT kna DOT ru>
|
* Copyright (c) 2006-2007 Byte <byte AT mail DOT kna DOT ru>
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "regenc.h"
|
#include "regenc.h"
|
||||||
|
#include "iso_8859.h"
|
||||||
|
|
||||||
#define ENC_CP1252_TO_LOWER_CASE(c) EncCP1252_ToLowerCaseTable[c]
|
#define ENC_CP1252_TO_LOWER_CASE(c) EncCP1252_ToLowerCaseTable[c]
|
||||||
#define ENC_IS_CP1252_CTYPE(code,ctype) \
|
#define ENC_IS_CP1252_CTYPE(code,ctype) \
|
||||||
|
@ -114,7 +115,6 @@ cp1252_mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED,
|
||||||
(*pp)++;
|
(*pp)++;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cp1252_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc ARG_UNUSED)
|
cp1252_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc ARG_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -180,6 +180,54 @@ cp1252_get_case_fold_codes_by_str(OnigCaseFoldType flag,
|
||||||
sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
|
sizeof(CaseFoldMap)/sizeof(OnigPairCaseFoldCodes), CaseFoldMap, 1,
|
||||||
flag, p, end, items);
|
flag, p, end, items);
|
||||||
}
|
}
|
||||||
|
#ifdef ONIG_CASE_MAPPING
|
||||||
|
static int
|
||||||
|
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
|
||||||
|
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
|
||||||
|
const struct OnigEncodingTypeST* enc)
|
||||||
|
{
|
||||||
|
OnigCodePoint code;
|
||||||
|
OnigUChar *to_start = to;
|
||||||
|
OnigCaseFoldType flags = *flagP;
|
||||||
|
|
||||||
|
while (*pp<end && to<to_end) {
|
||||||
|
code = *(*pp)++;
|
||||||
|
if (code==SHARP_s) {
|
||||||
|
if (flags&ONIGENC_CASE_UPCASE) {
|
||||||
|
flags |= ONIGENC_CASE_MODIFIED;
|
||||||
|
*to++ = 'S';
|
||||||
|
code = (flags&ONIGENC_CASE_TITLECASE) ? 's' : 'S';
|
||||||
|
}
|
||||||
|
else if (flags&ONIGENC_CASE_FOLD) {
|
||||||
|
flags |= ONIGENC_CASE_MODIFIED;
|
||||||
|
*to++ = 's';
|
||||||
|
code = 's';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((EncCP1252_CtypeTable[code] & BIT_CTYPE_UPPER)
|
||||||
|
&& (flags & (ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_FOLD))) {
|
||||||
|
flags |= ONIGENC_CASE_MODIFIED;
|
||||||
|
code = ENC_CP1252_TO_LOWER_CASE(code);
|
||||||
|
}
|
||||||
|
else if (code==0x83 || code==0xAA || code==0xBA || code==0xB5) ;
|
||||||
|
else if ((EncCP1252_CtypeTable[code]&BIT_CTYPE_LOWER)
|
||||||
|
&& (flags&ONIGENC_CASE_UPCASE)) {
|
||||||
|
flags |= ONIGENC_CASE_MODIFIED;
|
||||||
|
if (code==0x9A || code==0x9C || code==0x9E)
|
||||||
|
code -= 0x10;
|
||||||
|
else if (code==0xFF)
|
||||||
|
code -= 0x60;
|
||||||
|
else
|
||||||
|
code -= 0x20;
|
||||||
|
}
|
||||||
|
*to++ = code;
|
||||||
|
if (flags&ONIGENC_CASE_TITLECASE) /* switch from titlecase to lowercase for capitalize */
|
||||||
|
flags ^= (ONIGENC_CASE_UPCASE|ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_TITLECASE);
|
||||||
|
}
|
||||||
|
*flagP = flags;
|
||||||
|
return (int)(to-to_start);
|
||||||
|
}
|
||||||
|
#endif /* ONIG_CASE_MAPPING */
|
||||||
|
|
||||||
OnigEncodingDefine(windows_1252, Windows_1252) = {
|
OnigEncodingDefine(windows_1252, Windows_1252) = {
|
||||||
onigenc_single_byte_mbc_enc_len,
|
onigenc_single_byte_mbc_enc_len,
|
||||||
|
@ -201,7 +249,7 @@ OnigEncodingDefine(windows_1252, Windows_1252) = {
|
||||||
0,
|
0,
|
||||||
ONIGENC_FLAG_NONE,
|
ONIGENC_FLAG_NONE,
|
||||||
#ifdef ONIG_CASE_MAPPING
|
#ifdef ONIG_CASE_MAPPING
|
||||||
onigenc_single_byte_ascii_only_case_map,
|
case_map,
|
||||||
#endif /* ONIG_CASE_MAPPING */
|
#endif /* ONIG_CASE_MAPPING */
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -279,7 +279,7 @@ class TestComprehensiveCaseFold
|
||||||
generate_ascii_only_case_mapping_tests 'Windows-31J'
|
generate_ascii_only_case_mapping_tests 'Windows-31J'
|
||||||
generate_ascii_only_case_mapping_tests 'Windows-1250'
|
generate_ascii_only_case_mapping_tests 'Windows-1250'
|
||||||
generate_ascii_only_case_mapping_tests 'Windows-1251'
|
generate_ascii_only_case_mapping_tests 'Windows-1251'
|
||||||
generate_ascii_only_case_mapping_tests 'Windows-1252'
|
generate_case_mapping_tests 'Windows-1252'
|
||||||
generate_ascii_only_case_mapping_tests 'Windows-1253'
|
generate_ascii_only_case_mapping_tests 'Windows-1253'
|
||||||
generate_ascii_only_case_mapping_tests 'Windows-1254'
|
generate_ascii_only_case_mapping_tests 'Windows-1254'
|
||||||
generate_case_mapping_tests 'Windows-1255'
|
generate_case_mapping_tests 'Windows-1255'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue