aboutsummaryrefslogtreecommitdiffstats
path: root/regenc.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-10 17:47:04 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-10 17:47:04 +0000
commit1b7d03b9d0d60d4dede7d38739503e59a8b25d06 (patch)
treedeb58ca3dc6d6cd71c1740e62aa7e47bea5ed37e /regenc.c
parent5a5ea533fd8c5c95ca0dcd5e4cce2558ebba62c5 (diff)
downloadruby-1b7d03b9d0d60d4dede7d38739503e59a8b25d06.tar.gz
Merge Onigmo 6.0.0
* https://github.com/k-takata/Onigmo/blob/Onigmo-6.0.0/HISTORY * fix for ruby 2.4: https://github.com/k-takata/Onigmo/pull/78 * suppress warning: https://github.com/k-takata/Onigmo/pull/79 * include/ruby/oniguruma.h: include onigmo.h. * template/encdb.h.tmpl: ignore duplicated definition of EUC-CN in enc/euc_kr.c. It is defined in enc/gb2313.c with CRuby macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regenc.c')
-rw-r--r--regenc.c67
1 files changed, 34 insertions, 33 deletions
diff --git a/regenc.c b/regenc.c
index 5cacbdfaa4..ca09a7fcb3 100644
--- a/regenc.c
+++ b/regenc.c
@@ -3,7 +3,7 @@
**********************************************************************/
/*-
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
- * Copyright (c) 2011 K.Takata <kentkt AT csc DOT jp>
+ * Copyright (c) 2011-2016 K.Takata <kentkt AT csc DOT jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -364,12 +364,14 @@ const UChar OnigEncISO_8859_1_ToUpperCaseTable[256] = {
};
#endif
+#if 0
extern void
onigenc_set_default_caseconv_table(const UChar* table ARG_UNUSED)
{
/* nothing */
/* obsoleted. */
}
+#endif
extern UChar*
onigenc_get_left_adjust_char_head(OnigEncoding enc, const UChar* start, const UChar* s, const UChar* end)
@@ -631,8 +633,10 @@ onigenc_single_byte_code_to_mbclen(OnigCodePoint code ARG_UNUSED, OnigEncoding e
extern int
onigenc_single_byte_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc ARG_UNUSED)
{
+#ifdef RUBY
if (code > 0xff)
rb_raise(rb_eRangeError, "%u out of char range", code);
+#endif
*buf = (UChar )(code & 0xff);
return 1;
}
@@ -892,6 +896,7 @@ onigenc_with_ascii_strnicmp(OnigEncoding enc, const UChar* p, const UChar* end,
return 0;
}
+#if 0
/* Property management */
static int
resize_property_list(int new_size, const OnigCodePoint*** plist, int* psize)
@@ -944,68 +949,64 @@ onigenc_property_list_add_property(UChar* name, const OnigCodePoint* prop,
(hash_data_type )(*pnum + ONIGENC_MAX_STD_CTYPE));
return 0;
}
+#endif
extern int
-onigenc_property_list_init(int (*f)(void))
-{
- int r;
-
- THREAD_ATOMIC_START;
-
- r = f();
-
- THREAD_ATOMIC_END;
- return r;
-}
-
-extern int
-onigenc_ascii_only_case_map (OnigCaseFoldType* flagP, const OnigUChar** pp, const OnigUChar* end,
- OnigUChar* to, OnigUChar* to_end, const struct OnigEncodingTypeST* enc)
+onigenc_ascii_only_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;
int codepoint_length;
- while (*pp<end && to<to_end) {
+ while (*pp < end && to < to_end) {
codepoint_length = ONIGENC_PRECISE_MBC_ENC_LEN(enc, *pp, end);
if (codepoint_length < 0)
return codepoint_length; /* encoding invalid */
code = ONIGENC_MBC_TO_CODE(enc, *pp, end);
*pp += codepoint_length;
- if (code>='a' && code<='z' && (flags&ONIGENC_CASE_UPCASE))
- flags |= ONIGENC_CASE_MODIFIED, code += 'A'-'a';
- else if (code>='A' && code<='Z' && (flags&(ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_FOLD)))
- flags |= ONIGENC_CASE_MODIFIED, code += 'a'-'A';
+ if (code >= 'a' && code <= 'z' && (flags & ONIGENC_CASE_UPCASE)) {
+ flags |= ONIGENC_CASE_MODIFIED;
+ code += 'A' - 'a';
+ } else if (code >= 'A' && code <= 'Z' &&
+ (flags & (ONIGENC_CASE_DOWNCASE | ONIGENC_CASE_FOLD))) {
+ flags |= ONIGENC_CASE_MODIFIED;
+ code += 'a' - 'A';
+ }
to += ONIGENC_CODE_TO_MBC(enc, code, to);
if (flags & ONIGENC_CASE_TITLECASE) /* switch from titlecase to lowercase for capitalize */
- flags ^= (ONIGENC_CASE_UPCASE|ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_TITLECASE);
+ flags ^= (ONIGENC_CASE_UPCASE | ONIGENC_CASE_DOWNCASE | ONIGENC_CASE_TITLECASE);
}
*flagP = flags;
- return (int)(to-to_start);
+ return (int )(to - to_start);
}
extern int
-onigenc_single_byte_ascii_only_case_map (OnigCaseFoldType* flagP, const OnigUChar** pp,
- const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
- const struct OnigEncodingTypeST* enc)
+onigenc_single_byte_ascii_only_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) {
+ while (*pp < end && to < to_end) {
code = *(*pp)++;
- if (code>='a' && code<='z' && (flags&ONIGENC_CASE_UPCASE))
- flags |= ONIGENC_CASE_MODIFIED, code += 'A'-'a';
- else if (code>='A' && code<='Z' && (flags&(ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_FOLD)))
- flags |= ONIGENC_CASE_MODIFIED, code += 'a'-'A';
+ if (code >= 'a' && code <= 'z' && (flags & ONIGENC_CASE_UPCASE)) {
+ flags |= ONIGENC_CASE_MODIFIED;
+ code += 'A' - 'a';
+ } else if (code >= 'A' && code <= 'Z' &&
+ (flags & (ONIGENC_CASE_DOWNCASE | ONIGENC_CASE_FOLD))) {
+ flags |= ONIGENC_CASE_MODIFIED;
+ code += 'a' - 'A';
+ }
*to++ = code;
if (flags & ONIGENC_CASE_TITLECASE) /* switch from titlecase to lowercase for capitalize */
- flags ^= (ONIGENC_CASE_UPCASE|ONIGENC_CASE_DOWNCASE|ONIGENC_CASE_TITLECASE);
+ flags ^= (ONIGENC_CASE_UPCASE | ONIGENC_CASE_DOWNCASE | ONIGENC_CASE_TITLECASE);
}
*flagP = flags;
- return (int)(to-to_start);
+ return (int )(to - to_start);
}