2004-03-05 18:31:51 +03:00
|
|
|
/**********************************************************************
|
2012-02-17 11:42:23 +04:00
|
|
|
regenc.c - Onigmo (Oniguruma-mod) (regular expression library)
|
2004-03-05 18:31:51 +03:00
|
|
|
**********************************************************************/
|
2004-11-04 17:31:26 +03:00
|
|
|
/*-
|
2007-05-23 05:32:08 +04:00
|
|
|
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
2016-12-10 20:47:04 +03:00
|
|
|
* Copyright (c) 2011-2016 K.Takata <kentkt AT csc DOT jp>
|
2004-11-04 17:31:26 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2005-01-28 18:02:36 +03:00
|
|
|
#include "regint.h"
|
2004-03-05 18:31:51 +03:00
|
|
|
|
|
|
|
OnigEncoding OnigEncDefaultCharEncoding = ONIG_ENCODING_INIT_DEFAULT;
|
|
|
|
|
|
|
|
extern int
|
2007-03-19 06:58:57 +03:00
|
|
|
onigenc_init(void)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern OnigEncoding
|
2007-03-19 06:58:57 +03:00
|
|
|
onigenc_get_default_encoding(void)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
|
|
|
return OnigEncDefaultCharEncoding;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
|
|
|
onigenc_set_default_encoding(OnigEncoding enc)
|
|
|
|
{
|
|
|
|
OnigEncDefaultCharEncoding = enc;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-10-25 09:45:40 +03:00
|
|
|
extern int
|
|
|
|
onigenc_mbclen(const OnigUChar* p,const OnigUChar* e, OnigEncoding enc)
|
|
|
|
{
|
|
|
|
int ret = ONIGENC_PRECISE_MBC_ENC_LEN(enc, p, e);
|
|
|
|
if (ONIGENC_MBCLEN_CHARFOUND_P(ret)) {
|
|
|
|
ret = ONIGENC_MBCLEN_CHARFOUND_LEN(ret);
|
2024-02-07 05:00:47 +03:00
|
|
|
if (p + ret > e) ret = (int)(e - p); // just for case
|
2022-10-25 09:45:40 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
else if (ONIGENC_MBCLEN_NEEDMORE_P(ret)) {
|
|
|
|
return (int)(e - p);
|
|
|
|
}
|
|
|
|
return p < e ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2008-01-27 17:27:07 +03:00
|
|
|
extern int
|
2014-06-02 02:06:11 +04:00
|
|
|
onigenc_mbclen_approximate(const OnigUChar* p,const OnigUChar* e, OnigEncoding enc)
|
2008-01-27 17:27:07 +03:00
|
|
|
{
|
2017-02-11 18:08:33 +03:00
|
|
|
int ret = ONIGENC_PRECISE_MBC_ENC_LEN(enc, p, e);
|
2013-07-09 11:38:15 +04:00
|
|
|
if (ONIGENC_MBCLEN_CHARFOUND_P(ret))
|
2013-07-05 04:54:11 +04:00
|
|
|
return ONIGENC_MBCLEN_CHARFOUND_LEN(ret);
|
2013-07-09 11:38:15 +04:00
|
|
|
else if (ONIGENC_MBCLEN_NEEDMORE_P(ret))
|
2017-02-11 18:08:33 +03:00
|
|
|
return (int )(e - p) + ONIGENC_MBCLEN_NEEDMORE_LEN(ret);
|
2008-01-27 17:27:07 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-03-05 18:31:51 +03:00
|
|
|
extern UChar*
|
2008-09-13 20:40:31 +04:00
|
|
|
onigenc_get_right_adjust_char_head(OnigEncoding enc, const UChar* start, const UChar* s, const UChar* end)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2008-09-13 23:23:52 +04:00
|
|
|
UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s, end);
|
2004-03-05 18:31:51 +03:00
|
|
|
if (p < s) {
|
2012-02-17 11:42:23 +04:00
|
|
|
p += enclen(enc, p, end);
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern UChar*
|
|
|
|
onigenc_get_right_adjust_char_head_with_prev(OnigEncoding enc,
|
2008-09-13 21:05:49 +04:00
|
|
|
const UChar* start, const UChar* s, const UChar* end, const UChar** prev)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2008-09-13 23:23:52 +04:00
|
|
|
UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s, end);
|
2004-03-05 18:31:51 +03:00
|
|
|
|
|
|
|
if (p < s) {
|
2005-02-23 15:41:49 +03:00
|
|
|
if (prev) *prev = (const UChar* )p;
|
2008-09-13 21:05:49 +04:00
|
|
|
p += enclen(enc, p, end);
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
else {
|
2005-02-23 15:41:49 +03:00
|
|
|
if (prev) *prev = (const UChar* )NULL; /* Sorry */
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern UChar*
|
2008-09-13 22:22:04 +04:00
|
|
|
onigenc_get_prev_char_head(OnigEncoding enc, const UChar* start, const UChar* s, const UChar* end)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
|
|
|
if (s <= start)
|
|
|
|
return (UChar* )NULL;
|
|
|
|
|
2008-09-13 23:23:52 +04:00
|
|
|
return ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s - 1, end);
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern UChar*
|
2008-09-13 22:44:53 +04:00
|
|
|
onigenc_step_back(OnigEncoding enc, const UChar* start, const UChar* s, const UChar* end, int n)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
|
|
|
while (ONIG_IS_NOT_NULL(s) && n-- > 0) {
|
|
|
|
if (s <= start)
|
|
|
|
return (UChar* )NULL;
|
|
|
|
|
2008-09-13 23:23:52 +04:00
|
|
|
s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s - 1, end);
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
2005-02-23 15:41:49 +03:00
|
|
|
return (UChar* )s;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
2004-11-04 17:31:26 +03:00
|
|
|
extern UChar*
|
2005-02-23 15:41:49 +03:00
|
|
|
onigenc_step(OnigEncoding enc, const UChar* p, const UChar* end, int n)
|
2004-11-04 17:31:26 +03:00
|
|
|
{
|
2005-02-23 15:41:49 +03:00
|
|
|
UChar* q = (UChar* )p;
|
2004-11-04 17:31:26 +03:00
|
|
|
while (n-- > 0) {
|
2007-09-06 16:33:45 +04:00
|
|
|
q += ONIGENC_MBC_ENC_LEN(enc, q, end);
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
2005-02-23 15:41:49 +03:00
|
|
|
return (q <= end ? q : NULL);
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2005-02-23 15:41:49 +03:00
|
|
|
onigenc_strlen(OnigEncoding enc, const UChar* p, const UChar* end)
|
2004-11-04 17:31:26 +03:00
|
|
|
{
|
|
|
|
int n = 0;
|
2005-02-23 15:41:49 +03:00
|
|
|
UChar* q = (UChar* )p;
|
2009-02-22 17:23:33 +03:00
|
|
|
|
2005-02-23 15:41:49 +03:00
|
|
|
while (q < end) {
|
2007-09-06 16:33:45 +04:00
|
|
|
q += ONIGENC_MBC_ENC_LEN(enc, q, end);
|
2004-11-04 17:31:26 +03:00
|
|
|
n++;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2005-02-23 15:41:49 +03:00
|
|
|
onigenc_strlen_null(OnigEncoding enc, const UChar* s)
|
2004-11-04 17:31:26 +03:00
|
|
|
{
|
|
|
|
int n = 0;
|
2005-02-23 15:41:49 +03:00
|
|
|
UChar* p = (UChar* )s;
|
2009-08-13 10:37:39 +04:00
|
|
|
UChar* e;
|
2009-02-22 17:23:33 +03:00
|
|
|
|
2004-11-04 17:31:26 +03:00
|
|
|
while (1) {
|
|
|
|
if (*p == '\0') {
|
|
|
|
UChar* q;
|
|
|
|
int len = ONIGENC_MBC_MINLEN(enc);
|
|
|
|
|
|
|
|
if (len == 1) return n;
|
|
|
|
q = p + 1;
|
|
|
|
while (len > 1) {
|
|
|
|
if (*q != '\0') break;
|
|
|
|
q++;
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
if (len == 1) return n;
|
|
|
|
}
|
2009-08-13 10:37:39 +04:00
|
|
|
e = p + ONIGENC_MBC_MAXLEN(enc);
|
2007-09-06 16:33:45 +04:00
|
|
|
p += ONIGENC_MBC_ENC_LEN(enc, p, e);
|
2004-11-04 17:31:26 +03:00
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2005-02-23 15:41:49 +03:00
|
|
|
onigenc_str_bytelen_null(OnigEncoding enc, const UChar* s)
|
2004-11-04 17:31:26 +03:00
|
|
|
{
|
2005-02-23 15:41:49 +03:00
|
|
|
UChar* start = (UChar* )s;
|
|
|
|
UChar* p = (UChar* )s;
|
2009-08-13 10:37:39 +04:00
|
|
|
UChar* e;
|
2004-11-04 17:31:26 +03:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
if (*p == '\0') {
|
|
|
|
UChar* q;
|
|
|
|
int len = ONIGENC_MBC_MINLEN(enc);
|
|
|
|
|
|
|
|
if (len == 1) return (int )(p - start);
|
|
|
|
q = p + 1;
|
|
|
|
while (len > 1) {
|
|
|
|
if (*q != '\0') break;
|
|
|
|
q++;
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
if (len == 1) return (int )(p - start);
|
|
|
|
}
|
2009-08-13 10:37:39 +04:00
|
|
|
e = p + ONIGENC_MBC_MAXLEN(enc);
|
2007-09-06 16:33:45 +04:00
|
|
|
p += ONIGENC_MBC_ENC_LEN(enc, p, e);
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
|
|
|
}
|
2004-03-05 18:31:51 +03:00
|
|
|
|
2007-07-23 13:39:30 +04:00
|
|
|
const UChar OnigEncAsciiToLowerCaseTable[] = {
|
2004-03-05 18:31:51 +03:00
|
|
|
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
|
|
|
|
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
|
|
|
|
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
|
|
|
|
'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
|
|
|
|
'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
|
|
|
|
'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
|
|
|
|
'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
|
|
|
|
'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
|
|
|
|
'\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
|
|
|
|
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
|
|
|
|
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
|
|
|
|
'\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
|
|
|
|
'\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
|
|
|
|
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
|
|
|
|
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
|
|
|
|
'\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
|
|
|
|
'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
|
|
|
|
'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
|
|
|
|
'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
|
|
|
|
'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
|
|
|
|
'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
|
|
|
|
'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
|
|
|
|
'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
|
|
|
|
'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
|
|
|
|
'\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
|
|
|
|
'\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
|
|
|
|
'\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
|
|
|
|
'\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
|
|
|
|
'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
|
|
|
|
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
|
|
|
|
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
|
|
|
|
'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
|
|
|
|
};
|
|
|
|
|
2004-11-04 17:31:26 +03:00
|
|
|
#ifdef USE_UPPER_CASE_TABLE
|
2006-02-04 15:31:19 +03:00
|
|
|
const UChar OnigEncAsciiToUpperCaseTable[256] = {
|
2004-11-04 17:31:26 +03:00
|
|
|
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
|
|
|
|
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
|
|
|
|
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
|
|
|
|
'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
|
|
|
|
'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
|
|
|
|
'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
|
|
|
|
'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
|
|
|
|
'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
|
|
|
|
'\100', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
|
|
|
|
'\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
|
|
|
|
'\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
|
|
|
|
'\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137',
|
|
|
|
'\140', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
|
|
|
|
'\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
|
|
|
|
'\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
|
|
|
|
'\130', '\131', '\132', '\173', '\174', '\175', '\176', '\177',
|
|
|
|
'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
|
|
|
|
'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
|
|
|
|
'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
|
|
|
|
'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
|
|
|
|
'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
|
|
|
|
'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
|
|
|
|
'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
|
|
|
|
'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
|
|
|
|
'\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
|
|
|
|
'\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
|
|
|
|
'\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
|
|
|
|
'\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
|
|
|
|
'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
|
|
|
|
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
|
|
|
|
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
|
|
|
|
'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2006-02-04 15:31:19 +03:00
|
|
|
const unsigned short OnigEncAsciiCtypeTable[256] = {
|
2007-05-23 05:32:08 +04:00
|
|
|
0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
|
|
|
|
0x4008, 0x420c, 0x4209, 0x4208, 0x4208, 0x4208, 0x4008, 0x4008,
|
|
|
|
0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
|
|
|
|
0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008, 0x4008,
|
|
|
|
0x4284, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
|
|
|
|
0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
|
|
|
|
0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0, 0x78b0,
|
|
|
|
0x78b0, 0x78b0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x41a0,
|
|
|
|
0x41a0, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x7ca2, 0x74a2,
|
|
|
|
0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
|
|
|
|
0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2, 0x74a2,
|
|
|
|
0x74a2, 0x74a2, 0x74a2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x51a0,
|
|
|
|
0x41a0, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x78e2, 0x70e2,
|
|
|
|
0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
|
|
|
|
0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2, 0x70e2,
|
|
|
|
0x70e2, 0x70e2, 0x70e2, 0x41a0, 0x41a0, 0x41a0, 0x41a0, 0x4008,
|
2004-03-05 18:31:51 +03:00
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
|
|
|
|
};
|
|
|
|
|
2006-02-04 15:31:19 +03:00
|
|
|
const UChar OnigEncISO_8859_1_ToLowerCaseTable[256] = {
|
2004-11-04 17:31:26 +03:00
|
|
|
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
|
|
|
|
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
|
|
|
|
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
|
|
|
|
'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
|
|
|
|
'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
|
|
|
|
'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
|
|
|
|
'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
|
|
|
|
'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
|
|
|
|
'\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
|
|
|
|
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
|
|
|
|
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
|
|
|
|
'\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
|
|
|
|
'\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
|
|
|
|
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
|
|
|
|
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
|
|
|
|
'\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
|
|
|
|
'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
|
|
|
|
'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
|
|
|
|
'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
|
|
|
|
'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
|
|
|
|
'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
|
|
|
|
'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
|
|
|
|
'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
|
|
|
|
'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
|
|
|
|
'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
|
|
|
|
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
|
|
|
|
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
|
|
|
|
'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
|
|
|
|
'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
|
|
|
|
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
|
|
|
|
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
|
|
|
|
'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef USE_UPPER_CASE_TABLE
|
2006-02-04 15:31:19 +03:00
|
|
|
const UChar OnigEncISO_8859_1_ToUpperCaseTable[256] = {
|
2004-11-04 17:31:26 +03:00
|
|
|
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
|
|
|
|
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
|
|
|
|
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
|
|
|
|
'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
|
|
|
|
'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
|
|
|
|
'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
|
|
|
|
'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
|
|
|
|
'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
|
|
|
|
'\100', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
|
|
|
|
'\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
|
|
|
|
'\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
|
|
|
|
'\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137',
|
|
|
|
'\140', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
|
|
|
|
'\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
|
|
|
|
'\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
|
|
|
|
'\130', '\131', '\132', '\173', '\174', '\175', '\176', '\177',
|
|
|
|
'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
|
|
|
|
'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
|
|
|
|
'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
|
|
|
|
'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
|
|
|
|
'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
|
|
|
|
'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
|
|
|
|
'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
|
|
|
|
'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
|
|
|
|
'\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
|
|
|
|
'\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
|
|
|
|
'\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
|
|
|
|
'\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
|
|
|
|
'\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
|
|
|
|
'\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
|
|
|
|
'\320', '\321', '\322', '\323', '\324', '\325', '\326', '\367',
|
|
|
|
'\330', '\331', '\332', '\333', '\334', '\335', '\336', '\377',
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2016-12-10 20:47:04 +03:00
|
|
|
#if 0
|
2004-03-05 18:31:51 +03:00
|
|
|
extern void
|
2008-01-03 18:55:04 +03:00
|
|
|
onigenc_set_default_caseconv_table(const UChar* table ARG_UNUSED)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2007-07-23 13:39:30 +04:00
|
|
|
/* nothing */
|
|
|
|
/* obsoleted. */
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
2016-12-10 20:47:04 +03:00
|
|
|
#endif
|
2004-03-05 18:31:51 +03:00
|
|
|
|
|
|
|
extern UChar*
|
2008-09-13 23:23:52 +04:00
|
|
|
onigenc_get_left_adjust_char_head(OnigEncoding enc, const UChar* start, const UChar* s, const UChar* end)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2008-09-13 23:23:52 +04:00
|
|
|
return ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s, end);
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
const OnigPairCaseFoldCodes OnigAsciiLowerMap[] = {
|
2004-11-04 17:31:26 +03:00
|
|
|
{ 0x41, 0x61 },
|
|
|
|
{ 0x42, 0x62 },
|
|
|
|
{ 0x43, 0x63 },
|
|
|
|
{ 0x44, 0x64 },
|
|
|
|
{ 0x45, 0x65 },
|
|
|
|
{ 0x46, 0x66 },
|
|
|
|
{ 0x47, 0x67 },
|
|
|
|
{ 0x48, 0x68 },
|
|
|
|
{ 0x49, 0x69 },
|
|
|
|
{ 0x4a, 0x6a },
|
|
|
|
{ 0x4b, 0x6b },
|
|
|
|
{ 0x4c, 0x6c },
|
|
|
|
{ 0x4d, 0x6d },
|
|
|
|
{ 0x4e, 0x6e },
|
|
|
|
{ 0x4f, 0x6f },
|
|
|
|
{ 0x50, 0x70 },
|
|
|
|
{ 0x51, 0x71 },
|
|
|
|
{ 0x52, 0x72 },
|
|
|
|
{ 0x53, 0x73 },
|
|
|
|
{ 0x54, 0x74 },
|
|
|
|
{ 0x55, 0x75 },
|
|
|
|
{ 0x56, 0x76 },
|
|
|
|
{ 0x57, 0x77 },
|
|
|
|
{ 0x58, 0x78 },
|
|
|
|
{ 0x59, 0x79 },
|
2007-05-23 05:32:08 +04:00
|
|
|
{ 0x5a, 0x7a }
|
2004-11-04 17:31:26 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
extern int
|
2008-01-03 18:55:04 +03:00
|
|
|
onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,
|
2007-10-10 19:05:32 +04:00
|
|
|
OnigApplyAllCaseFoldFunc f, void* arg,
|
2008-01-19 18:37:06 +03:00
|
|
|
OnigEncoding enc ARG_UNUSED)
|
2004-11-04 17:31:26 +03:00
|
|
|
{
|
2007-05-23 05:32:08 +04:00
|
|
|
OnigCodePoint code;
|
|
|
|
int i, r;
|
|
|
|
|
2014-09-15 20:18:41 +04:00
|
|
|
for (i = 0; i < numberof(OnigAsciiLowerMap); i++) {
|
2007-05-23 05:32:08 +04:00
|
|
|
code = OnigAsciiLowerMap[i].to;
|
|
|
|
r = (*f)(OnigAsciiLowerMap[i].from, &code, 1, arg);
|
|
|
|
if (r != 0) return r;
|
|
|
|
|
|
|
|
code = OnigAsciiLowerMap[i].from;
|
|
|
|
r = (*f)(OnigAsciiLowerMap[i].to, &code, 1, arg);
|
|
|
|
if (r != 0) return r;
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
2007-05-23 05:32:08 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2008-01-19 18:37:06 +03:00
|
|
|
onigenc_ascii_get_case_fold_codes_by_str(OnigCaseFoldType flag ARG_UNUSED,
|
2014-09-15 20:18:41 +04:00
|
|
|
const OnigUChar* p, const OnigUChar* end ARG_UNUSED,
|
|
|
|
OnigCaseFoldCodeItem items[], OnigEncoding enc ARG_UNUSED)
|
2007-05-23 05:32:08 +04:00
|
|
|
{
|
|
|
|
if (0x41 <= *p && *p <= 0x5a) {
|
|
|
|
items[0].byte_len = 1;
|
|
|
|
items[0].code_len = 1;
|
|
|
|
items[0].code[0] = (OnigCodePoint )(*p + 0x20);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (0x61 <= *p && *p <= 0x7a) {
|
|
|
|
items[0].byte_len = 1;
|
|
|
|
items[0].code_len = 1;
|
|
|
|
items[0].code[0] = (OnigCodePoint )(*p - 0x20);
|
|
|
|
return 1;
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
2007-05-23 05:32:08 +04:00
|
|
|
else
|
|
|
|
return 0;
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
|
|
|
|
2008-01-03 18:55:04 +03:00
|
|
|
static int
|
|
|
|
ss_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,
|
2007-05-23 05:32:08 +04:00
|
|
|
OnigApplyAllCaseFoldFunc f, void* arg)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2008-07-01 12:21:44 +04:00
|
|
|
OnigCodePoint ss[] = { 0x73, 0x73 };
|
2007-05-23 05:32:08 +04:00
|
|
|
|
|
|
|
return (*f)((OnigCodePoint )0xdf, ss, 2, arg);
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2007-05-23 05:32:08 +04:00
|
|
|
onigenc_apply_all_case_fold_with_map(int map_size,
|
|
|
|
const OnigPairCaseFoldCodes map[],
|
|
|
|
int ess_tsett_flag, OnigCaseFoldType flag,
|
|
|
|
OnigApplyAllCaseFoldFunc f, void* arg)
|
2004-11-04 17:31:26 +03:00
|
|
|
{
|
2007-05-23 05:32:08 +04:00
|
|
|
OnigCodePoint code;
|
|
|
|
int i, r;
|
2004-11-04 17:31:26 +03:00
|
|
|
|
2007-10-10 19:05:32 +04:00
|
|
|
r = onigenc_ascii_apply_all_case_fold(flag, f, arg, 0);
|
2007-05-23 05:32:08 +04:00
|
|
|
if (r != 0) return r;
|
|
|
|
|
|
|
|
for (i = 0; i < map_size; i++) {
|
|
|
|
code = map[i].to;
|
|
|
|
r = (*f)(map[i].from, &code, 1, arg);
|
|
|
|
if (r != 0) return r;
|
|
|
|
|
|
|
|
code = map[i].from;
|
|
|
|
r = (*f)(map[i].to, &code, 1, arg);
|
|
|
|
if (r != 0) return r;
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
2007-05-23 05:32:08 +04:00
|
|
|
|
|
|
|
if (ess_tsett_flag != 0)
|
|
|
|
return ss_apply_all_case_fold(flag, f, arg);
|
|
|
|
|
|
|
|
return 0;
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2007-05-23 05:32:08 +04:00
|
|
|
onigenc_get_case_fold_codes_by_str_with_map(int map_size,
|
|
|
|
const OnigPairCaseFoldCodes map[],
|
2008-01-03 18:55:04 +03:00
|
|
|
int ess_tsett_flag, OnigCaseFoldType flag ARG_UNUSED,
|
2007-05-23 05:32:08 +04:00
|
|
|
const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2007-05-23 05:32:08 +04:00
|
|
|
if (0x41 <= *p && *p <= 0x5a) {
|
|
|
|
items[0].byte_len = 1;
|
|
|
|
items[0].code_len = 1;
|
|
|
|
items[0].code[0] = (OnigCodePoint )(*p + 0x20);
|
|
|
|
if (*p == 0x53 && ess_tsett_flag != 0 && end > p + 1
|
|
|
|
&& (*(p+1) == 0x53 || *(p+1) == 0x73)) {
|
|
|
|
/* SS */
|
|
|
|
items[1].byte_len = 2;
|
|
|
|
items[1].code_len = 1;
|
|
|
|
items[1].code[0] = (OnigCodePoint )0xdf;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (0x61 <= *p && *p <= 0x7a) {
|
|
|
|
items[0].byte_len = 1;
|
|
|
|
items[0].code_len = 1;
|
|
|
|
items[0].code[0] = (OnigCodePoint )(*p - 0x20);
|
|
|
|
if (*p == 0x73 && ess_tsett_flag != 0 && end > p + 1
|
|
|
|
&& (*(p+1) == 0x73 || *(p+1) == 0x53)) {
|
|
|
|
/* ss */
|
|
|
|
items[1].byte_len = 2;
|
|
|
|
items[1].code_len = 1;
|
|
|
|
items[1].code[0] = (OnigCodePoint )0xdf;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (*p == 0xdf && ess_tsett_flag != 0) {
|
|
|
|
items[0].byte_len = 1;
|
|
|
|
items[0].code_len = 2;
|
|
|
|
items[0].code[0] = (OnigCodePoint )'s';
|
|
|
|
items[0].code[1] = (OnigCodePoint )'s';
|
|
|
|
|
|
|
|
items[1].byte_len = 1;
|
|
|
|
items[1].code_len = 2;
|
|
|
|
items[1].code[0] = (OnigCodePoint )'S';
|
|
|
|
items[1].code[1] = (OnigCodePoint )'S';
|
|
|
|
|
|
|
|
items[2].byte_len = 1;
|
|
|
|
items[2].code_len = 2;
|
|
|
|
items[2].code[0] = (OnigCodePoint )'s';
|
|
|
|
items[2].code[1] = (OnigCodePoint )'S';
|
2004-11-04 17:31:26 +03:00
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
items[3].byte_len = 1;
|
|
|
|
items[3].code_len = 2;
|
|
|
|
items[3].code[0] = (OnigCodePoint )'S';
|
|
|
|
items[3].code[1] = (OnigCodePoint )'s';
|
|
|
|
|
|
|
|
return 4;
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
2007-05-23 05:32:08 +04:00
|
|
|
else {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < map_size; i++) {
|
|
|
|
if (*p == map[i].from) {
|
|
|
|
items[0].byte_len = 1;
|
|
|
|
items[0].code_len = 1;
|
|
|
|
items[0].code[0] = map[i].to;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (*p == map[i].to) {
|
|
|
|
items[0].byte_len = 1;
|
|
|
|
items[0].code_len = 1;
|
|
|
|
items[0].code[0] = map[i].from;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
|
2004-03-05 18:31:51 +03:00
|
|
|
extern int
|
2014-09-15 20:18:41 +04:00
|
|
|
onigenc_not_support_get_ctype_code_range(OnigCtype ctype ARG_UNUSED,
|
|
|
|
OnigCodePoint* sb_out ARG_UNUSED,
|
|
|
|
const OnigCodePoint* ranges[] ARG_UNUSED,
|
|
|
|
OnigEncoding enc)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2004-11-04 17:31:26 +03:00
|
|
|
return ONIG_NO_SUPPORT_CONFIG;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2008-01-19 18:37:06 +03:00
|
|
|
onigenc_is_mbc_newline_0x0a(const UChar* p, const UChar* end, OnigEncoding enc ARG_UNUSED)
|
2004-11-04 17:31:26 +03:00
|
|
|
{
|
|
|
|
if (p < end) {
|
|
|
|
if (*p == 0x0a) return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* for single byte encodings */
|
|
|
|
extern int
|
2008-01-19 18:37:06 +03:00
|
|
|
onigenc_ascii_mbc_case_fold(OnigCaseFoldType flag ARG_UNUSED, const UChar** p,
|
2014-09-15 20:18:41 +04:00
|
|
|
const UChar* end, UChar* lower, OnigEncoding enc ARG_UNUSED)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2007-05-23 05:32:08 +04:00
|
|
|
*lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(**p);
|
2004-11-04 17:31:26 +03:00
|
|
|
|
|
|
|
(*p)++;
|
2004-03-05 18:31:51 +03:00
|
|
|
return 1; /* return byte length of converted char to lower */
|
|
|
|
}
|
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
#if 0
|
2004-03-05 18:31:51 +03:00
|
|
|
extern int
|
2008-01-19 18:37:06 +03:00
|
|
|
onigenc_ascii_is_mbc_ambiguous(OnigCaseFoldType flag ARG_UNUSED,
|
|
|
|
const UChar** pp, const UChar* end ARG_UNUSED)
|
2004-11-04 17:31:26 +03:00
|
|
|
{
|
2005-02-23 15:41:49 +03:00
|
|
|
const UChar* p = *pp;
|
2004-11-04 17:31:26 +03:00
|
|
|
|
|
|
|
(*pp)++;
|
2007-05-23 05:32:08 +04:00
|
|
|
return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
2007-05-23 05:32:08 +04:00
|
|
|
#endif
|
2004-11-04 17:31:26 +03:00
|
|
|
|
|
|
|
extern int
|
2008-01-19 18:37:06 +03:00
|
|
|
onigenc_single_byte_mbc_enc_len(const UChar* p ARG_UNUSED, const UChar* e ARG_UNUSED,
|
|
|
|
OnigEncoding enc ARG_UNUSED)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2004-11-04 17:31:26 +03:00
|
|
|
return 1;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern OnigCodePoint
|
2008-01-19 18:37:06 +03:00
|
|
|
onigenc_single_byte_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED,
|
|
|
|
OnigEncoding enc ARG_UNUSED)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
|
|
|
return (OnigCodePoint )(*p);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2008-01-19 18:37:06 +03:00
|
|
|
onigenc_single_byte_code_to_mbclen(OnigCodePoint code ARG_UNUSED, OnigEncoding enc ARG_UNUSED)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2008-01-19 18:37:06 +03:00
|
|
|
onigenc_single_byte_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc ARG_UNUSED)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2016-12-10 20:47:04 +03:00
|
|
|
#ifdef RUBY
|
2008-08-07 00:17:55 +04:00
|
|
|
if (code > 0xff)
|
2014-09-15 20:18:41 +04:00
|
|
|
rb_raise(rb_eRangeError, "%u out of char range", code);
|
2016-12-10 20:47:04 +03:00
|
|
|
#endif
|
2004-03-05 18:31:51 +03:00
|
|
|
*buf = (UChar )(code & 0xff);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern UChar*
|
2014-09-15 20:18:41 +04:00
|
|
|
onigenc_single_byte_left_adjust_char_head(const UChar* start ARG_UNUSED,
|
|
|
|
const UChar* s,
|
|
|
|
const UChar* end ARG_UNUSED,
|
2008-01-19 18:37:06 +03:00
|
|
|
OnigEncoding enc ARG_UNUSED)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2005-02-23 15:41:49 +03:00
|
|
|
return (UChar* )s;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2014-09-15 20:18:41 +04:00
|
|
|
onigenc_always_true_is_allowed_reverse_match(const UChar* s ARG_UNUSED,
|
|
|
|
const UChar* end ARG_UNUSED,
|
2008-01-19 18:37:06 +03:00
|
|
|
OnigEncoding enc ARG_UNUSED)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-11-04 17:31:26 +03:00
|
|
|
extern int
|
2014-09-15 20:18:41 +04:00
|
|
|
onigenc_always_false_is_allowed_reverse_match(const UChar* s ARG_UNUSED,
|
|
|
|
const UChar* end ARG_UNUSED,
|
2008-01-19 18:37:06 +03:00
|
|
|
OnigEncoding enc ARG_UNUSED)
|
2004-11-04 17:31:26 +03:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-12-22 08:38:33 +03:00
|
|
|
extern int
|
|
|
|
onigenc_ascii_is_code_ctype(OnigCodePoint code, unsigned int ctype,
|
2008-01-19 18:37:06 +03:00
|
|
|
OnigEncoding enc ARG_UNUSED)
|
2007-12-22 08:38:33 +03:00
|
|
|
{
|
|
|
|
if (code < 128)
|
|
|
|
return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-05 18:31:51 +03:00
|
|
|
extern OnigCodePoint
|
2008-09-18 16:53:25 +04:00
|
|
|
onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2008-09-18 16:53:25 +04:00
|
|
|
int c, i, len;
|
2004-03-05 18:31:51 +03:00
|
|
|
OnigCodePoint n;
|
|
|
|
|
2008-09-18 16:53:25 +04:00
|
|
|
len = enclen(enc, p, end);
|
2004-11-04 17:31:26 +03:00
|
|
|
n = (OnigCodePoint )(*p++);
|
2004-03-05 18:31:51 +03:00
|
|
|
if (len == 1) return n;
|
|
|
|
|
|
|
|
for (i = 1; i < len; i++) {
|
|
|
|
if (p >= end) break;
|
|
|
|
c = *p++;
|
|
|
|
n <<= 8; n += c;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2008-01-03 18:55:04 +03:00
|
|
|
onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag ARG_UNUSED,
|
|
|
|
const UChar** pp, const UChar* end ARG_UNUSED,
|
|
|
|
UChar* lower)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
|
|
|
int len;
|
2005-02-23 15:41:49 +03:00
|
|
|
const UChar *p = *pp;
|
2004-03-05 18:31:51 +03:00
|
|
|
|
|
|
|
if (ONIGENC_IS_MBC_ASCII(p)) {
|
2007-05-23 05:32:08 +04:00
|
|
|
*lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
|
2004-11-04 17:31:26 +03:00
|
|
|
(*pp)++;
|
2004-03-05 18:31:51 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
2007-05-23 05:32:08 +04:00
|
|
|
int i;
|
|
|
|
|
2008-01-03 18:55:04 +03:00
|
|
|
len = enclen(enc, p, end);
|
2007-05-23 05:32:08 +04:00
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
*lower++ = *p++;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
2004-11-04 17:31:26 +03:00
|
|
|
(*pp) += len;
|
2004-03-05 18:31:51 +03:00
|
|
|
return len; /* return byte length of converted to lower char */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
#if 0
|
2004-03-05 18:31:51 +03:00
|
|
|
extern int
|
2007-05-23 05:32:08 +04:00
|
|
|
onigenc_mbn_is_mbc_ambiguous(OnigEncoding enc, OnigCaseFoldType flag,
|
2014-09-15 20:18:41 +04:00
|
|
|
const UChar** pp, const UChar* end ARG_UNUSED)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2005-02-23 15:41:49 +03:00
|
|
|
const UChar* p = *pp;
|
2004-03-05 18:31:51 +03:00
|
|
|
|
2004-11-04 17:31:26 +03:00
|
|
|
if (ONIGENC_IS_MBC_ASCII(p)) {
|
|
|
|
(*pp)++;
|
2007-05-23 05:32:08 +04:00
|
|
|
return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
|
|
|
|
2008-01-03 18:55:04 +03:00
|
|
|
(*pp) += enclen(enc, p);
|
2004-03-05 18:31:51 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
2007-05-23 05:32:08 +04:00
|
|
|
#endif
|
2004-03-05 18:31:51 +03:00
|
|
|
|
|
|
|
extern int
|
2008-01-19 18:37:06 +03:00
|
|
|
onigenc_mb2_code_to_mbclen(OnigCodePoint code, OnigEncoding enc ARG_UNUSED)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2012-01-09 00:42:45 +04:00
|
|
|
if (code <= 0xff) return 1;
|
|
|
|
if (code <= 0xffff) return 2;
|
|
|
|
return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2008-01-19 18:37:06 +03:00
|
|
|
onigenc_mb4_code_to_mbclen(OnigCodePoint code, OnigEncoding enc ARG_UNUSED)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
|
|
|
if ((code & 0xff000000) != 0) return 4;
|
|
|
|
else if ((code & 0xff0000) != 0) return 3;
|
|
|
|
else if ((code & 0xff00) != 0) return 2;
|
|
|
|
else return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
|
|
|
onigenc_mb2_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
|
|
|
|
{
|
|
|
|
UChar *p = buf;
|
|
|
|
|
|
|
|
if ((code & 0xff00) != 0) {
|
|
|
|
*p++ = (UChar )((code >> 8) & 0xff);
|
|
|
|
}
|
|
|
|
*p++ = (UChar )(code & 0xff);
|
|
|
|
|
|
|
|
#if 1
|
2008-01-03 18:55:04 +03:00
|
|
|
if (enclen(enc, buf, p) != (p - buf))
|
|
|
|
return ONIGERR_INVALID_CODE_POINT_VALUE;
|
2004-03-05 18:31:51 +03:00
|
|
|
#endif
|
2012-02-17 11:42:23 +04:00
|
|
|
return (int )(p - buf);
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
|
|
|
onigenc_mb4_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
|
|
|
|
{
|
|
|
|
UChar *p = buf;
|
|
|
|
|
|
|
|
if ((code & 0xff000000) != 0) {
|
|
|
|
*p++ = (UChar )((code >> 24) & 0xff);
|
|
|
|
}
|
2006-02-04 15:31:19 +03:00
|
|
|
if ((code & 0xff0000) != 0 || p != buf) {
|
2004-03-05 18:31:51 +03:00
|
|
|
*p++ = (UChar )((code >> 16) & 0xff);
|
|
|
|
}
|
2006-02-04 15:31:19 +03:00
|
|
|
if ((code & 0xff00) != 0 || p != buf) {
|
2004-03-05 18:31:51 +03:00
|
|
|
*p++ = (UChar )((code >> 8) & 0xff);
|
|
|
|
}
|
|
|
|
*p++ = (UChar )(code & 0xff);
|
|
|
|
|
|
|
|
#if 1
|
2008-01-03 18:55:04 +03:00
|
|
|
if (enclen(enc, buf, p) != (p - buf))
|
|
|
|
return ONIGERR_INVALID_CODE_POINT_VALUE;
|
2004-03-05 18:31:51 +03:00
|
|
|
#endif
|
2012-02-17 11:42:23 +04:00
|
|
|
return (int )(p - buf);
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
extern int
|
2015-08-27 22:49:45 +03:00
|
|
|
onigenc_minimum_property_name_to_ctype(OnigEncoding enc, const UChar* p, const UChar* end)
|
2007-05-23 05:32:08 +04:00
|
|
|
{
|
2008-07-01 12:21:44 +04:00
|
|
|
static const PosixBracketEntryType PBS[] = {
|
2014-09-15 20:18:41 +04:00
|
|
|
POSIX_BRACKET_ENTRY_INIT("Alnum", ONIGENC_CTYPE_ALNUM),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("Alpha", ONIGENC_CTYPE_ALPHA),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("Blank", ONIGENC_CTYPE_BLANK),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("Cntrl", ONIGENC_CTYPE_CNTRL),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("Digit", ONIGENC_CTYPE_DIGIT),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("Graph", ONIGENC_CTYPE_GRAPH),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("Lower", ONIGENC_CTYPE_LOWER),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("Print", ONIGENC_CTYPE_PRINT),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("Punct", ONIGENC_CTYPE_PUNCT),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("Space", ONIGENC_CTYPE_SPACE),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("Upper", ONIGENC_CTYPE_UPPER),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("XDigit", ONIGENC_CTYPE_XDIGIT),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("ASCII", ONIGENC_CTYPE_ASCII),
|
|
|
|
POSIX_BRACKET_ENTRY_INIT("Word", ONIGENC_CTYPE_WORD),
|
2007-05-23 05:32:08 +04:00
|
|
|
};
|
|
|
|
|
2014-09-15 20:18:41 +04:00
|
|
|
const PosixBracketEntryType *pb;
|
2007-05-23 05:32:08 +04:00
|
|
|
int len;
|
|
|
|
|
|
|
|
len = onigenc_strlen(enc, p, end);
|
2014-09-15 20:18:41 +04:00
|
|
|
for (pb = PBS; pb < PBS + numberof(PBS); pb++) {
|
2007-05-23 05:32:08 +04:00
|
|
|
if (len == pb->len &&
|
2012-02-17 11:42:23 +04:00
|
|
|
onigenc_with_ascii_strnicmp(enc, p, end, pb->name, pb->len) == 0)
|
2007-05-23 05:32:08 +04:00
|
|
|
return pb->ctype;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
|
|
|
|
}
|
|
|
|
|
2004-03-05 18:31:51 +03:00
|
|
|
extern int
|
2004-11-04 17:31:26 +03:00
|
|
|
onigenc_mb2_is_code_ctype(OnigEncoding enc, OnigCodePoint code,
|
2004-03-05 18:31:51 +03:00
|
|
|
unsigned int ctype)
|
|
|
|
{
|
2006-02-04 15:31:19 +03:00
|
|
|
if (code < 128)
|
|
|
|
return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
|
|
|
|
else {
|
2007-05-23 05:32:08 +04:00
|
|
|
if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {
|
2004-11-04 17:31:26 +03:00
|
|
|
return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE);
|
2006-02-04 15:31:19 +03:00
|
|
|
}
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
2006-02-04 15:31:19 +03:00
|
|
|
return FALSE;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2004-11-04 17:31:26 +03:00
|
|
|
onigenc_mb4_is_code_ctype(OnigEncoding enc, OnigCodePoint code,
|
2004-03-05 18:31:51 +03:00
|
|
|
unsigned int ctype)
|
|
|
|
{
|
2006-02-04 15:31:19 +03:00
|
|
|
if (code < 128)
|
|
|
|
return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
|
|
|
|
else {
|
2007-05-23 05:32:08 +04:00
|
|
|
if (CTYPE_IS_WORD_GRAPH_PRINT(ctype)) {
|
2004-11-04 17:31:26 +03:00
|
|
|
return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE);
|
2006-02-04 15:31:19 +03:00
|
|
|
}
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
2006-02-04 15:31:19 +03:00
|
|
|
return FALSE;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2005-02-23 15:41:49 +03:00
|
|
|
onigenc_with_ascii_strncmp(OnigEncoding enc, const UChar* p, const UChar* end,
|
|
|
|
const UChar* sascii /* ascii */, int n)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2004-11-04 17:31:26 +03:00
|
|
|
int x, c;
|
2004-03-05 18:31:51 +03:00
|
|
|
|
2004-11-04 17:31:26 +03:00
|
|
|
while (n-- > 0) {
|
|
|
|
if (p >= end) return (int )(*sascii);
|
2004-03-05 18:31:51 +03:00
|
|
|
|
2004-11-04 17:31:26 +03:00
|
|
|
c = (int )ONIGENC_MBC_TO_CODE(enc, p, end);
|
|
|
|
x = *sascii - c;
|
|
|
|
if (x) return x;
|
2004-03-05 18:31:51 +03:00
|
|
|
|
2004-11-04 17:31:26 +03:00
|
|
|
sascii++;
|
2008-01-03 18:55:04 +03:00
|
|
|
p += enclen(enc, p, end);
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
|
|
|
return 0;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
2012-02-17 11:42:23 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-12-10 20:47:04 +03:00
|
|
|
#if 0
|
2007-05-23 05:32:08 +04:00
|
|
|
/* Property management */
|
|
|
|
static int
|
|
|
|
resize_property_list(int new_size, const OnigCodePoint*** plist, int* psize)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2009-06-30 06:08:54 +04:00
|
|
|
size_t size;
|
2007-05-23 05:32:08 +04:00
|
|
|
const OnigCodePoint **list = *plist;
|
|
|
|
|
|
|
|
size = sizeof(OnigCodePoint*) * new_size;
|
|
|
|
if (IS_NULL(list)) {
|
|
|
|
list = (const OnigCodePoint** )xmalloc(size);
|
2015-11-26 11:31:27 +03:00
|
|
|
if (IS_NULL(list)) return ONIGERR_MEMORY;
|
2007-05-23 05:32:08 +04:00
|
|
|
}
|
|
|
|
else {
|
2015-11-26 11:31:27 +03:00
|
|
|
const OnigCodePoint **tmp;
|
|
|
|
tmp = (const OnigCodePoint** )xrealloc((void* )list, size);
|
|
|
|
if (IS_NULL(tmp)) return ONIGERR_MEMORY;
|
|
|
|
list = tmp;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
*plist = list;
|
|
|
|
*psize = new_size;
|
2004-03-05 18:31:51 +03:00
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
return 0;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2007-05-23 05:32:08 +04:00
|
|
|
onigenc_property_list_add_property(UChar* name, const OnigCodePoint* prop,
|
|
|
|
hash_table_type **table, const OnigCodePoint*** plist, int *pnum,
|
|
|
|
int *psize)
|
2004-03-05 18:31:51 +03:00
|
|
|
{
|
2007-05-23 05:32:08 +04:00
|
|
|
#define PROP_INIT_SIZE 16
|
2004-03-05 18:31:51 +03:00
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
int r;
|
2004-03-05 18:31:51 +03:00
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
if (*psize <= *pnum) {
|
|
|
|
int new_size = (*psize == 0 ? PROP_INIT_SIZE : *psize * 2);
|
|
|
|
r = resize_property_list(new_size, plist, psize);
|
|
|
|
if (r != 0) return r;
|
|
|
|
}
|
2004-11-04 17:31:26 +03:00
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
(*plist)[*pnum] = prop;
|
2004-11-04 17:31:26 +03:00
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
if (ONIG_IS_NULL(*table)) {
|
|
|
|
*table = onig_st_init_strend_table_with_size(PROP_INIT_SIZE);
|
|
|
|
if (ONIG_IS_NULL(*table)) return ONIGERR_MEMORY;
|
2004-11-04 17:31:26 +03:00
|
|
|
}
|
2004-03-05 18:31:51 +03:00
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
*pnum = *pnum + 1;
|
|
|
|
onig_st_insert_strend(*table, name, name + strlen((char* )name),
|
|
|
|
(hash_data_type )(*pnum + ONIGENC_MAX_STD_CTYPE));
|
|
|
|
return 0;
|
2004-03-05 18:31:51 +03:00
|
|
|
}
|
2016-12-10 20:47:04 +03:00
|
|
|
#endif
|
2004-03-05 18:31:51 +03:00
|
|
|
|
2007-05-23 05:32:08 +04:00
|
|
|
extern int
|
2016-12-10 20:47:04 +03:00
|
|
|
onigenc_ascii_only_case_map(OnigCaseFoldType* flagP, const OnigUChar** pp, const OnigUChar* end,
|
|
|
|
OnigUChar* to, OnigUChar* to_end, const struct OnigEncodingTypeST* enc)
|
2016-06-07 06:55:37 +03:00
|
|
|
{
|
|
|
|
OnigCodePoint code;
|
|
|
|
OnigUChar *to_start = to;
|
|
|
|
OnigCaseFoldType flags = *flagP;
|
|
|
|
int codepoint_length;
|
|
|
|
|
2016-12-10 20:47:04 +03:00
|
|
|
while (*pp < end && to < to_end) {
|
2016-06-07 06:55:37 +03:00
|
|
|
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;
|
|
|
|
|
2016-12-10 20:47:04 +03:00
|
|
|
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';
|
|
|
|
}
|
2016-06-07 06:55:37 +03:00
|
|
|
to += ONIGENC_CODE_TO_MBC(enc, code, to);
|
|
|
|
if (flags & ONIGENC_CASE_TITLECASE) /* switch from titlecase to lowercase for capitalize */
|
2016-12-10 20:47:04 +03:00
|
|
|
flags ^= (ONIGENC_CASE_UPCASE | ONIGENC_CASE_DOWNCASE | ONIGENC_CASE_TITLECASE);
|
2016-06-07 06:55:37 +03:00
|
|
|
}
|
|
|
|
*flagP = flags;
|
2016-12-10 20:47:04 +03:00
|
|
|
return (int )(to - to_start);
|
2016-06-07 06:55:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
2016-12-10 20:47:04 +03:00
|
|
|
onigenc_single_byte_ascii_only_case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
|
|
|
|
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
|
|
|
|
const struct OnigEncodingTypeST* enc)
|
2016-06-07 06:55:37 +03:00
|
|
|
{
|
|
|
|
OnigCodePoint code;
|
|
|
|
OnigUChar *to_start = to;
|
|
|
|
OnigCaseFoldType flags = *flagP;
|
|
|
|
|
2016-12-10 20:47:04 +03:00
|
|
|
while (*pp < end && to < to_end) {
|
2016-06-07 06:55:37 +03:00
|
|
|
code = *(*pp)++;
|
|
|
|
|
2016-12-10 20:47:04 +03:00
|
|
|
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';
|
|
|
|
}
|
2016-06-07 06:55:37 +03:00
|
|
|
*to++ = code;
|
|
|
|
if (flags & ONIGENC_CASE_TITLECASE) /* switch from titlecase to lowercase for capitalize */
|
2016-12-10 20:47:04 +03:00
|
|
|
flags ^= (ONIGENC_CASE_UPCASE | ONIGENC_CASE_DOWNCASE | ONIGENC_CASE_TITLECASE);
|
2016-06-07 06:55:37 +03:00
|
|
|
}
|
|
|
|
*flagP = flags;
|
2016-12-10 20:47:04 +03:00
|
|
|
return (int )(to - to_start);
|
2016-06-07 06:55:37 +03:00
|
|
|
}
|