From 0424e152c684a85f4b0691f1e84aec203115333d Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 17 Feb 2012 07:42:23 +0000 Subject: * Merge Onigmo-5.13.1. [ruby-dev:45057] [Feature #5820] https://github.com/k-takata/Onigmo cp reg{comp,enc,error,exec,parse,syntax}.c reg{enc,int,parse}.h cp oniguruma.h cp tool/enc-unicode.rb cp -r enc/ git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- regenc.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'regenc.c') diff --git a/regenc.c b/regenc.c index 70b56ef727..288eac433d 100644 --- a/regenc.c +++ b/regenc.c @@ -1,8 +1,9 @@ /********************************************************************** - regenc.c - Oniguruma (regular expression library) + regenc.c - Onigmo (Oniguruma-mod) (regular expression library) **********************************************************************/ /*- * Copyright (c) 2002-2007 K.Kosako + * Copyright (c) 2011 K.Takata * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,7 +67,7 @@ onigenc_get_right_adjust_char_head(OnigEncoding enc, const UChar* start, const U { UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s, end); if (p < s) { - p += enclen(enc, p, end); + p += enclen(enc, p, end); } return p; } @@ -760,7 +761,7 @@ onigenc_mb2_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf) if (enclen(enc, buf, p) != (p - buf)) return ONIGERR_INVALID_CODE_POINT_VALUE; #endif - return (int)(p - buf); + return (int )(p - buf); } extern int @@ -783,7 +784,7 @@ onigenc_mb4_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf) if (enclen(enc, buf, p) != (p - buf)) return ONIGERR_INVALID_CODE_POINT_VALUE; #endif - return (int)(p - buf); + return (int )(p - buf); } extern int @@ -812,7 +813,7 @@ onigenc_minimum_property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end) len = onigenc_strlen(enc, p, end); for (pbe = (pb = PBS) + sizeof(PBS)/sizeof(PBS[0]); pb < pbe; ++pb) { if (len == pb->len && - STRNCASECMP((char *)p, (char *)pb->name, len) == 0) + onigenc_with_ascii_strnicmp(enc, p, end, pb->name, pb->len) == 0) return pb->ctype; } @@ -868,6 +869,27 @@ onigenc_with_ascii_strncmp(OnigEncoding enc, const UChar* p, const UChar* end, return 0; } +extern int +onigenc_with_ascii_strnicmp(OnigEncoding enc, const UChar* p, const UChar* end, + const UChar* sascii /* ascii */, int n) +{ + int x, c; + + while (n-- > 0) { + if (p >= end) return (int )(*sascii); + + c = (int )ONIGENC_MBC_TO_CODE(enc, p, end); + if (ONIGENC_IS_ASCII_CODE(c)) + c = ONIGENC_ASCII_CODE_TO_LOWER_CASE(c); + x = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*sascii) - c; + if (x) return x; + + sascii++; + p += enclen(enc, p, end); + } + return 0; +} + /* Property management */ static int resize_property_list(int new_size, const OnigCodePoint*** plist, int* psize) -- cgit v1.2.3