From 2873edeafb6f6df1fc99bb9b1167591b99dd378c Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 10 Dec 2016 17:47:04 +0000 Subject: 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 --- regenc.c | 67 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) (limited to 'regenc.c') 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 - * Copyright (c) 2011 K.Takata + * Copyright (c) 2011-2016 K.Takata * 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='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='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); } -- cgit v1.2.3