mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* include/ruby/oniguruma.h: Oniguruma 1.9.1 merged.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1aaf8b1713
commit
52ed8c4edd
23 changed files with 866 additions and 646 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Fri Jan 4 00:54:43 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* include/ruby/oniguruma.h: Oniguruma 1.9.1 merged.
|
||||||
|
|
||||||
Fri Jan 4 00:20:47 2008 Tanaka Akira <akr@fsij.org>
|
Fri Jan 4 00:20:47 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* io.c (io_ungetc): move data in buffer if it is required to store the
|
* io.c (io_ungetc): move data in buffer if it is required to store the
|
||||||
|
|
21
enc/euc_jp.c
21
enc/euc_jp.c
|
@ -137,7 +137,7 @@ eucjp_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
|
||||||
int c, i, len;
|
int c, i, len;
|
||||||
OnigCodePoint n;
|
OnigCodePoint n;
|
||||||
|
|
||||||
len = enc_len(ONIG_ENCODING_EUC_JP, p, end);
|
len = enclen(ONIG_ENCODING_EUC_JP, p, end);
|
||||||
n = (OnigCodePoint )*p++;
|
n = (OnigCodePoint )*p++;
|
||||||
if (len == 1) return n;
|
if (len == 1) return n;
|
||||||
|
|
||||||
|
@ -156,7 +156,8 @@ eucjp_code_to_mbclen(OnigCodePoint code, OnigEncoding enc)
|
||||||
else if (code > 0xffffff) return 0;
|
else if (code > 0xffffff) return 0;
|
||||||
else if ((code & 0xff0000) >= 0x800000) return 3;
|
else if ((code & 0xff0000) >= 0x800000) return 3;
|
||||||
else if ((code & 0xff00) >= 0x8000) return 2;
|
else if ((code & 0xff00) >= 0x8000) return 2;
|
||||||
else return 0;
|
else
|
||||||
|
return ONIGERR_INVALID_CODE_POINT_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -188,8 +189,8 @@ eucjp_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)
|
||||||
*p++ = (UChar )(code & 0xff);
|
*p++ = (UChar )(code & 0xff);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if (enc_len(ONIG_ENCODING_EUC_JP, buf, p) != (p - buf))
|
if (enclen(ONIG_ENCODING_EUC_JP, buf, p) != (p - buf))
|
||||||
return ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE;
|
return ONIGERR_INVALID_CODE_POINT_VALUE;
|
||||||
#endif
|
#endif
|
||||||
return p - buf;
|
return p - buf;
|
||||||
}
|
}
|
||||||
|
@ -210,7 +211,7 @@ eucjp_mbc_case_fold(OnigCaseFoldType flag,
|
||||||
else {
|
else {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
len = enc_len(ONIG_ENCODING_EUC_JP, p, end);
|
len = enclen(ONIG_ENCODING_EUC_JP, p, end);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
*lower++ = *p++;
|
*lower++ = *p++;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +233,7 @@ eucjp_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc
|
||||||
p = s;
|
p = s;
|
||||||
|
|
||||||
while (!eucjp_islead(*p) && p > start) p--;
|
while (!eucjp_islead(*p) && p > start) p--;
|
||||||
len = enc_len(ONIG_ENCODING_EUC_JP, p, s);
|
len = enclen(ONIG_ENCODING_EUC_JP, p, s);
|
||||||
if (p + len > s) return (UChar* )p;
|
if (p + len > s) return (UChar* )p;
|
||||||
p += len;
|
p += len;
|
||||||
return (UChar* )(p + ((s - p) & ~1));
|
return (UChar* )(p + ((s - p) & ~1));
|
||||||
|
@ -311,7 +312,7 @@ eucjp_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
|
||||||
|
|
||||||
ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
|
ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
|
||||||
if (ctype >= (unsigned int )PropertyListNum)
|
if (ctype >= (unsigned int )PropertyListNum)
|
||||||
return ONIGENC_ERR_TYPE_BUG;
|
return ONIGERR_TYPE_BUG;
|
||||||
|
|
||||||
return onig_is_in_code_range((UChar* )PropertyList[ctype], code);
|
return onig_is_in_code_range((UChar* )PropertyList[ctype], code);
|
||||||
}
|
}
|
||||||
|
@ -320,7 +321,7 @@ eucjp_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
eucjp_get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
|
eucjp_get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out,
|
||||||
const OnigCodePoint* ranges[], OnigEncoding enc)
|
const OnigCodePoint* ranges[], OnigEncoding enc)
|
||||||
{
|
{
|
||||||
if (ctype <= ONIGENC_MAX_STD_CTYPE) {
|
if (ctype <= ONIGENC_MAX_STD_CTYPE) {
|
||||||
|
@ -332,8 +333,8 @@ eucjp_get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
|
||||||
PROPERTY_LIST_INIT_CHECK;
|
PROPERTY_LIST_INIT_CHECK;
|
||||||
|
|
||||||
ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
|
ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
|
||||||
if (ctype >= PropertyListNum)
|
if (ctype >= (OnigCtype )PropertyListNum)
|
||||||
return ONIGENC_ERR_TYPE_BUG;
|
return ONIGERR_TYPE_BUG;
|
||||||
|
|
||||||
*ranges = PropertyList[ctype];
|
*ranges = PropertyList[ctype];
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
iso8859_10.c - Oniguruma (regular expression library)
|
iso8859_10.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -124,8 +124,7 @@ iso_8859_10_mbc_case_fold(OnigCaseFoldType flag,
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int
|
static int
|
||||||
iso_8859_10_is_mbc_ambiguous(OnigCaseFoldType flag,
|
is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
|
||||||
const UChar** pp, const UChar* end)
|
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
const UChar* p = *pp;
|
const UChar* p = *pp;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
iso8859_11.c - Oniguruma (regular expression library)
|
iso8859_11.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
iso8859_13.c - Oniguruma (regular expression library)
|
iso8859_13.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -124,8 +124,7 @@ iso_8859_13_mbc_case_fold(OnigCaseFoldType flag,
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int
|
static int
|
||||||
iso_8859_13_is_mbc_ambiguous(OnigCaseFoldType flag,
|
is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
|
||||||
const UChar** pp, const UChar* end)
|
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
const UChar* p = *pp;
|
const UChar* p = *pp;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
iso8859_14.c - Oniguruma (regular expression library)
|
iso8859_14.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -124,7 +124,7 @@ iso_8859_14_mbc_case_fold(OnigCaseFoldType flag,
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int
|
static int
|
||||||
iso_8859_14_is_mbc_ambiguous(OnigCaseFoldType flag,
|
is_mbc_ambiguous(OnigCaseFoldType flag,
|
||||||
const UChar** pp, const UChar* end)
|
const UChar** pp, const UChar* end)
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
iso8859_15.c - Oniguruma (regular expression library)
|
iso8859_15.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -124,7 +124,7 @@ iso_8859_15_mbc_case_fold(OnigCaseFoldType flag,
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int
|
static int
|
||||||
iso_8859_15_is_mbc_ambiguous(OnigCaseFoldType flag,
|
is_mbc_ambiguous(OnigCaseFoldType flag,
|
||||||
const UChar** pp, const UChar* end)
|
const UChar** pp, const UChar* end)
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
iso8859_16.c - Oniguruma (regular expression library)
|
iso8859_16.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -124,8 +124,7 @@ iso_8859_16_mbc_case_fold(OnigCaseFoldType flag,
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int
|
static int
|
||||||
iso_8859_16_is_mbc_ambiguous(OnigCaseFoldType flag,
|
is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
|
||||||
const UChar** pp, const UChar* end)
|
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
const UChar* p = *pp;
|
const UChar* p = *pp;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
iso8859_8.c - Oniguruma (regular expression library)
|
iso8859_8.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
iso8859_9.c - Oniguruma (regular expression library)
|
iso8859_9.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -124,8 +124,7 @@ iso_8859_9_mbc_case_fold(OnigCaseFoldType flag,
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int
|
static int
|
||||||
iso_8859_9_is_mbc_ambiguous(OnigCaseFoldType flag,
|
is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
|
||||||
const UChar** pp, const UChar* end)
|
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
const UChar* p = *pp;
|
const UChar* p = *pp;
|
||||||
|
|
20
enc/sjis.c
20
enc/sjis.c
|
@ -141,7 +141,7 @@ sjis_code_to_mbclen(OnigCodePoint code, OnigEncoding enc)
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
return ONIGERR_INVALID_CODE_POINT_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static OnigCodePoint
|
static OnigCodePoint
|
||||||
|
@ -150,7 +150,7 @@ sjis_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
|
||||||
int c, i, len;
|
int c, i, len;
|
||||||
OnigCodePoint n;
|
OnigCodePoint n;
|
||||||
|
|
||||||
len = enc_len(ONIG_ENCODING_SJIS, p, end);
|
len = enclen(ONIG_ENCODING_SJIS, p, end);
|
||||||
c = *p++;
|
c = *p++;
|
||||||
n = c;
|
n = c;
|
||||||
if (len == 1) return n;
|
if (len == 1) return n;
|
||||||
|
@ -172,8 +172,8 @@ sjis_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)
|
||||||
*p++ = (UChar )(code & 0xff);
|
*p++ = (UChar )(code & 0xff);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (enc_len(ONIG_ENCODING_SJIS, buf) != (p - buf))
|
if (enclen(ONIG_ENCODING_SJIS, buf) != (p - buf))
|
||||||
return REGERR_INVALID_WIDE_CHAR_VALUE;
|
return REGERR_INVALID_CODE_POINT_VALUE;
|
||||||
#endif
|
#endif
|
||||||
return p - buf;
|
return p - buf;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ sjis_mbc_case_fold(OnigCaseFoldType flag,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int i;
|
int i;
|
||||||
int len = enc_len(ONIG_ENCODING_SJIS, p, end);
|
int len = enclen(ONIG_ENCODING_SJIS, p, end);
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
*lower++ = *p++;
|
*lower++ = *p++;
|
||||||
|
@ -245,7 +245,7 @@ sjis_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len = enc_len(ONIG_ENCODING_SJIS, p, s);
|
len = enclen(ONIG_ENCODING_SJIS, p, s);
|
||||||
if (p + len > s) return (UChar* )p;
|
if (p + len > s) return (UChar* )p;
|
||||||
p += len;
|
p += len;
|
||||||
return (UChar* )(p + ((s - p) & ~1));
|
return (UChar* )(p + ((s - p) & ~1));
|
||||||
|
@ -322,7 +322,7 @@ sjis_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
|
||||||
|
|
||||||
ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
|
ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
|
||||||
if (ctype >= (unsigned int )PropertyListNum)
|
if (ctype >= (unsigned int )PropertyListNum)
|
||||||
return ONIGENC_ERR_TYPE_BUG;
|
return ONIGERR_TYPE_BUG;
|
||||||
|
|
||||||
return onig_is_in_code_range((UChar* )PropertyList[ctype], code);
|
return onig_is_in_code_range((UChar* )PropertyList[ctype], code);
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ sjis_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sjis_get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
|
sjis_get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out,
|
||||||
const OnigCodePoint* ranges[], OnigEncoding enc)
|
const OnigCodePoint* ranges[], OnigEncoding enc)
|
||||||
{
|
{
|
||||||
if (ctype <= ONIGENC_MAX_STD_CTYPE) {
|
if (ctype <= ONIGENC_MAX_STD_CTYPE) {
|
||||||
|
@ -343,8 +343,8 @@ sjis_get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
|
||||||
PROPERTY_LIST_INIT_CHECK;
|
PROPERTY_LIST_INIT_CHECK;
|
||||||
|
|
||||||
ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
|
ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
|
||||||
if (ctype >= PropertyListNum)
|
if (ctype >= (OnigCtype )PropertyListNum)
|
||||||
return ONIGENC_ERR_TYPE_BUG;
|
return ONIGERR_TYPE_BUG;
|
||||||
|
|
||||||
*ranges = PropertyList[ctype];
|
*ranges = PropertyList[ctype];
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -10618,7 +10618,7 @@ static PosixBracketEntryType HashEntryData[] = {
|
||||||
static const OnigCodePoint* CodeRanges[CODE_RANGES_NUM];
|
static const OnigCodePoint* CodeRanges[CODE_RANGES_NUM];
|
||||||
static int CodeRangeTableInited = 0;
|
static int CodeRangeTableInited = 0;
|
||||||
|
|
||||||
static void init_code_range_array() {
|
static void init_code_range_array(void) {
|
||||||
THREAD_ATOMIC_START;
|
THREAD_ATOMIC_START;
|
||||||
|
|
||||||
CodeRanges[0] = CR_NEWLINE;
|
CodeRanges[0] = CR_NEWLINE;
|
||||||
|
@ -10756,7 +10756,7 @@ onigenc_unicode_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncodi
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctype >= CODE_RANGES_NUM) {
|
if (ctype >= CODE_RANGES_NUM) {
|
||||||
return ONIGENC_ERR_TYPE_BUG;
|
return ONIGERR_TYPE_BUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CodeRangeTableInited == 0) init_code_range_array();
|
if (CodeRangeTableInited == 0) init_code_range_array();
|
||||||
|
@ -10769,7 +10769,7 @@ extern int
|
||||||
onigenc_unicode_ctype_code_range(int ctype, const OnigCodePoint* ranges[])
|
onigenc_unicode_ctype_code_range(int ctype, const OnigCodePoint* ranges[])
|
||||||
{
|
{
|
||||||
if (ctype >= CODE_RANGES_NUM) {
|
if (ctype >= CODE_RANGES_NUM) {
|
||||||
return ONIGENC_ERR_TYPE_BUG;
|
return ONIGERR_TYPE_BUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CodeRangeTableInited == 0) init_code_range_array();
|
if (CodeRangeTableInited == 0) init_code_range_array();
|
||||||
|
@ -10780,7 +10780,7 @@ onigenc_unicode_ctype_code_range(int ctype, const OnigCodePoint* ranges[])
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
onigenc_utf16_32_get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
|
onigenc_utf16_32_get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out,
|
||||||
const OnigCodePoint* ranges[])
|
const OnigCodePoint* ranges[])
|
||||||
{
|
{
|
||||||
*sb_out = 0x00;
|
*sb_out = 0x00;
|
||||||
|
@ -10832,7 +10832,7 @@ onigenc_unicode_property_name_to_ctype(OnigEncoding enc, UChar* name, UChar* end
|
||||||
if (len >= PROPERTY_NAME_MAX_SIZE)
|
if (len >= PROPERTY_NAME_MAX_SIZE)
|
||||||
return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
|
return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
|
||||||
|
|
||||||
p += enc_len(enc, p, end);
|
p += enclen(enc, p, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[len] = 0;
|
buf[len] = 0;
|
||||||
|
@ -10903,11 +10903,12 @@ static int init_case_fold_table(void)
|
||||||
|
|
||||||
FoldTable = st_init_numtable_with_size(1200);
|
FoldTable = st_init_numtable_with_size(1200);
|
||||||
if (ONIG_IS_NULL(FoldTable)) return ONIGERR_MEMORY;
|
if (ONIG_IS_NULL(FoldTable)) return ONIGERR_MEMORY;
|
||||||
for (i = 0; i < sizeof(CaseFold)/sizeof(CaseFold_11_Type); i++) {
|
for (i = 0; i < (int )(sizeof(CaseFold)/sizeof(CaseFold_11_Type)); i++) {
|
||||||
p = &CaseFold[i];
|
p = &CaseFold[i];
|
||||||
st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )&(p->to));
|
st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )&(p->to));
|
||||||
}
|
}
|
||||||
for (i = 0; i < sizeof(CaseFold_Locale)/sizeof(CaseFold_11_Type); i++) {
|
for (i = 0; i < (int )(sizeof(CaseFold_Locale)/sizeof(CaseFold_11_Type));
|
||||||
|
i++) {
|
||||||
p = &CaseFold_Locale[i];
|
p = &CaseFold_Locale[i];
|
||||||
st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )&(p->to));
|
st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )&(p->to));
|
||||||
}
|
}
|
||||||
|
@ -10915,11 +10916,13 @@ static int init_case_fold_table(void)
|
||||||
Unfold1Table = st_init_numtable_with_size(1000);
|
Unfold1Table = st_init_numtable_with_size(1000);
|
||||||
if (ONIG_IS_NULL(Unfold1Table)) return ONIGERR_MEMORY;
|
if (ONIG_IS_NULL(Unfold1Table)) return ONIGERR_MEMORY;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(CaseUnfold_11)/sizeof(CaseUnfold_11_Type); i++) {
|
for (i = 0; i < (int )(sizeof(CaseUnfold_11)/sizeof(CaseUnfold_11_Type));
|
||||||
|
i++) {
|
||||||
p1 = &CaseUnfold_11[i];
|
p1 = &CaseUnfold_11[i];
|
||||||
st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )&(p1->to));
|
st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )&(p1->to));
|
||||||
}
|
}
|
||||||
for (i = 0; i < sizeof(CaseUnfold_11_Locale)/sizeof(CaseUnfold_11_Type);
|
for (i = 0;
|
||||||
|
i < (int )(sizeof(CaseUnfold_11_Locale)/sizeof(CaseUnfold_11_Type));
|
||||||
i++) {
|
i++) {
|
||||||
p1 = &CaseUnfold_11_Locale[i];
|
p1 = &CaseUnfold_11_Locale[i];
|
||||||
st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )&(p1->to));
|
st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )&(p1->to));
|
||||||
|
@ -10928,11 +10931,13 @@ static int init_case_fold_table(void)
|
||||||
Unfold2Table = st_init_table_with_size(&type_code2_hash, 200);
|
Unfold2Table = st_init_table_with_size(&type_code2_hash, 200);
|
||||||
if (ONIG_IS_NULL(Unfold2Table)) return ONIGERR_MEMORY;
|
if (ONIG_IS_NULL(Unfold2Table)) return ONIGERR_MEMORY;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(CaseUnfold_12)/sizeof(CaseUnfold_12_Type); i++) {
|
for (i = 0; i < (int )(sizeof(CaseUnfold_12)/sizeof(CaseUnfold_12_Type));
|
||||||
|
i++) {
|
||||||
p2 = &CaseUnfold_12[i];
|
p2 = &CaseUnfold_12[i];
|
||||||
st_add_direct(Unfold2Table, (st_data_t )p2->from, (st_data_t )(&p2->to));
|
st_add_direct(Unfold2Table, (st_data_t )p2->from, (st_data_t )(&p2->to));
|
||||||
}
|
}
|
||||||
for (i = 0; i < sizeof(CaseUnfold_12_Locale)/sizeof(CaseUnfold_12_Type);
|
for (i = 0;
|
||||||
|
i < (int )(sizeof(CaseUnfold_12_Locale)/sizeof(CaseUnfold_12_Type));
|
||||||
i++) {
|
i++) {
|
||||||
p2 = &CaseUnfold_12_Locale[i];
|
p2 = &CaseUnfold_12_Locale[i];
|
||||||
st_add_direct(Unfold2Table, (st_data_t )p2->from, (st_data_t )(&p2->to));
|
st_add_direct(Unfold2Table, (st_data_t )p2->from, (st_data_t )(&p2->to));
|
||||||
|
@ -10941,7 +10946,8 @@ static int init_case_fold_table(void)
|
||||||
Unfold3Table = st_init_table_with_size(&type_code3_hash, 30);
|
Unfold3Table = st_init_table_with_size(&type_code3_hash, 30);
|
||||||
if (ONIG_IS_NULL(Unfold3Table)) return ONIGERR_MEMORY;
|
if (ONIG_IS_NULL(Unfold3Table)) return ONIGERR_MEMORY;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(CaseUnfold_13)/sizeof(CaseUnfold_13_Type); i++) {
|
for (i = 0; i < (int )(sizeof(CaseUnfold_13)/sizeof(CaseUnfold_13_Type));
|
||||||
|
i++) {
|
||||||
p3 = &CaseUnfold_13[i];
|
p3 = &CaseUnfold_13[i];
|
||||||
st_add_direct(Unfold3Table, (st_data_t )p3->from, (st_data_t )(&p3->to));
|
st_add_direct(Unfold3Table, (st_data_t )p3->from, (st_data_t )(&p3->to));
|
||||||
}
|
}
|
||||||
|
@ -10953,7 +10959,8 @@ static int init_case_fold_table(void)
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
onigenc_unicode_mbc_case_fold(OnigEncoding enc,
|
onigenc_unicode_mbc_case_fold(OnigEncoding enc,
|
||||||
OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold)
|
OnigCaseFoldType flag ARG_UNUSED, const UChar** pp, const UChar* end,
|
||||||
|
UChar* fold)
|
||||||
{
|
{
|
||||||
CodePointList3 *to;
|
CodePointList3 *to;
|
||||||
OnigCodePoint code;
|
OnigCodePoint code;
|
||||||
|
@ -10963,7 +10970,7 @@ onigenc_unicode_mbc_case_fold(OnigEncoding enc,
|
||||||
if (CaseFoldInited == 0) init_case_fold_table();
|
if (CaseFoldInited == 0) init_case_fold_table();
|
||||||
|
|
||||||
code = ONIGENC_MBC_TO_CODE(enc, p, end);
|
code = ONIGENC_MBC_TO_CODE(enc, p, end);
|
||||||
len = enc_len(enc, p, end);
|
len = enclen(enc, p, end);
|
||||||
*pp += len;
|
*pp += len;
|
||||||
|
|
||||||
#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
|
#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
|
||||||
|
@ -11014,7 +11021,8 @@ onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag,
|
||||||
|
|
||||||
/* if (CaseFoldInited == 0) init_case_fold_table(); */
|
/* if (CaseFoldInited == 0) init_case_fold_table(); */
|
||||||
|
|
||||||
for (i = 0; i < sizeof(CaseUnfold_11)/sizeof(CaseUnfold_11_Type); i++) {
|
for (i = 0; i < (int )(sizeof(CaseUnfold_11)/sizeof(CaseUnfold_11_Type));
|
||||||
|
i++) {
|
||||||
p11 = &CaseUnfold_11[i];
|
p11 = &CaseUnfold_11[i];
|
||||||
for (j = 0; j < p11->to.n; j++) {
|
for (j = 0; j < p11->to.n; j++) {
|
||||||
code = p11->from;
|
code = p11->from;
|
||||||
|
@ -11053,7 +11061,8 @@ onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i < sizeof(CaseUnfold_11_Locale)/sizeof(CaseUnfold_11_Type);
|
for (i = 0;
|
||||||
|
i < (int )(sizeof(CaseUnfold_11_Locale)/sizeof(CaseUnfold_11_Type));
|
||||||
i++) {
|
i++) {
|
||||||
p11 = &CaseUnfold_11_Locale[i];
|
p11 = &CaseUnfold_11_Locale[i];
|
||||||
for (j = 0; j < p11->to.n; j++) {
|
for (j = 0; j < p11->to.n; j++) {
|
||||||
|
@ -11081,7 +11090,8 @@ onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
|
if ((flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
|
||||||
for (i = 0; i < sizeof(CaseUnfold_12)/sizeof(CaseUnfold_12_Type); i++) {
|
for (i = 0; i < (int )(sizeof(CaseUnfold_12)/sizeof(CaseUnfold_12_Type));
|
||||||
|
i++) {
|
||||||
for (j = 0; j < CaseUnfold_12[i].to.n; j++) {
|
for (j = 0; j < CaseUnfold_12[i].to.n; j++) {
|
||||||
r = (*f)(CaseUnfold_12[i].to.code[j],
|
r = (*f)(CaseUnfold_12[i].to.code[j],
|
||||||
(OnigCodePoint* )CaseUnfold_12[i].from, 2, arg);
|
(OnigCodePoint* )CaseUnfold_12[i].from, 2, arg);
|
||||||
|
@ -11100,7 +11110,8 @@ onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag,
|
||||||
#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
|
#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
|
||||||
if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) == 0) {
|
if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) == 0) {
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i < sizeof(CaseUnfold_12_Locale)/sizeof(CaseUnfold_12_Type);
|
for (i = 0;
|
||||||
|
i < (int )(sizeof(CaseUnfold_12_Locale)/sizeof(CaseUnfold_12_Type));
|
||||||
i++) {
|
i++) {
|
||||||
for (j = 0; j < CaseUnfold_12_Locale[i].to.n; j++) {
|
for (j = 0; j < CaseUnfold_12_Locale[i].to.n; j++) {
|
||||||
r = (*f)(CaseUnfold_12_Locale[i].to.code[j],
|
r = (*f)(CaseUnfold_12_Locale[i].to.code[j],
|
||||||
|
@ -11121,7 +11132,8 @@ onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < sizeof(CaseUnfold_13)/sizeof(CaseUnfold_13_Type); i++) {
|
for (i = 0; i < (int )(sizeof(CaseUnfold_13)/sizeof(CaseUnfold_13_Type));
|
||||||
|
i++) {
|
||||||
for (j = 0; j < CaseUnfold_13[i].to.n; j++) {
|
for (j = 0; j < CaseUnfold_13[i].to.n; j++) {
|
||||||
r = (*f)(CaseUnfold_13[i].to.code[j],
|
r = (*f)(CaseUnfold_13[i].to.code[j],
|
||||||
(OnigCodePoint* )CaseUnfold_13[i].from, 3, arg);
|
(OnigCodePoint* )CaseUnfold_13[i].from, 3, arg);
|
||||||
|
@ -11156,7 +11168,7 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
code = ONIGENC_MBC_TO_CODE(enc, p, end);
|
code = ONIGENC_MBC_TO_CODE(enc, p, end);
|
||||||
len = enc_len(enc, p, end);
|
len = enclen(enc, p, end);
|
||||||
|
|
||||||
#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
|
#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
|
||||||
if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
|
if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
|
||||||
|
@ -11305,7 +11317,7 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
|
||||||
else
|
else
|
||||||
codes[1] = code;
|
codes[1] = code;
|
||||||
|
|
||||||
clen = enc_len(enc, p, end);
|
clen = enclen(enc, p, end);
|
||||||
len += clen;
|
len += clen;
|
||||||
if (onig_st_lookup(Unfold2Table, (st_data_t )codes, (void* )&z2) != 0) {
|
if (onig_st_lookup(Unfold2Table, (st_data_t )codes, (void* )&z2) != 0) {
|
||||||
for (i = 0; i < z2->n; i++) {
|
for (i = 0; i < z2->n; i++) {
|
||||||
|
@ -11326,7 +11338,7 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
|
||||||
else
|
else
|
||||||
codes[2] = code;
|
codes[2] = code;
|
||||||
|
|
||||||
clen = enc_len(enc, p, end);
|
clen = enclen(enc, p, end);
|
||||||
len += clen;
|
len += clen;
|
||||||
if (onig_st_lookup(Unfold3Table, (st_data_t )codes,
|
if (onig_st_lookup(Unfold3Table, (st_data_t )codes,
|
||||||
(void* )&z2) != 0) {
|
(void* )&z2) != 0) {
|
||||||
|
|
40
enc/utf8.c
40
enc/utf8.c
|
@ -272,7 +272,7 @@ utf8_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
|
||||||
int c, len;
|
int c, len;
|
||||||
OnigCodePoint n;
|
OnigCodePoint n;
|
||||||
|
|
||||||
len = enc_len(ONIG_ENCODING_UTF8, p, end);
|
len = enclen(ONIG_ENCODING_UTF8, p, end);
|
||||||
c = *p++;
|
c = *p++;
|
||||||
if (len > 1) {
|
if (len > 1) {
|
||||||
len--;
|
len--;
|
||||||
|
@ -307,33 +307,9 @@ utf8_code_to_mbclen(OnigCodePoint code, OnigEncoding enc)
|
||||||
else if (code == INVALID_CODE_FF) return 1;
|
else if (code == INVALID_CODE_FF) return 1;
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
return ONIGENC_ERR_TOO_BIG_WIDE_CHAR_VALUE;
|
return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static int
|
|
||||||
utf8_code_to_mbc_first(OnigCodePoint code)
|
|
||||||
{
|
|
||||||
if ((code & 0xffffff80) == 0)
|
|
||||||
return code;
|
|
||||||
else {
|
|
||||||
if ((code & 0xfffff800) == 0)
|
|
||||||
return ((code>>6)& 0x1f) | 0xc0;
|
|
||||||
else if ((code & 0xffff0000) == 0)
|
|
||||||
return ((code>>12) & 0x0f) | 0xe0;
|
|
||||||
else if ((code & 0xffe00000) == 0)
|
|
||||||
return ((code>>18) & 0x07) | 0xf0;
|
|
||||||
else if ((code & 0xfc000000) == 0)
|
|
||||||
return ((code>>24) & 0x03) | 0xf8;
|
|
||||||
else if ((code & 0x80000000) == 0)
|
|
||||||
return ((code>>30) & 0x01) | 0xfc;
|
|
||||||
else {
|
|
||||||
return ONIGENC_ERR_TOO_BIG_WIDE_CHAR_VALUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
utf8_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)
|
utf8_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)
|
||||||
{
|
{
|
||||||
|
@ -383,7 +359,7 @@ utf8_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
return ONIGENC_ERR_TOO_BIG_WIDE_CHAR_VALUE;
|
return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*p++ = UTF8_TRAIL0(code);
|
*p++ = UTF8_TRAIL0(code);
|
||||||
|
@ -421,7 +397,7 @@ utf8_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp,
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int
|
static int
|
||||||
utf8_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
|
is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
|
||||||
{
|
{
|
||||||
const UChar* p = *pp;
|
const UChar* p = *pp;
|
||||||
|
|
||||||
|
@ -430,7 +406,7 @@ utf8_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
|
||||||
return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
|
return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(*pp) += enc_len(ONIG_ENCODING_UTF8, p);
|
(*pp) += enclen(ONIG_ENCODING_UTF8, p);
|
||||||
|
|
||||||
if (*p == 0xc3) {
|
if (*p == 0xc3) {
|
||||||
int c = *(p + 1);
|
int c = *(p + 1);
|
||||||
|
@ -457,7 +433,7 @@ utf8_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
utf8_get_ctype_code_range(int ctype, OnigCodePoint *sb_out,
|
utf8_get_ctype_code_range(OnigCtype ctype, OnigCodePoint *sb_out,
|
||||||
const OnigCodePoint* ranges[], OnigEncoding enc)
|
const OnigCodePoint* ranges[], OnigEncoding enc)
|
||||||
{
|
{
|
||||||
*sb_out = 0x80;
|
*sb_out = 0x80;
|
||||||
|
@ -478,7 +454,7 @@ utf8_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
utf8_get_case_fold_codes_by_str(OnigCaseFoldType flag,
|
get_case_fold_codes_by_str(OnigCaseFoldType flag,
|
||||||
const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[],
|
const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[],
|
||||||
OnigEncoding enc)
|
OnigEncoding enc)
|
||||||
{
|
{
|
||||||
|
@ -497,7 +473,7 @@ OnigEncodingDefine(utf8, UTF8) = {
|
||||||
utf8_code_to_mbc,
|
utf8_code_to_mbc,
|
||||||
utf8_mbc_case_fold,
|
utf8_mbc_case_fold,
|
||||||
onigenc_unicode_apply_all_case_fold,
|
onigenc_unicode_apply_all_case_fold,
|
||||||
utf8_get_case_fold_codes_by_str,
|
get_case_fold_codes_by_str,
|
||||||
onigenc_unicode_property_name_to_ctype,
|
onigenc_unicode_property_name_to_ctype,
|
||||||
onigenc_unicode_is_code_ctype,
|
onigenc_unicode_is_code_ctype,
|
||||||
utf8_get_ctype_code_range,
|
utf8_get_ctype_code_range,
|
||||||
|
|
|
@ -39,7 +39,7 @@ extern "C" {
|
||||||
#define ONIGURUMA
|
#define ONIGURUMA
|
||||||
#define ONIGURUMA_VERSION_MAJOR 5
|
#define ONIGURUMA_VERSION_MAJOR 5
|
||||||
#define ONIGURUMA_VERSION_MINOR 9
|
#define ONIGURUMA_VERSION_MINOR 9
|
||||||
#define ONIGURUMA_VERSION_TEENY 0
|
#define ONIGURUMA_VERSION_TEENY 1
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
# ifndef HAVE_PROTOTYPES
|
# ifndef HAVE_PROTOTYPES
|
||||||
|
@ -57,6 +57,12 @@ extern "C" {
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_STDARG_H
|
||||||
|
# ifndef HAVE_STDARG_PROTOTYPES
|
||||||
|
# define HAVE_STDARG_PROTOTYPES 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef P_
|
#ifndef P_
|
||||||
#if defined(__STDC__) || defined(_WIN32)
|
#if defined(__STDC__) || defined(_WIN32)
|
||||||
# define P_(args) args
|
# define P_(args) args
|
||||||
|
@ -99,12 +105,12 @@ extern "C" {
|
||||||
|
|
||||||
typedef unsigned char OnigUChar;
|
typedef unsigned char OnigUChar;
|
||||||
typedef unsigned long OnigCodePoint;
|
typedef unsigned long OnigCodePoint;
|
||||||
|
typedef unsigned int OnigCtype;
|
||||||
typedef unsigned int OnigDistance;
|
typedef unsigned int OnigDistance;
|
||||||
|
|
||||||
#define ONIG_INFINITE_DISTANCE ~((OnigDistance )0)
|
#define ONIG_INFINITE_DISTANCE ~((OnigDistance )0)
|
||||||
|
|
||||||
/* case fold flag */
|
typedef unsigned int OnigCaseFoldType; /* case fold flag */
|
||||||
typedef unsigned int OnigCaseFoldType;
|
|
||||||
|
|
||||||
ONIG_EXTERN OnigCaseFoldType OnigDefaultCaseFoldFlag;
|
ONIG_EXTERN OnigCaseFoldType OnigDefaultCaseFoldFlag;
|
||||||
|
|
||||||
|
@ -156,8 +162,8 @@ typedef struct OnigEncodingTypeST {
|
||||||
int (*apply_all_case_fold)(OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, struct OnigEncodingTypeST* enc);
|
int (*apply_all_case_fold)(OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, struct OnigEncodingTypeST* enc);
|
||||||
int (*get_case_fold_codes_by_str)(OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem acs[], struct OnigEncodingTypeST* enc);
|
int (*get_case_fold_codes_by_str)(OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem acs[], struct OnigEncodingTypeST* enc);
|
||||||
int (*property_name_to_ctype)(struct OnigEncodingTypeST* enc, OnigUChar* p, OnigUChar* end);
|
int (*property_name_to_ctype)(struct OnigEncodingTypeST* enc, OnigUChar* p, OnigUChar* end);
|
||||||
int (*is_code_ctype)(OnigCodePoint code, unsigned int ctype, struct OnigEncodingTypeST* enc);
|
int (*is_code_ctype)(OnigCodePoint code, OnigCtype ctype, struct OnigEncodingTypeST* enc);
|
||||||
int (*get_ctype_code_range)(int ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], struct OnigEncodingTypeST* enc);
|
int (*get_ctype_code_range)(OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], struct OnigEncodingTypeST* enc);
|
||||||
OnigUChar* (*left_adjust_char_head)(const OnigUChar* start, const OnigUChar* p, struct OnigEncodingTypeST* enc);
|
OnigUChar* (*left_adjust_char_head)(const OnigUChar* start, const OnigUChar* p, struct OnigEncodingTypeST* enc);
|
||||||
int (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end, struct OnigEncodingTypeST* enc);
|
int (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end, struct OnigEncodingTypeST* enc);
|
||||||
void *auxiliary_data;
|
void *auxiliary_data;
|
||||||
|
@ -256,7 +262,7 @@ ONIG_EXTERN OnigEncodingType OnigEncodingGB18030;
|
||||||
#define ONIGENC_MAX_STD_CTYPE ONIGENC_CTYPE_ASCII
|
#define ONIGENC_MAX_STD_CTYPE ONIGENC_CTYPE_ASCII
|
||||||
|
|
||||||
|
|
||||||
#define enc_len(enc,p,e) ONIGENC_MBC_ENC_LEN(enc, p, e)
|
#define onig_enc_len(enc,p,e) ONIGENC_MBC_ENC_LEN(enc, p, e)
|
||||||
|
|
||||||
#define ONIGENC_IS_UNDEF(enc) ((enc) == ONIG_ENCODING_UNDEF)
|
#define ONIGENC_IS_UNDEF(enc) ((enc) == ONIG_ENCODING_UNDEF)
|
||||||
#define ONIGENC_IS_SINGLEBYTE(enc) (ONIGENC_MBC_MAXLEN(enc) == 1)
|
#define ONIGENC_IS_SINGLEBYTE(enc) (ONIGENC_MBC_MAXLEN(enc) == 1)
|
||||||
|
@ -604,6 +610,7 @@ ONIG_EXTERN OnigSyntaxType* OnigDefaultSyntax;
|
||||||
#define ONIGERR_NEVER_ENDING_RECURSION -221
|
#define ONIGERR_NEVER_ENDING_RECURSION -221
|
||||||
#define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY -222
|
#define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY -222
|
||||||
#define ONIGERR_INVALID_CHAR_PROPERTY_NAME -223
|
#define ONIGERR_INVALID_CHAR_PROPERTY_NAME -223
|
||||||
|
#define ONIGERR_INVALID_CODE_POINT_VALUE -400
|
||||||
#define ONIGERR_INVALID_WIDE_CHAR_VALUE -400
|
#define ONIGERR_INVALID_WIDE_CHAR_VALUE -400
|
||||||
#define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE -401
|
#define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE -401
|
||||||
#define ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION -402
|
#define ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION -402
|
||||||
|
|
126
regcomp.c
126
regcomp.c
|
@ -115,7 +115,7 @@ static int
|
||||||
bitset_is_empty(BitSetRef bs)
|
bitset_is_empty(BitSetRef bs)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < BITSET_SIZE; i++) {
|
for (i = 0; i < (int )BITSET_SIZE; i++) {
|
||||||
if (bs[i] != 0) return 0;
|
if (bs[i] != 0) return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -416,8 +416,8 @@ compile_tree_n_times(Node* node, int n, regex_t* reg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
add_compile_string_length(UChar* s, int mb_len, int str_len,
|
add_compile_string_length(UChar* s ARG_UNUSED, int mb_len, int str_len,
|
||||||
regex_t* reg, int ignore_case)
|
regex_t* reg ARG_UNUSED, int ignore_case)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int op = select_str_opcode(mb_len, str_len, ignore_case);
|
int op = select_str_opcode(mb_len, str_len, ignore_case);
|
||||||
|
@ -469,13 +469,13 @@ compile_length_string_node(Node* node, regex_t* reg)
|
||||||
ambig = NSTRING_IS_AMBIG(node);
|
ambig = NSTRING_IS_AMBIG(node);
|
||||||
|
|
||||||
p = prev = sn->s;
|
p = prev = sn->s;
|
||||||
prev_len = enc_len(enc, p, sn->end);
|
prev_len = enclen(enc, p, sn->end);
|
||||||
p += prev_len;
|
p += prev_len;
|
||||||
slen = 1;
|
slen = 1;
|
||||||
rlen = 0;
|
rlen = 0;
|
||||||
|
|
||||||
for (; p < sn->end; ) {
|
for (; p < sn->end; ) {
|
||||||
len = enc_len(enc, p, sn->end);
|
len = enclen(enc, p, sn->end);
|
||||||
if (len == prev_len) {
|
if (len == prev_len) {
|
||||||
slen++;
|
slen++;
|
||||||
}
|
}
|
||||||
|
@ -518,12 +518,12 @@ compile_string_node(Node* node, regex_t* reg)
|
||||||
ambig = NSTRING_IS_AMBIG(node);
|
ambig = NSTRING_IS_AMBIG(node);
|
||||||
|
|
||||||
p = prev = sn->s;
|
p = prev = sn->s;
|
||||||
prev_len = enc_len(enc, p, end);
|
prev_len = enclen(enc, p, end);
|
||||||
p += prev_len;
|
p += prev_len;
|
||||||
slen = 1;
|
slen = 1;
|
||||||
|
|
||||||
for (; p < end; ) {
|
for (; p < end; ) {
|
||||||
len = enc_len(enc, p, end);
|
len = enclen(enc, p, end);
|
||||||
if (len == prev_len) {
|
if (len == prev_len) {
|
||||||
slen++;
|
slen++;
|
||||||
}
|
}
|
||||||
|
@ -1535,7 +1535,7 @@ compile_length_tree(Node* node, regex_t* reg)
|
||||||
{
|
{
|
||||||
BRefNode* br = NBREF(node);
|
BRefNode* br = NBREF(node);
|
||||||
|
|
||||||
#ifdef USE_BACKREF_AT_LEVEL
|
#ifdef USE_BACKREF_WITH_LEVEL
|
||||||
if (IS_BACKREF_NEST_LEVEL(br)) {
|
if (IS_BACKREF_NEST_LEVEL(br)) {
|
||||||
r = SIZE_OPCODE + SIZE_OPTION + SIZE_LENGTH +
|
r = SIZE_OPCODE + SIZE_OPTION + SIZE_LENGTH +
|
||||||
SIZE_LENGTH + (SIZE_MEMNUM * br->back_num);
|
SIZE_LENGTH + (SIZE_MEMNUM * br->back_num);
|
||||||
|
@ -1659,9 +1659,9 @@ compile_tree(Node* node, regex_t* reg)
|
||||||
{
|
{
|
||||||
BRefNode* br = NBREF(node);
|
BRefNode* br = NBREF(node);
|
||||||
|
|
||||||
#ifdef USE_BACKREF_AT_LEVEL
|
#ifdef USE_BACKREF_WITH_LEVEL
|
||||||
if (IS_BACKREF_NEST_LEVEL(br)) {
|
if (IS_BACKREF_NEST_LEVEL(br)) {
|
||||||
r = add_opcode(reg, OP_BACKREF_AT_LEVEL);
|
r = add_opcode(reg, OP_BACKREF_WITH_LEVEL);
|
||||||
if (r) return r;
|
if (r) return r;
|
||||||
r = add_option(reg, (reg->options & ONIG_OPTION_IGNORECASE));
|
r = add_option(reg, (reg->options & ONIG_OPTION_IGNORECASE));
|
||||||
if (r) return r;
|
if (r) return r;
|
||||||
|
@ -1703,7 +1703,7 @@ compile_tree(Node* node, regex_t* reg)
|
||||||
}
|
}
|
||||||
if (r) return r;
|
if (r) return r;
|
||||||
|
|
||||||
#ifdef USE_BACKREF_AT_LEVEL
|
#ifdef USE_BACKREF_WITH_LEVEL
|
||||||
add_bacref_mems:
|
add_bacref_mems:
|
||||||
#endif
|
#endif
|
||||||
r = add_length(reg, br->back_num);
|
r = add_length(reg, br->back_num);
|
||||||
|
@ -1951,7 +1951,7 @@ unset_addr_list_fix(UnsetAddrList* uslist, regex_t* reg)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK
|
#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
|
||||||
static int
|
static int
|
||||||
quantifiers_memory_node_info(Node* node)
|
quantifiers_memory_node_info(Node* node)
|
||||||
{
|
{
|
||||||
|
@ -2018,7 +2018,7 @@ quantifiers_memory_node_info(Node* node)
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif /* USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK */
|
#endif /* USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_min_match_length(Node* node, OnigDistance *min, ScanEnv* env)
|
get_min_match_length(Node* node, OnigDistance *min, ScanEnv* env)
|
||||||
|
@ -2312,7 +2312,7 @@ get_char_length_tree1(Node* node, regex_t* reg, int* len, int level)
|
||||||
StrNode* sn = NSTR(node);
|
StrNode* sn = NSTR(node);
|
||||||
UChar *s = sn->s;
|
UChar *s = sn->s;
|
||||||
while (s < sn->end) {
|
while (s < sn->end) {
|
||||||
s += enc_len(reg->enc, s, sn->end);
|
s += enclen(reg->enc, s, sn->end);
|
||||||
(*len)++;
|
(*len)++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3003,25 +3003,12 @@ setup_subexp_call(Node* node, ScanEnv* env)
|
||||||
|
|
||||||
case NT_CALL:
|
case NT_CALL:
|
||||||
{
|
{
|
||||||
int n, num, *refs;
|
|
||||||
UChar *p;
|
|
||||||
CallNode* cn = NCALL(node);
|
CallNode* cn = NCALL(node);
|
||||||
Node** nodes = SCANENV_MEM_NODES(env);
|
Node** nodes = SCANENV_MEM_NODES(env);
|
||||||
|
|
||||||
#ifdef USE_NAMED_GROUP
|
if (cn->group_num != 0) {
|
||||||
n = onig_name_to_group_numbers(env->reg, cn->name, cn->name_end, &refs);
|
int gnum = cn->group_num;
|
||||||
#else
|
|
||||||
n = -1;
|
|
||||||
#endif
|
|
||||||
if (n <= 0) {
|
|
||||||
/* name not found, check group number. (?*ddd) */
|
|
||||||
p = cn->name;
|
|
||||||
num = onig_scan_unsigned_number(&p, cn->name_end, env->enc);
|
|
||||||
if (num <= 0 || p != cn->name_end) {
|
|
||||||
onig_scan_env_set_error_string(env,
|
|
||||||
ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end);
|
|
||||||
return ONIGERR_UNDEFINED_NAME_REFERENCE;
|
|
||||||
}
|
|
||||||
#ifdef USE_NAMED_GROUP
|
#ifdef USE_NAMED_GROUP
|
||||||
if (env->num_named > 0 &&
|
if (env->num_named > 0 &&
|
||||||
IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
|
IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
|
||||||
|
@ -3029,13 +3016,35 @@ setup_subexp_call(Node* node, ScanEnv* env)
|
||||||
return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
|
return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (num > env->num_mem) {
|
if (gnum > env->num_mem) {
|
||||||
onig_scan_env_set_error_string(env,
|
onig_scan_env_set_error_string(env,
|
||||||
ONIGERR_UNDEFINED_GROUP_REFERENCE, cn->name, cn->name_end);
|
ONIGERR_UNDEFINED_GROUP_REFERENCE, cn->name, cn->name_end);
|
||||||
return ONIGERR_UNDEFINED_GROUP_REFERENCE;
|
return ONIGERR_UNDEFINED_GROUP_REFERENCE;
|
||||||
}
|
}
|
||||||
cn->ref_num = num;
|
|
||||||
goto set_call_attr;
|
#ifdef USE_NAMED_GROUP
|
||||||
|
set_call_attr:
|
||||||
|
#endif
|
||||||
|
cn->target = nodes[cn->group_num];
|
||||||
|
if (IS_NULL(cn->target)) {
|
||||||
|
onig_scan_env_set_error_string(env,
|
||||||
|
ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end);
|
||||||
|
return ONIGERR_UNDEFINED_NAME_REFERENCE;
|
||||||
|
}
|
||||||
|
SET_ENCLOSE_STATUS(cn->target, NST_CALLED);
|
||||||
|
BIT_STATUS_ON_AT(env->bt_mem_start, cn->group_num);
|
||||||
|
cn->unset_addr_list = env->unset_addr_list;
|
||||||
|
}
|
||||||
|
#ifdef USE_NAMED_GROUP
|
||||||
|
else {
|
||||||
|
int *refs;
|
||||||
|
|
||||||
|
int n = onig_name_to_group_numbers(env->reg, cn->name, cn->name_end,
|
||||||
|
&refs);
|
||||||
|
if (n <= 0) {
|
||||||
|
onig_scan_env_set_error_string(env,
|
||||||
|
ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end);
|
||||||
|
return ONIGERR_UNDEFINED_NAME_REFERENCE;
|
||||||
}
|
}
|
||||||
else if (n > 1) {
|
else if (n > 1) {
|
||||||
onig_scan_env_set_error_string(env,
|
onig_scan_env_set_error_string(env,
|
||||||
|
@ -3043,18 +3052,11 @@ setup_subexp_call(Node* node, ScanEnv* env)
|
||||||
return ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL;
|
return ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cn->ref_num = refs[0];
|
cn->group_num = refs[0];
|
||||||
set_call_attr:
|
goto set_call_attr;
|
||||||
cn->target = nodes[cn->ref_num];
|
|
||||||
if (IS_NULL(cn->target)) {
|
|
||||||
onig_scan_env_set_error_string(env,
|
|
||||||
ONIGERR_UNDEFINED_NAME_REFERENCE, cn->name, cn->name_end);
|
|
||||||
return ONIGERR_UNDEFINED_NAME_REFERENCE;
|
|
||||||
}
|
}
|
||||||
SET_ENCLOSE_STATUS(cn->target, NST_CALLED);
|
|
||||||
BIT_STATUS_ON_AT(env->bt_mem_start, cn->ref_num);
|
|
||||||
cn->unset_addr_list = env->unset_addr_list;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -3389,7 +3391,7 @@ expand_case_fold_string(Node* node, regex_t* reg)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = enc_len(reg->enc, p, end);
|
len = enclen(reg->enc, p, end);
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
if (IS_NULL(snode)) {
|
if (IS_NULL(snode)) {
|
||||||
|
@ -3706,7 +3708,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)
|
||||||
if (p[i] > env->num_mem) return ONIGERR_INVALID_BACKREF;
|
if (p[i] > env->num_mem) return ONIGERR_INVALID_BACKREF;
|
||||||
BIT_STATUS_ON_AT(env->backrefed_mem, p[i]);
|
BIT_STATUS_ON_AT(env->backrefed_mem, p[i]);
|
||||||
BIT_STATUS_ON_AT(env->bt_mem_start, p[i]);
|
BIT_STATUS_ON_AT(env->bt_mem_start, p[i]);
|
||||||
#ifdef USE_BACKREF_AT_LEVEL
|
#ifdef USE_BACKREF_WITH_LEVEL
|
||||||
if (IS_BACKREF_NEST_LEVEL(br)) {
|
if (IS_BACKREF_NEST_LEVEL(br)) {
|
||||||
BIT_STATUS_ON_AT(env->bt_mem_end, p[i]);
|
BIT_STATUS_ON_AT(env->bt_mem_end, p[i]);
|
||||||
}
|
}
|
||||||
|
@ -3731,7 +3733,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)
|
||||||
if (r) break;
|
if (r) break;
|
||||||
if (d == 0) {
|
if (d == 0) {
|
||||||
qn->target_empty_info = NQ_TARGET_IS_EMPTY;
|
qn->target_empty_info = NQ_TARGET_IS_EMPTY;
|
||||||
#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK
|
#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
|
||||||
r = quantifiers_memory_node_info(target);
|
r = quantifiers_memory_node_info(target);
|
||||||
if (r < 0) break;
|
if (r < 0) break;
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
|
@ -3898,7 +3900,7 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)
|
||||||
|
|
||||||
/* set skip map for Boyer-Moor search */
|
/* set skip map for Boyer-Moor search */
|
||||||
static int
|
static int
|
||||||
set_bm_skip(UChar* s, UChar* end, OnigEncoding enc,
|
set_bm_skip(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED,
|
||||||
UChar skip[], int** int_skip)
|
UChar skip[], int** int_skip)
|
||||||
{
|
{
|
||||||
int i, len;
|
int i, len;
|
||||||
|
@ -3987,7 +3989,7 @@ map_position_value(OnigEncoding enc, int i)
|
||||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 1
|
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
if (i < sizeof(ByteValTable)/sizeof(ByteValTable[0])) {
|
if (i < (int )(sizeof(ByteValTable)/sizeof(ByteValTable[0]))) {
|
||||||
if (i == 0 && ONIGENC_MBC_MINLEN(enc) > 1)
|
if (i == 0 && ONIGENC_MBC_MINLEN(enc) > 1)
|
||||||
return 20;
|
return 20;
|
||||||
else
|
else
|
||||||
|
@ -4019,7 +4021,7 @@ distance_value(MinMaxLen* mm)
|
||||||
if (mm->max == ONIG_INFINITE_DISTANCE) return 0;
|
if (mm->max == ONIG_INFINITE_DISTANCE) return 0;
|
||||||
|
|
||||||
d = mm->max - mm->min;
|
d = mm->max - mm->min;
|
||||||
if (d < sizeof(dist_vals)/sizeof(dist_vals[0]))
|
if (d < (int )(sizeof(dist_vals)/sizeof(dist_vals[0])))
|
||||||
/* return dist_vals[d] * 16 / (mm->min + 12); */
|
/* return dist_vals[d] * 16 / (mm->min + 12); */
|
||||||
return (int )dist_vals[d];
|
return (int )dist_vals[d];
|
||||||
else
|
else
|
||||||
|
@ -4212,7 +4214,7 @@ concat_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OnigEncoding enc)
|
||||||
p = add->s;
|
p = add->s;
|
||||||
end = p + add->len;
|
end = p + add->len;
|
||||||
for (i = to->len; p < end; ) {
|
for (i = to->len; p < end; ) {
|
||||||
len = enc_len(enc, p, end);
|
len = enclen(enc, p, end);
|
||||||
if (i + len > OPT_EXACT_MAXLEN) break;
|
if (i + len > OPT_EXACT_MAXLEN) break;
|
||||||
for (j = 0; j < len && p < end; j++)
|
for (j = 0; j < len && p < end; j++)
|
||||||
to->s[i++] = *p++;
|
to->s[i++] = *p++;
|
||||||
|
@ -4227,14 +4229,14 @@ concat_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OnigEncoding enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
concat_opt_exact_info_str(OptExactInfo* to,
|
concat_opt_exact_info_str(OptExactInfo* to, UChar* s, UChar* end,
|
||||||
UChar* s, UChar* end, int raw, OnigEncoding enc)
|
int raw ARG_UNUSED, OnigEncoding enc)
|
||||||
{
|
{
|
||||||
int i, j, len;
|
int i, j, len;
|
||||||
UChar *p;
|
UChar *p;
|
||||||
|
|
||||||
for (i = to->len, p = s; p < end && i < OPT_EXACT_MAXLEN; ) {
|
for (i = to->len, p = s; p < end && i < OPT_EXACT_MAXLEN; ) {
|
||||||
len = enc_len(enc, p, end);
|
len = enclen(enc, p, end);
|
||||||
if (i + len > OPT_EXACT_MAXLEN) break;
|
if (i + len > OPT_EXACT_MAXLEN) break;
|
||||||
for (j = 0; j < len && p < end; j++)
|
for (j = 0; j < len && p < end; j++)
|
||||||
to->s[i++] = *p++;
|
to->s[i++] = *p++;
|
||||||
|
@ -4260,7 +4262,7 @@ alt_merge_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OptEnv* env)
|
||||||
|
|
||||||
for (i = 0; i < to->len && i < add->len; ) {
|
for (i = 0; i < to->len && i < add->len; ) {
|
||||||
if (to->s[i] != add->s[i]) break;
|
if (to->s[i] != add->s[i]) break;
|
||||||
len = enc_len(env->enc, to->s + i, to->s + to->len);
|
len = enclen(env->enc, to->s + i, to->s + to->len);
|
||||||
|
|
||||||
for (j = 1; j < len; j++) {
|
for (j = 1; j < len; j++) {
|
||||||
if (to->s[i+j] != add->s[i+j]) break;
|
if (to->s[i+j] != add->s[i+j]) break;
|
||||||
|
@ -5044,7 +5046,7 @@ static void print_enc_string(FILE* fp, OnigEncoding enc,
|
||||||
fputc((int )code, fp);
|
fputc((int )code, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
p += enc_len(enc, p);
|
p += enclen(enc, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -5634,8 +5636,6 @@ onig_init(void)
|
||||||
extern int
|
extern int
|
||||||
onig_end(void)
|
onig_end(void)
|
||||||
{
|
{
|
||||||
extern int onig_free_shared_cclass_table(void);
|
|
||||||
|
|
||||||
THREAD_ATOMIC_START;
|
THREAD_ATOMIC_START;
|
||||||
|
|
||||||
#ifdef ONIG_DEBUG_STATISTICS
|
#ifdef ONIG_DEBUG_STATISTICS
|
||||||
|
@ -5679,11 +5679,11 @@ onig_is_in_code_range(const UChar* p, OnigCodePoint code)
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
onig_is_code_in_cc_len(int enclen, OnigCodePoint code, CClassNode* cc)
|
onig_is_code_in_cc_len(int elen, OnigCodePoint code, CClassNode* cc)
|
||||||
{
|
{
|
||||||
int found;
|
int found;
|
||||||
|
|
||||||
if (enclen > 1 || (code >= SINGLE_BYTE_SIZE)) {
|
if (elen > 1 || (code >= SINGLE_BYTE_SIZE)) {
|
||||||
if (IS_NULL(cc->mbuf)) {
|
if (IS_NULL(cc->mbuf)) {
|
||||||
found = 0;
|
found = 0;
|
||||||
}
|
}
|
||||||
|
@ -5776,7 +5776,7 @@ OnigOpInfoType OnigOpInfo[] = {
|
||||||
{ OP_BACKREFN_IC, "backrefn-ic", ARG_SPECIAL },
|
{ OP_BACKREFN_IC, "backrefn-ic", ARG_SPECIAL },
|
||||||
{ OP_BACKREF_MULTI, "backref_multi", ARG_SPECIAL },
|
{ OP_BACKREF_MULTI, "backref_multi", ARG_SPECIAL },
|
||||||
{ OP_BACKREF_MULTI_IC, "backref_multi-ic", ARG_SPECIAL },
|
{ OP_BACKREF_MULTI_IC, "backref_multi-ic", ARG_SPECIAL },
|
||||||
{ OP_BACKREF_AT_LEVEL, "backref_at_level", ARG_SPECIAL },
|
{ OP_BACKREF_WITH_LEVEL, "backref_at_level", ARG_SPECIAL },
|
||||||
{ OP_MEMORY_START_PUSH, "mem-start-push", ARG_MEMNUM },
|
{ OP_MEMORY_START_PUSH, "mem-start-push", ARG_MEMNUM },
|
||||||
{ OP_MEMORY_START, "mem-start", ARG_MEMNUM },
|
{ OP_MEMORY_START, "mem-start", ARG_MEMNUM },
|
||||||
{ OP_MEMORY_END_PUSH, "mem-end-push", ARG_MEMNUM },
|
{ OP_MEMORY_END_PUSH, "mem-end-push", ARG_MEMNUM },
|
||||||
|
@ -5968,7 +5968,7 @@ onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OP_EXACT1_IC:
|
case OP_EXACT1_IC:
|
||||||
len = enc_len(enc, bp);
|
len = enclen(enc, bp);
|
||||||
p_string(f, len, bp);
|
p_string(f, len, bp);
|
||||||
bp += len;
|
bp += len;
|
||||||
break;
|
break;
|
||||||
|
@ -6043,7 +6043,7 @@ onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OP_BACKREF_AT_LEVEL:
|
case OP_BACKREF_WITH_LEVEL:
|
||||||
{
|
{
|
||||||
OnigOptionType option;
|
OnigOptionType option;
|
||||||
LengthType level;
|
LengthType level;
|
||||||
|
@ -6182,7 +6182,7 @@ print_indent_tree(FILE* f, Node* node, int indent)
|
||||||
|
|
||||||
case NT_CCLASS:
|
case NT_CCLASS:
|
||||||
fprintf(f, "<cclass:%x>", (int )node);
|
fprintf(f, "<cclass:%x>", (int )node);
|
||||||
if (IS_CCLASS_NOT(NCCLASS(node)) fputs(" not", f);
|
if (IS_NCCLASS_NOT(NCCLASS(node))) fputs(" not", f);
|
||||||
if (NCCLASS(node)->mbuf) {
|
if (NCCLASS(node)->mbuf) {
|
||||||
BBuf* bbuf = NCCLASS(node)->mbuf;
|
BBuf* bbuf = NCCLASS(node)->mbuf;
|
||||||
for (i = 0; i < bbuf->used; i++) {
|
for (i = 0; i < bbuf->used; i++) {
|
||||||
|
|
44
regenc.c
44
regenc.c
|
@ -55,7 +55,7 @@ onigenc_get_right_adjust_char_head(OnigEncoding enc, const UChar* start, const U
|
||||||
{
|
{
|
||||||
UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
|
UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
|
||||||
if (p < s) {
|
if (p < s) {
|
||||||
p += enc_len(enc, p, s);
|
p += enclen(enc, p, s);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ onigenc_get_right_adjust_char_head_with_prev(OnigEncoding enc,
|
||||||
|
|
||||||
if (p < s) {
|
if (p < s) {
|
||||||
if (prev) *prev = (const UChar* )p;
|
if (prev) *prev = (const UChar* )p;
|
||||||
p += enc_len(enc, p, s);
|
p += enclen(enc, p, s);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (prev) *prev = (const UChar* )NULL; /* Sorry */
|
if (prev) *prev = (const UChar* )NULL; /* Sorry */
|
||||||
|
@ -351,7 +351,7 @@ const UChar OnigEncISO_8859_1_ToUpperCaseTable[256] = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
onigenc_set_default_caseconv_table(const UChar* table)
|
onigenc_set_default_caseconv_table(const UChar* table ARG_UNUSED)
|
||||||
{
|
{
|
||||||
/* nothing */
|
/* nothing */
|
||||||
/* obsoleted. */
|
/* obsoleted. */
|
||||||
|
@ -393,15 +393,16 @@ const OnigPairCaseFoldCodes OnigAsciiLowerMap[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag,
|
onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,
|
||||||
OnigApplyAllCaseFoldFunc f, void* arg,
|
OnigApplyAllCaseFoldFunc f, void* arg,
|
||||||
OnigEncoding enc)
|
OnigEncoding enc)
|
||||||
{
|
{
|
||||||
OnigCodePoint code;
|
OnigCodePoint code;
|
||||||
int i, r;
|
int i, r;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(OnigAsciiLowerMap)/sizeof(OnigPairCaseFoldCodes)
|
for (i = 0;
|
||||||
; i++) {
|
i < (int )(sizeof(OnigAsciiLowerMap)/sizeof(OnigPairCaseFoldCodes));
|
||||||
|
i++) {
|
||||||
code = OnigAsciiLowerMap[i].to;
|
code = OnigAsciiLowerMap[i].to;
|
||||||
r = (*f)(OnigAsciiLowerMap[i].from, &code, 1, arg);
|
r = (*f)(OnigAsciiLowerMap[i].from, &code, 1, arg);
|
||||||
if (r != 0) return r;
|
if (r != 0) return r;
|
||||||
|
@ -435,8 +436,8 @@ onigenc_ascii_get_case_fold_codes_by_str(OnigCaseFoldType flag,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
ss_apply_all_case_fold(OnigCaseFoldType flag,
|
ss_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,
|
||||||
OnigApplyAllCaseFoldFunc f, void* arg)
|
OnigApplyAllCaseFoldFunc f, void* arg)
|
||||||
{
|
{
|
||||||
static OnigCodePoint ss[] = { 0x73, 0x73 };
|
static OnigCodePoint ss[] = { 0x73, 0x73 };
|
||||||
|
@ -475,7 +476,7 @@ onigenc_apply_all_case_fold_with_map(int map_size,
|
||||||
extern int
|
extern int
|
||||||
onigenc_get_case_fold_codes_by_str_with_map(int map_size,
|
onigenc_get_case_fold_codes_by_str_with_map(int map_size,
|
||||||
const OnigPairCaseFoldCodes map[],
|
const OnigPairCaseFoldCodes map[],
|
||||||
int ess_tsett_flag, OnigCaseFoldType flag,
|
int ess_tsett_flag, OnigCaseFoldType flag ARG_UNUSED,
|
||||||
const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
|
const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
|
||||||
{
|
{
|
||||||
if (0x41 <= *p && *p <= 0x5a) {
|
if (0x41 <= *p && *p <= 0x5a) {
|
||||||
|
@ -555,7 +556,7 @@ onigenc_get_case_fold_codes_by_str_with_map(int map_size,
|
||||||
|
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
onigenc_not_support_get_ctype_code_range(int ctype,
|
onigenc_not_support_get_ctype_code_range(OnigCtype ctype,
|
||||||
OnigCodePoint* sb_out, const OnigCodePoint* ranges[],
|
OnigCodePoint* sb_out, const OnigCodePoint* ranges[],
|
||||||
OnigEncoding enc)
|
OnigEncoding enc)
|
||||||
{
|
{
|
||||||
|
@ -656,7 +657,7 @@ onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end)
|
||||||
int c, i, len;
|
int c, i, len;
|
||||||
OnigCodePoint n;
|
OnigCodePoint n;
|
||||||
|
|
||||||
len = enc_len(enc, p, end);
|
len = enclen(enc, p, end);
|
||||||
n = (OnigCodePoint )(*p++);
|
n = (OnigCodePoint )(*p++);
|
||||||
if (len == 1) return n;
|
if (len == 1) return n;
|
||||||
|
|
||||||
|
@ -669,8 +670,9 @@ onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end)
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag,
|
onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag ARG_UNUSED,
|
||||||
const UChar** pp, const UChar* end, UChar* lower)
|
const UChar** pp, const UChar* end ARG_UNUSED,
|
||||||
|
UChar* lower)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
const UChar *p = *pp;
|
const UChar *p = *pp;
|
||||||
|
@ -683,7 +685,7 @@ onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag,
|
||||||
else {
|
else {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
len = enc_len(enc, p, end);
|
len = enclen(enc, p, end);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
*lower++ = *p++;
|
*lower++ = *p++;
|
||||||
}
|
}
|
||||||
|
@ -704,7 +706,7 @@ onigenc_mbn_is_mbc_ambiguous(OnigEncoding enc, OnigCaseFoldType flag,
|
||||||
return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
|
return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*pp) += enc_len(enc, p);
|
(*pp) += enclen(enc, p);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -736,8 +738,8 @@ onigenc_mb2_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
|
||||||
*p++ = (UChar )(code & 0xff);
|
*p++ = (UChar )(code & 0xff);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if (enc_len(enc, buf, p) != (p - buf))
|
if (enclen(enc, buf, p) != (p - buf))
|
||||||
return ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE;
|
return ONIGERR_INVALID_CODE_POINT_VALUE;
|
||||||
#endif
|
#endif
|
||||||
return p - buf;
|
return p - buf;
|
||||||
}
|
}
|
||||||
|
@ -759,8 +761,8 @@ onigenc_mb4_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
|
||||||
*p++ = (UChar )(code & 0xff);
|
*p++ = (UChar )(code & 0xff);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if (enc_len(enc, buf, p) != (p - buf))
|
if (enclen(enc, buf, p) != (p - buf))
|
||||||
return ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE;
|
return ONIGERR_INVALID_CODE_POINT_VALUE;
|
||||||
#endif
|
#endif
|
||||||
return p - buf;
|
return p - buf;
|
||||||
}
|
}
|
||||||
|
@ -843,7 +845,7 @@ onigenc_with_ascii_strncmp(OnigEncoding enc, const UChar* p, const UChar* end,
|
||||||
if (x) return x;
|
if (x) return x;
|
||||||
|
|
||||||
sascii++;
|
sascii++;
|
||||||
p += enc_len(enc, p, end);
|
p += enclen(enc, p, end);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -900,7 +902,7 @@ onigenc_property_list_add_property(UChar* name, const OnigCodePoint* prop,
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
onigenc_property_list_init(int (*f)())
|
onigenc_property_list_init(int (*f)(void))
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
|
18
regenc.h
18
regenc.h
|
@ -57,17 +57,21 @@ typedef struct {
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* error codes */
|
#ifndef ARG_UNUSED
|
||||||
#define ONIGENC_ERR_MEMORY -5
|
#if defined(__GNUC__)
|
||||||
#define ONIGENC_ERR_TYPE_BUG -6
|
# define ARG_UNUSED __attribute__ ((unused))
|
||||||
#define ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE -400
|
#else
|
||||||
#define ONIGENC_ERR_TOO_BIG_WIDE_CHAR_VALUE -401
|
# define ARG_UNUSED
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ONIG_IS_NULL(p) (((void*)(p)) == (void*)0)
|
#define ONIG_IS_NULL(p) (((void*)(p)) == (void*)0)
|
||||||
#define ONIG_IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
|
#define ONIG_IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
|
||||||
#define ONIG_CHECK_NULL_RETURN(p) if (ONIG_IS_NULL(p)) return NULL
|
#define ONIG_CHECK_NULL_RETURN(p) if (ONIG_IS_NULL(p)) return NULL
|
||||||
#define ONIG_CHECK_NULL_RETURN_VAL(p,val) if (ONIG_IS_NULL(p)) return (val)
|
#define ONIG_CHECK_NULL_RETURN_VAL(p,val) if (ONIG_IS_NULL(p)) return (val)
|
||||||
|
|
||||||
|
#define enclen(enc,p,e) ONIGENC_MBC_ENC_LEN(enc,p,e)
|
||||||
|
|
||||||
/* character types bit flag */
|
/* character types bit flag */
|
||||||
#define BIT_CTYPE_NEWLINE (1<< ONIGENC_CTYPE_NEWLINE)
|
#define BIT_CTYPE_NEWLINE (1<< ONIGENC_CTYPE_NEWLINE)
|
||||||
#define BIT_CTYPE_ALPHA (1<< ONIGENC_CTYPE_ALPHA)
|
#define BIT_CTYPE_ALPHA (1<< ONIGENC_CTYPE_ALPHA)
|
||||||
|
@ -111,7 +115,7 @@ ONIG_EXTERN int onigenc_ascii_apply_all_case_fold P_((OnigCaseFoldType flag, Oni
|
||||||
ONIG_EXTERN int onigenc_ascii_get_case_fold_codes_by_str P_((OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[], OnigEncoding enc));
|
ONIG_EXTERN int onigenc_ascii_get_case_fold_codes_by_str P_((OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[], OnigEncoding enc));
|
||||||
ONIG_EXTERN int onigenc_apply_all_case_fold_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));
|
ONIG_EXTERN int onigenc_apply_all_case_fold_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));
|
||||||
ONIG_EXTERN int onigenc_get_case_fold_codes_by_str_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
|
ONIG_EXTERN int onigenc_get_case_fold_codes_by_str_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
|
||||||
ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((int ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], OnigEncoding enc));
|
ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], OnigEncoding enc));
|
||||||
ONIG_EXTERN int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end, OnigEncoding enc));
|
ONIG_EXTERN int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end, OnigEncoding enc));
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,7 +145,7 @@ ONIG_EXTERN int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint co
|
||||||
|
|
||||||
/* in enc/unicode.c */
|
/* in enc/unicode.c */
|
||||||
ONIG_EXTERN int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype, OnigEncoding enc));
|
ONIG_EXTERN int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype, OnigEncoding enc));
|
||||||
ONIG_EXTERN int onigenc_utf16_32_get_ctype_code_range P_((int ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[]));
|
ONIG_EXTERN int onigenc_utf16_32_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[]));
|
||||||
ONIG_EXTERN int onigenc_unicode_ctype_code_range P_((int ctype, const OnigCodePoint* ranges[]));
|
ONIG_EXTERN int onigenc_unicode_ctype_code_range P_((int ctype, const OnigCodePoint* ranges[]));
|
||||||
ONIG_EXTERN int onigenc_unicode_get_case_fold_codes_by_str P_((OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
|
ONIG_EXTERN int onigenc_unicode_get_case_fold_codes_by_str P_((OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
|
||||||
ONIG_EXTERN int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold));
|
ONIG_EXTERN int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold));
|
||||||
|
|
38
regerror.c
38
regerror.c
|
@ -142,8 +142,8 @@ onig_error_code_to_format(int code)
|
||||||
p = "too big wide-char value"; break;
|
p = "too big wide-char value"; break;
|
||||||
case ONIGERR_TOO_LONG_WIDE_CHAR_VALUE:
|
case ONIGERR_TOO_LONG_WIDE_CHAR_VALUE:
|
||||||
p = "too long wide-char value"; break;
|
p = "too long wide-char value"; break;
|
||||||
case ONIGERR_INVALID_WIDE_CHAR_VALUE:
|
case ONIGERR_INVALID_CODE_POINT_VALUE:
|
||||||
p = "invalid wide-char value"; break;
|
p = "invalid code point value"; break;
|
||||||
case ONIGERR_EMPTY_GROUP_NAME:
|
case ONIGERR_EMPTY_GROUP_NAME:
|
||||||
p = "group name is empty"; break;
|
p = "group name is empty"; break;
|
||||||
case ONIGERR_INVALID_GROUP_NAME:
|
case ONIGERR_INVALID_GROUP_NAME:
|
||||||
|
@ -182,6 +182,15 @@ onig_error_code_to_format(int code)
|
||||||
return (UChar* )p;
|
return (UChar* )p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sprint_byte(char* s, unsigned int v)
|
||||||
|
{
|
||||||
|
sprintf(s, "%02x", (v & 0377));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sprint_byte_with_x(char* s, unsigned int v)
|
||||||
|
{
|
||||||
|
sprintf(s, "\\x%02x", (v & 0377));
|
||||||
|
}
|
||||||
|
|
||||||
static int to_ascii(OnigEncoding enc, UChar *s, UChar *end,
|
static int to_ascii(OnigEncoding enc, UChar *s, UChar *end,
|
||||||
UChar buf[], int buf_size, int *is_over)
|
UChar buf[], int buf_size, int *is_over)
|
||||||
|
@ -196,10 +205,17 @@ static int to_ascii(OnigEncoding enc, UChar *s, UChar *end,
|
||||||
while (p < end) {
|
while (p < end) {
|
||||||
code = ONIGENC_MBC_TO_CODE(enc, p, end);
|
code = ONIGENC_MBC_TO_CODE(enc, p, end);
|
||||||
if (code >= 0x80) {
|
if (code >= 0x80) {
|
||||||
if (len + 5 <= buf_size) {
|
if (code > 0xffff && len + 10 <= buf_size) {
|
||||||
sprintf((char* )(&(buf[len])), "\\x%02X",
|
sprint_byte_with_x((char*)(&(buf[len])), (unsigned int)(code >> 24));
|
||||||
(unsigned int )(code & 0377));
|
sprint_byte((char*)(&(buf[len+4])), (unsigned int)(code >> 16));
|
||||||
len += 5;
|
sprint_byte((char*)(&(buf[len+6])), (unsigned int)(code >> 8));
|
||||||
|
sprint_byte((char*)(&(buf[len+8])), (unsigned int)code);
|
||||||
|
len += 10;
|
||||||
|
}
|
||||||
|
else if (len + 6 <= buf_size) {
|
||||||
|
sprint_byte_with_x((char*)(&(buf[len])), (unsigned int)(code >> 8));
|
||||||
|
sprint_byte((char*)(&(buf[len+4])), (unsigned int)code);
|
||||||
|
len += 6;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
break;
|
break;
|
||||||
|
@ -209,7 +225,7 @@ static int to_ascii(OnigEncoding enc, UChar *s, UChar *end,
|
||||||
buf[len++] = (UChar )code;
|
buf[len++] = (UChar )code;
|
||||||
}
|
}
|
||||||
|
|
||||||
p += enc_len(enc, p, end);
|
p += enclen(enc, p, end);
|
||||||
if (len >= buf_size) break;
|
if (len >= buf_size) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +346,7 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)
|
||||||
while (p < pat_end) {
|
while (p < pat_end) {
|
||||||
if (*p == '\\') {
|
if (*p == '\\') {
|
||||||
*s++ = *p++;
|
*s++ = *p++;
|
||||||
len = enc_len(enc, p, pat_end);
|
len = enclen(enc, p, pat_end);
|
||||||
while (len-- > 0) *s++ = *p++;
|
while (len-- > 0) *s++ = *p++;
|
||||||
}
|
}
|
||||||
else if (*p == '/') {
|
else if (*p == '/') {
|
||||||
|
@ -338,7 +354,7 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)
|
||||||
*s++ = *p++;
|
*s++ = *p++;
|
||||||
}
|
}
|
||||||
else if (ONIGENC_IS_MBC_HEAD(enc, p, pat_end)) {
|
else if (ONIGENC_IS_MBC_HEAD(enc, p, pat_end)) {
|
||||||
len = enc_len(enc, p, pat_end);
|
len = enclen(enc, p, pat_end);
|
||||||
if (ONIGENC_MBC_MINLEN(enc) == 1) {
|
if (ONIGENC_MBC_MINLEN(enc) == 1) {
|
||||||
while (len-- > 0) *s++ = *p++;
|
while (len-- > 0) *s++ = *p++;
|
||||||
}
|
}
|
||||||
|
@ -346,7 +362,7 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)
|
||||||
int blen;
|
int blen;
|
||||||
|
|
||||||
while (len-- > 0) {
|
while (len-- > 0) {
|
||||||
sprintf((char* )bs, "\\x%02X", *p++ & 0377);
|
sprint_byte_with_x((char* )bs, (unsigned int )(*p++));
|
||||||
blen = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
|
blen = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
|
||||||
bp = bs;
|
bp = bs;
|
||||||
while (blen-- > 0) *s++ = *bp++;
|
while (blen-- > 0) *s++ = *bp++;
|
||||||
|
@ -355,7 +371,7 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)
|
||||||
}
|
}
|
||||||
else if (!ONIGENC_IS_CODE_PRINT(enc, *p) &&
|
else if (!ONIGENC_IS_CODE_PRINT(enc, *p) &&
|
||||||
!ONIGENC_IS_CODE_SPACE(enc, *p)) {
|
!ONIGENC_IS_CODE_SPACE(enc, *p)) {
|
||||||
sprintf((char* )bs, "\\x%02X", *p++ & 0377);
|
sprint_byte_with_x((char* )bs, (unsigned int )(*p++));
|
||||||
len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
|
len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
|
||||||
bp = bs;
|
bp = bs;
|
||||||
while (len-- > 0) *s++ = *bp++;
|
while (len-- > 0) *s++ = *bp++;
|
||||||
|
|
121
regexec.c
121
regexec.c
|
@ -29,10 +29,12 @@
|
||||||
|
|
||||||
#include "regint.h"
|
#include "regint.h"
|
||||||
|
|
||||||
|
#define USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
|
||||||
|
|
||||||
#ifdef USE_CRNL_AS_LINE_TERMINATOR
|
#ifdef USE_CRNL_AS_LINE_TERMINATOR
|
||||||
#define ONIGENC_IS_MBC_CRNL(enc,p,end) \
|
#define ONIGENC_IS_MBC_CRNL(enc,p,end) \
|
||||||
(ONIGENC_MBC_TO_CODE(enc,p,end) == 13 && \
|
(ONIGENC_MBC_TO_CODE(enc,p,end) == 13 && \
|
||||||
ONIGENC_IS_MBC_NEWLINE(enc,(p+enc_len(enc,p)),end))
|
ONIGENC_IS_MBC_NEWLINE(enc,(p+enclen(enc,p)),end))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_CAPTURE_HISTORY
|
#ifdef USE_CAPTURE_HISTORY
|
||||||
|
@ -196,7 +198,7 @@ onig_region_resize(OnigRegion* region, int n)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int
|
static int
|
||||||
onig_region_resize_clear(OnigRegion* region, int n)
|
onig_region_resize_clear(OnigRegion* region, int n)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
@ -1019,7 +1021,7 @@ static int string_cmp_ic(OnigEncoding enc, int case_fold_flag,
|
||||||
#define IS_EMPTY_STR (str == end)
|
#define IS_EMPTY_STR (str == end)
|
||||||
#define ON_STR_BEGIN(s) ((s) == str)
|
#define ON_STR_BEGIN(s) ((s) == str)
|
||||||
#define ON_STR_END(s) ((s) == end)
|
#define ON_STR_END(s) ((s) == end)
|
||||||
#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
|
#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
|
||||||
#define DATA_ENSURE_CHECK1 (s < right_range)
|
#define DATA_ENSURE_CHECK1 (s < right_range)
|
||||||
#define DATA_ENSURE_CHECK(n) (s + (n) <= right_range)
|
#define DATA_ENSURE_CHECK(n) (s + (n) <= right_range)
|
||||||
#define DATA_ENSURE(n) if (s + (n) > right_range) goto fail
|
#define DATA_ENSURE(n) if (s + (n) > right_range) goto fail
|
||||||
|
@ -1027,7 +1029,7 @@ static int string_cmp_ic(OnigEncoding enc, int case_fold_flag,
|
||||||
#define DATA_ENSURE_CHECK1 (s < end)
|
#define DATA_ENSURE_CHECK1 (s < end)
|
||||||
#define DATA_ENSURE_CHECK(n) (s + (n) <= end)
|
#define DATA_ENSURE_CHECK(n) (s + (n) <= end)
|
||||||
#define DATA_ENSURE(n) if (s + (n) > end) goto fail
|
#define DATA_ENSURE(n) if (s + (n) > end) goto fail
|
||||||
#endif /* USE_MATCH_RANGE_IS_COMPLETE_RANGE */
|
#endif /* USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE */
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_CAPTURE_HISTORY
|
#ifdef USE_CAPTURE_HISTORY
|
||||||
|
@ -1072,7 +1074,7 @@ make_capture_history_tree(OnigCaptureTreeNode* node, OnigStackType** kp,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_BACKREF_AT_LEVEL
|
#ifdef USE_BACKREF_WITH_LEVEL
|
||||||
static int mem_is_in_memp(int mem, int num, UChar* memp)
|
static int mem_is_in_memp(int mem, int num, UChar* memp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -1140,7 +1142,7 @@ static int backref_match_at_nested_level(regex_t* reg
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* USE_BACKREF_AT_LEVEL */
|
#endif /* USE_BACKREF_WITH_LEVEL */
|
||||||
|
|
||||||
|
|
||||||
#ifdef ONIG_DEBUG_STATISTICS
|
#ifdef ONIG_DEBUG_STATISTICS
|
||||||
|
@ -1234,7 +1236,7 @@ typedef struct {
|
||||||
/* if sstart == str then set sprev to NULL. */
|
/* if sstart == str then set sprev to NULL. */
|
||||||
static int
|
static int
|
||||||
match_at(regex_t* reg, const UChar* str, const UChar* end,
|
match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
|
#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
|
||||||
const UChar* right_range,
|
const UChar* right_range,
|
||||||
#endif
|
#endif
|
||||||
const UChar* sstart, UChar* sprev, OnigMatchArg* msa)
|
const UChar* sstart, UChar* sprev, OnigMatchArg* msa)
|
||||||
|
@ -1296,7 +1298,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
fprintf(stderr, "%4d> \"", (int )(s - str));
|
fprintf(stderr, "%4d> \"", (int )(s - str));
|
||||||
bp = buf;
|
bp = buf;
|
||||||
for (i = 0, q = s; i < 7 && q < end; i++) {
|
for (i = 0, q = s; i < 7 && q < end; i++) {
|
||||||
len = enc_len(encode, q);
|
len = enclen(encode, q);
|
||||||
while (len-- > 0) *bp++ = *q++;
|
while (len-- > 0) *bp++ = *q++;
|
||||||
}
|
}
|
||||||
if (q < end) { xmemcpy(bp, "...\"", 4); bp += 4; }
|
if (q < end) { xmemcpy(bp, "...\"", 4); bp += 4; }
|
||||||
|
@ -1328,7 +1330,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
best_len = n;
|
best_len = n;
|
||||||
region = msa->region;
|
region = msa->region;
|
||||||
if (region) {
|
if (region) {
|
||||||
#ifdef USE_POSIX_REGION_OPTION
|
#ifdef USE_POSIX_API_REGION_OPTION
|
||||||
if (IS_POSIX_REGION(msa->options)) {
|
if (IS_POSIX_REGION(msa->options)) {
|
||||||
posix_regmatch_t* rmt = (posix_regmatch_t* )region;
|
posix_regmatch_t* rmt = (posix_regmatch_t* )region;
|
||||||
|
|
||||||
|
@ -1351,7 +1353,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#endif /* USE_POSIX_REGION_OPTION */
|
#endif /* USE_POSIX_API_REGION_OPTION */
|
||||||
region->beg[0] = sstart - str;
|
region->beg[0] = sstart - str;
|
||||||
region->end[0] = s - str;
|
region->end[0] = s - str;
|
||||||
for (i = 1; i <= num_mem; i++) {
|
for (i = 1; i <= num_mem; i++) {
|
||||||
|
@ -1397,7 +1399,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* USE_CAPTURE_HISTORY */
|
#endif /* USE_CAPTURE_HISTORY */
|
||||||
#ifdef USE_POSIX_REGION_OPTION
|
#ifdef USE_POSIX_API_REGION_OPTION
|
||||||
} /* else IS_POSIX_REGION() */
|
} /* else IS_POSIX_REGION() */
|
||||||
#endif
|
#endif
|
||||||
} /* if (region) */
|
} /* if (region) */
|
||||||
|
@ -1642,7 +1644,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
DATA_ENSURE(1);
|
DATA_ENSURE(1);
|
||||||
if (BITSET_AT(((BitSetRef )p), *s) == 0) goto fail;
|
if (BITSET_AT(((BitSetRef )p), *s) == 0) goto fail;
|
||||||
p += SIZE_BITSET;
|
p += SIZE_BITSET;
|
||||||
s += enc_len(encode, s, end); /* OP_CCLASS can match mb-code. \D, \S */
|
s += enclen(encode, s, end); /* OP_CCLASS can match mb-code. \D, \S */
|
||||||
MOP_OUT;
|
MOP_OUT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1657,7 +1659,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
int mb_len;
|
int mb_len;
|
||||||
|
|
||||||
DATA_ENSURE(1);
|
DATA_ENSURE(1);
|
||||||
mb_len = enc_len(encode, s, end);
|
mb_len = enclen(encode, s, end);
|
||||||
DATA_ENSURE(mb_len);
|
DATA_ENSURE(mb_len);
|
||||||
ss = s;
|
ss = s;
|
||||||
s += mb_len;
|
s += mb_len;
|
||||||
|
@ -1697,7 +1699,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
DATA_ENSURE(1);
|
DATA_ENSURE(1);
|
||||||
if (BITSET_AT(((BitSetRef )p), *s) != 0) goto fail;
|
if (BITSET_AT(((BitSetRef )p), *s) != 0) goto fail;
|
||||||
p += SIZE_BITSET;
|
p += SIZE_BITSET;
|
||||||
s += enc_len(encode, s, end);
|
s += enclen(encode, s, end);
|
||||||
MOP_OUT;
|
MOP_OUT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1715,7 +1717,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
{
|
{
|
||||||
OnigCodePoint code;
|
OnigCodePoint code;
|
||||||
UChar *ss;
|
UChar *ss;
|
||||||
int mb_len = enc_len(encode, s, end);
|
int mb_len = enclen(encode, s, end);
|
||||||
|
|
||||||
if (! DATA_ENSURE_CHECK(mb_len)) {
|
if (! DATA_ENSURE_CHECK(mb_len)) {
|
||||||
DATA_ENSURE(1);
|
DATA_ENSURE(1);
|
||||||
|
@ -1769,7 +1771,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
|
|
||||||
DATA_ENSURE(1);
|
DATA_ENSURE(1);
|
||||||
GET_POINTER_INC(node, p);
|
GET_POINTER_INC(node, p);
|
||||||
mb_len = enc_len(encode, s, end);
|
mb_len = enclen(encode, s, end);
|
||||||
ss = s;
|
ss = s;
|
||||||
s += mb_len;
|
s += mb_len;
|
||||||
DATA_ENSURE(0);
|
DATA_ENSURE(0);
|
||||||
|
@ -1781,7 +1783,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
|
|
||||||
case OP_ANYCHAR: MOP_IN(OP_ANYCHAR);
|
case OP_ANYCHAR: MOP_IN(OP_ANYCHAR);
|
||||||
DATA_ENSURE(1);
|
DATA_ENSURE(1);
|
||||||
n = enc_len(encode, s, end);
|
n = enclen(encode, s, end);
|
||||||
DATA_ENSURE(n);
|
DATA_ENSURE(n);
|
||||||
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
|
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
|
||||||
s += n;
|
s += n;
|
||||||
|
@ -1790,7 +1792,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
|
|
||||||
case OP_ANYCHAR_ML: MOP_IN(OP_ANYCHAR_ML);
|
case OP_ANYCHAR_ML: MOP_IN(OP_ANYCHAR_ML);
|
||||||
DATA_ENSURE(1);
|
DATA_ENSURE(1);
|
||||||
n = enc_len(encode, s, end);
|
n = enclen(encode, s, end);
|
||||||
DATA_ENSURE(n);
|
DATA_ENSURE(n);
|
||||||
s += n;
|
s += n;
|
||||||
MOP_OUT;
|
MOP_OUT;
|
||||||
|
@ -1799,7 +1801,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
case OP_ANYCHAR_STAR: MOP_IN(OP_ANYCHAR_STAR);
|
case OP_ANYCHAR_STAR: MOP_IN(OP_ANYCHAR_STAR);
|
||||||
while (DATA_ENSURE_CHECK1) {
|
while (DATA_ENSURE_CHECK1) {
|
||||||
STACK_PUSH_ALT(p, s, sprev);
|
STACK_PUSH_ALT(p, s, sprev);
|
||||||
n = enc_len(encode, s, end);
|
n = enclen(encode, s, end);
|
||||||
DATA_ENSURE(n);
|
DATA_ENSURE(n);
|
||||||
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
|
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
|
||||||
sprev = s;
|
sprev = s;
|
||||||
|
@ -1811,7 +1813,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
case OP_ANYCHAR_ML_STAR: MOP_IN(OP_ANYCHAR_ML_STAR);
|
case OP_ANYCHAR_ML_STAR: MOP_IN(OP_ANYCHAR_ML_STAR);
|
||||||
while (DATA_ENSURE_CHECK1) {
|
while (DATA_ENSURE_CHECK1) {
|
||||||
STACK_PUSH_ALT(p, s, sprev);
|
STACK_PUSH_ALT(p, s, sprev);
|
||||||
n = enc_len(encode, s, end);
|
n = enclen(encode, s, end);
|
||||||
if (n > 1) {
|
if (n > 1) {
|
||||||
DATA_ENSURE(n);
|
DATA_ENSURE(n);
|
||||||
sprev = s;
|
sprev = s;
|
||||||
|
@ -1830,7 +1832,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
if (*p == *s) {
|
if (*p == *s) {
|
||||||
STACK_PUSH_ALT(p + 1, s, sprev);
|
STACK_PUSH_ALT(p + 1, s, sprev);
|
||||||
}
|
}
|
||||||
n = enc_len(encode, s, end);
|
n = enclen(encode, s, end);
|
||||||
DATA_ENSURE(n);
|
DATA_ENSURE(n);
|
||||||
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
|
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
|
||||||
sprev = s;
|
sprev = s;
|
||||||
|
@ -1845,7 +1847,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
if (*p == *s) {
|
if (*p == *s) {
|
||||||
STACK_PUSH_ALT(p + 1, s, sprev);
|
STACK_PUSH_ALT(p + 1, s, sprev);
|
||||||
}
|
}
|
||||||
n = enc_len(encode, s, end);
|
n = enclen(encode, s, end);
|
||||||
if (n > 1) {
|
if (n > 1) {
|
||||||
DATA_ENSURE(n);
|
DATA_ENSURE(n);
|
||||||
sprev = s;
|
sprev = s;
|
||||||
|
@ -1868,7 +1870,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
if (scv) goto fail;
|
if (scv) goto fail;
|
||||||
|
|
||||||
STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem);
|
STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem);
|
||||||
n = enc_len(encode, s);
|
n = enclen(encode, s);
|
||||||
DATA_ENSURE(n);
|
DATA_ENSURE(n);
|
||||||
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
|
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
|
||||||
sprev = s;
|
sprev = s;
|
||||||
|
@ -1886,7 +1888,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
if (scv) goto fail;
|
if (scv) goto fail;
|
||||||
|
|
||||||
STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem);
|
STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem);
|
||||||
n = enc_len(encode, s);
|
n = enclen(encode, s);
|
||||||
if (n > 1) {
|
if (n > 1) {
|
||||||
DATA_ENSURE(n);
|
DATA_ENSURE(n);
|
||||||
sprev = s;
|
sprev = s;
|
||||||
|
@ -1906,7 +1908,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
if (! ONIGENC_IS_MBC_WORD(encode, s, end))
|
if (! ONIGENC_IS_MBC_WORD(encode, s, end))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
s += enc_len(encode, s, end);
|
s += enclen(encode, s, end);
|
||||||
MOP_OUT;
|
MOP_OUT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1915,7 +1917,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
if (ONIGENC_IS_MBC_WORD(encode, s, end))
|
if (ONIGENC_IS_MBC_WORD(encode, s, end))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
s += enc_len(encode, s, end);
|
s += enclen(encode, s, end);
|
||||||
MOP_OUT;
|
MOP_OUT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2043,14 +2045,14 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (ONIGENC_IS_MBC_NEWLINE(encode, s, end) &&
|
else if (ONIGENC_IS_MBC_NEWLINE(encode, s, end) &&
|
||||||
ON_STR_END(s + enc_len(encode, s, end))) {
|
ON_STR_END(s + enclen(encode, s, end))) {
|
||||||
MOP_OUT;
|
MOP_OUT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#ifdef USE_CRNL_AS_LINE_TERMINATOR
|
#ifdef USE_CRNL_AS_LINE_TERMINATOR
|
||||||
else if (ONIGENC_IS_MBC_CRNL(encode, s, end)) {
|
else if (ONIGENC_IS_MBC_CRNL(encode, s, end)) {
|
||||||
UChar* ss = s + enc_len(encode, s);
|
UChar* ss = s + enclen(encode, s);
|
||||||
ss += enc_len(encode, ss);
|
ss += enclen(encode, ss);
|
||||||
if (ON_STR_END(ss)) {
|
if (ON_STR_END(ss)) {
|
||||||
MOP_OUT;
|
MOP_OUT;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2157,7 +2159,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
DATA_ENSURE(n);
|
DATA_ENSURE(n);
|
||||||
sprev = s;
|
sprev = s;
|
||||||
STRING_CMP(pstart, s, n);
|
STRING_CMP(pstart, s, n);
|
||||||
while (sprev + (len = enc_len(encode, sprev, end)) < s)
|
while (sprev + (len = enclen(encode, sprev, end)) < s)
|
||||||
sprev += len;
|
sprev += len;
|
||||||
|
|
||||||
MOP_OUT;
|
MOP_OUT;
|
||||||
|
@ -2189,7 +2191,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
DATA_ENSURE(n);
|
DATA_ENSURE(n);
|
||||||
sprev = s;
|
sprev = s;
|
||||||
STRING_CMP_IC(case_fold_flag, pstart, &s, n);
|
STRING_CMP_IC(case_fold_flag, pstart, &s, n);
|
||||||
while (sprev + (len = enc_len(encode, sprev, end)) < s)
|
while (sprev + (len = enclen(encode, sprev, end)) < s)
|
||||||
sprev += len;
|
sprev += len;
|
||||||
|
|
||||||
MOP_OUT;
|
MOP_OUT;
|
||||||
|
@ -2224,7 +2226,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
STRING_CMP_VALUE(pstart, swork, n, is_fail);
|
STRING_CMP_VALUE(pstart, swork, n, is_fail);
|
||||||
if (is_fail) continue;
|
if (is_fail) continue;
|
||||||
s = swork;
|
s = swork;
|
||||||
while (sprev + (len = enc_len(encode, sprev, end)) < s)
|
while (sprev + (len = enclen(encode, sprev, end)) < s)
|
||||||
sprev += len;
|
sprev += len;
|
||||||
|
|
||||||
p += (SIZE_MEMNUM * (tlen - i - 1));
|
p += (SIZE_MEMNUM * (tlen - i - 1));
|
||||||
|
@ -2263,7 +2265,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
STRING_CMP_VALUE_IC(case_fold_flag, pstart, &swork, n, is_fail);
|
STRING_CMP_VALUE_IC(case_fold_flag, pstart, &swork, n, is_fail);
|
||||||
if (is_fail) continue;
|
if (is_fail) continue;
|
||||||
s = swork;
|
s = swork;
|
||||||
while (sprev + (len = enc_len(encode, sprev, end)) < s)
|
while (sprev + (len = enclen(encode, sprev, end)) < s)
|
||||||
sprev += len;
|
sprev += len;
|
||||||
|
|
||||||
p += (SIZE_MEMNUM * (tlen - i - 1));
|
p += (SIZE_MEMNUM * (tlen - i - 1));
|
||||||
|
@ -2275,8 +2277,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef USE_BACKREF_AT_LEVEL
|
#ifdef USE_BACKREF_WITH_LEVEL
|
||||||
case OP_BACKREF_AT_LEVEL:
|
case OP_BACKREF_WITH_LEVEL:
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
OnigOptionType ic;
|
OnigOptionType ic;
|
||||||
|
@ -2289,7 +2291,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
sprev = s;
|
sprev = s;
|
||||||
if (backref_match_at_nested_level(reg, stk, stk_base, ic
|
if (backref_match_at_nested_level(reg, stk, stk_base, ic
|
||||||
, case_fold_flag, (int )level, (int )tlen, p, &s, end)) {
|
, case_fold_flag, (int )level, (int )tlen, p, &s, end)) {
|
||||||
while (sprev + (len = enc_len(encode, sprev, end)) < s)
|
while (sprev + (len = enclen(encode, sprev, end)) < s)
|
||||||
sprev += len;
|
sprev += len;
|
||||||
|
|
||||||
p += (SIZE_MEMNUM * tlen);
|
p += (SIZE_MEMNUM * tlen);
|
||||||
|
@ -2361,7 +2363,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK
|
#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
|
||||||
case OP_NULL_CHECK_END_MEMST: MOP_IN(OP_NULL_CHECK_END_MEMST);
|
case OP_NULL_CHECK_END_MEMST: MOP_IN(OP_NULL_CHECK_END_MEMST);
|
||||||
{
|
{
|
||||||
int isnull;
|
int isnull;
|
||||||
|
@ -2389,7 +2391,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
int isnull;
|
int isnull;
|
||||||
|
|
||||||
GET_MEMNUM_INC(mem, p); /* mem: null check id */
|
GET_MEMNUM_INC(mem, p); /* mem: null check id */
|
||||||
#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK
|
#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
|
||||||
STACK_NULL_CHECK_MEMST_REC(isnull, mem, s, reg);
|
STACK_NULL_CHECK_MEMST_REC(isnull, mem, s, reg);
|
||||||
#else
|
#else
|
||||||
STACK_NULL_CHECK_REC(isnull, mem, s);
|
STACK_NULL_CHECK_REC(isnull, mem, s);
|
||||||
|
@ -2760,7 +2762,7 @@ slow_search(OnigEncoding enc, UChar* target, UChar* target_end,
|
||||||
if (t == target_end)
|
if (t == target_end)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
s += enc_len(enc, s, end);
|
s += enclen(enc, s, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UChar* )NULL;
|
return (UChar* )NULL;
|
||||||
|
@ -2805,7 +2807,7 @@ slow_search_ic(OnigEncoding enc, int case_fold_flag,
|
||||||
s, text_end))
|
s, text_end))
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
s += enc_len(enc, s, text_end);
|
s += enclen(enc, s, text_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UChar* )NULL;
|
return (UChar* )NULL;
|
||||||
|
@ -2903,7 +2905,7 @@ bm_search_notrev(regex_t* reg, const UChar* target, const UChar* target_end,
|
||||||
skip = reg->map[*se];
|
skip = reg->map[*se];
|
||||||
t = s;
|
t = s;
|
||||||
do {
|
do {
|
||||||
s += enc_len(reg->enc, s, end);
|
s += enclen(reg->enc, s, end);
|
||||||
} while ((s - t) < skip && s < end);
|
} while ((s - t) < skip && s < end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2919,7 +2921,7 @@ bm_search_notrev(regex_t* reg, const UChar* target, const UChar* target_end,
|
||||||
skip = reg->int_map[*se];
|
skip = reg->int_map[*se];
|
||||||
t = s;
|
t = s;
|
||||||
do {
|
do {
|
||||||
s += enc_len(reg->enc, s, end);
|
s += enclen(reg->enc, s, end);
|
||||||
} while ((s - t) < skip && s < end);
|
} while ((s - t) < skip && s < end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2966,7 +2968,8 @@ bm_search(regex_t* reg, const UChar* target, const UChar* target_end,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
set_bm_backward_skip(UChar* s, UChar* end, OnigEncoding enc, int** skip)
|
set_bm_backward_skip(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED,
|
||||||
|
int** skip)
|
||||||
|
|
||||||
{
|
{
|
||||||
int i, len;
|
int i, len;
|
||||||
|
@ -3024,7 +3027,7 @@ map_search(OnigEncoding enc, UChar map[],
|
||||||
while (s < text_range) {
|
while (s < text_range) {
|
||||||
if (map[*s]) return (UChar* )s;
|
if (map[*s]) return (UChar* )s;
|
||||||
|
|
||||||
s += enc_len(enc, s, text_range);
|
s += enclen(enc, s, text_range);
|
||||||
}
|
}
|
||||||
return (UChar* )NULL;
|
return (UChar* )NULL;
|
||||||
}
|
}
|
||||||
|
@ -3086,7 +3089,7 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, On
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (region
|
if (region
|
||||||
#ifdef USE_POSIX_REGION_OPTION
|
#ifdef USE_POSIX_API_REGION_OPTION
|
||||||
&& !IS_POSIX_REGION(option)
|
&& !IS_POSIX_REGION(option)
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
|
@ -3098,7 +3101,7 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, On
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
prev = (UChar* )onigenc_get_prev_char_head(reg->enc, str, at);
|
prev = (UChar* )onigenc_get_prev_char_head(reg->enc, str, at);
|
||||||
r = match_at(reg, str, end,
|
r = match_at(reg, str, end,
|
||||||
#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
|
#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
|
||||||
end,
|
end,
|
||||||
#endif
|
#endif
|
||||||
at, prev, &msa);
|
at, prev, &msa);
|
||||||
|
@ -3127,7 +3130,7 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
UChar *q = p + reg->dmin;
|
UChar *q = p + reg->dmin;
|
||||||
while (p < q) p += enc_len(reg->enc, p, end);
|
while (p < q) p += enclen(reg->enc, p, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3158,7 +3161,7 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
|
||||||
if (p - reg->dmin < s) {
|
if (p - reg->dmin < s) {
|
||||||
retry_gate:
|
retry_gate:
|
||||||
pprev = p;
|
pprev = p;
|
||||||
p += enc_len(reg->enc, p, end);
|
p += enclen(reg->enc, p, end);
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3353,7 +3356,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
UChar *s, *prev;
|
UChar *s, *prev;
|
||||||
OnigMatchArg msa;
|
OnigMatchArg msa;
|
||||||
const UChar *orig_start = start;
|
const UChar *orig_start = start;
|
||||||
#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
|
#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
|
||||||
const UChar *orig_range = range;
|
const UChar *orig_range = range;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3389,7 +3392,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (region
|
if (region
|
||||||
#ifdef USE_POSIX_REGION_OPTION
|
#ifdef USE_POSIX_API_REGION_OPTION
|
||||||
&& !IS_POSIX_REGION(option)
|
&& !IS_POSIX_REGION(option)
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
|
@ -3400,7 +3403,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
if (start > end || start < str) goto mismatch_no_msa;
|
if (start > end || start < str) goto mismatch_no_msa;
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
|
#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
|
||||||
#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
|
#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
|
||||||
#define MATCH_AND_RETURN_CHECK(upper_range) \
|
#define MATCH_AND_RETURN_CHECK(upper_range) \
|
||||||
r = match_at(reg, str, end, (upper_range), s, prev, &msa); \
|
r = match_at(reg, str, end, (upper_range), s, prev, &msa); \
|
||||||
|
@ -3444,7 +3447,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
else goto finish; /* error */ \
|
else goto finish; /* error */ \
|
||||||
}
|
}
|
||||||
#endif /* USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE */
|
#endif /* USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE */
|
||||||
#endif /* USE_MATCH_RANGE_IS_COMPLETE_RANGE */
|
#endif /* USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE */
|
||||||
|
|
||||||
|
|
||||||
/* anchor optimize: resume search range */
|
/* anchor optimize: resume search range */
|
||||||
|
@ -3604,7 +3607,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
while (s <= high) {
|
while (s <= high) {
|
||||||
MATCH_AND_RETURN_CHECK(orig_range);
|
MATCH_AND_RETURN_CHECK(orig_range);
|
||||||
prev = s;
|
prev = s;
|
||||||
s += enc_len(reg->enc, s, end);
|
s += enclen(reg->enc, s, end);
|
||||||
}
|
}
|
||||||
} while (s < range);
|
} while (s < range);
|
||||||
goto mismatch;
|
goto mismatch;
|
||||||
|
@ -3617,11 +3620,11 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
do {
|
do {
|
||||||
MATCH_AND_RETURN_CHECK(orig_range);
|
MATCH_AND_RETURN_CHECK(orig_range);
|
||||||
prev = s;
|
prev = s;
|
||||||
s += enc_len(reg->enc, s, end);
|
s += enclen(reg->enc, s, end);
|
||||||
|
|
||||||
while (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end) && s < range) {
|
while (!ONIGENC_IS_MBC_NEWLINE(reg->enc, prev, end) && s < range) {
|
||||||
prev = s;
|
prev = s;
|
||||||
s += enc_len(reg->enc, s, end);
|
s += enclen(reg->enc, s, end);
|
||||||
}
|
}
|
||||||
} while (s < range);
|
} while (s < range);
|
||||||
goto mismatch;
|
goto mismatch;
|
||||||
|
@ -3632,7 +3635,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
do {
|
do {
|
||||||
MATCH_AND_RETURN_CHECK(orig_range);
|
MATCH_AND_RETURN_CHECK(orig_range);
|
||||||
prev = s;
|
prev = s;
|
||||||
s += enc_len(reg->enc, s, end);
|
s += enclen(reg->enc, s, end);
|
||||||
} while (s < range);
|
} while (s < range);
|
||||||
|
|
||||||
if (s == range) { /* because empty match with /$/. */
|
if (s == range) { /* because empty match with /$/. */
|
||||||
|
@ -3640,9 +3643,9 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { /* backward search */
|
else { /* backward search */
|
||||||
#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
|
#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
|
||||||
if (orig_start < end)
|
if (orig_start < end)
|
||||||
orig_start += enc_len(reg->enc, orig_start); /* is upper range */
|
orig_start += enclen(reg->enc, orig_start, end); /* is upper range */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (reg->optimize != ONIG_OPTIMIZE_NONE) {
|
if (reg->optimize != ONIG_OPTIMIZE_NONE) {
|
||||||
|
@ -3718,7 +3721,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
|
||||||
/* If result is mismatch and no FIND_NOT_EMPTY option,
|
/* If result is mismatch and no FIND_NOT_EMPTY option,
|
||||||
then the region is not setted in match_at(). */
|
then the region is not setted in match_at(). */
|
||||||
if (IS_FIND_NOT_EMPTY(reg->options) && region
|
if (IS_FIND_NOT_EMPTY(reg->options) && region
|
||||||
#ifdef USE_POSIX_REGION_OPTION
|
#ifdef USE_POSIX_API_REGION_OPTION
|
||||||
&& !IS_POSIX_REGION(option)
|
&& !IS_POSIX_REGION(option)
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
|
|
30
regint.h
30
regint.h
|
@ -51,19 +51,19 @@
|
||||||
(defined(__ppc__) && defined(__APPLE__)) || \
|
(defined(__ppc__) && defined(__APPLE__)) || \
|
||||||
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD86) || \
|
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD86) || \
|
||||||
defined(__mc68020__)
|
defined(__mc68020__)
|
||||||
/* #define PLATFORM_UNALIGNED_WORD_ACCESS */
|
#define PLATFORM_UNALIGNED_WORD_ACCESS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* config */
|
/* config */
|
||||||
/* spec. config */
|
/* spec. config */
|
||||||
#define USE_NAMED_GROUP
|
#define USE_NAMED_GROUP
|
||||||
#define USE_SUBEXP_CALL
|
#define USE_SUBEXP_CALL
|
||||||
#define USE_BACKREF_AT_LEVEL /* \k<name+n>, \k<name-n> */
|
#define USE_BACKREF_WITH_LEVEL /* \k<name+n>, \k<name-n> */
|
||||||
#define USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK /* /(?:()|())*\2/ */
|
#define USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT /* /(?:()|())*\2/ */
|
||||||
#define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
|
#define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
|
||||||
#define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
|
#define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
|
||||||
/* #define USE_RECOMPILE_API */
|
/* #define USE_RECOMPILE_API */
|
||||||
/* #define USE_CRNL_AS_LINE_TERMINATOR */ /* moved to regenc.h. */
|
/* !!! moved to regenc.h. */ /* #define USE_CRNL_AS_LINE_TERMINATOR */
|
||||||
|
|
||||||
/* internal config */
|
/* internal config */
|
||||||
#define USE_PARSE_TREE_NODE_RECYCLE
|
#define USE_PARSE_TREE_NODE_RECYCLE
|
||||||
|
@ -75,6 +75,12 @@
|
||||||
#define INIT_MATCH_STACK_SIZE 160
|
#define INIT_MATCH_STACK_SIZE 160
|
||||||
#define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */
|
#define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
# define ARG_UNUSED __attribute__ ((unused))
|
||||||
|
#else
|
||||||
|
# define ARG_UNUSED
|
||||||
|
#endif
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
/* escape other system UChar definition */
|
/* escape other system UChar definition */
|
||||||
#ifndef RUBY_DEFINES_H
|
#ifndef RUBY_DEFINES_H
|
||||||
|
@ -236,7 +242,6 @@
|
||||||
#define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
|
#define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
|
||||||
#define NULL_UCHARP ((UChar* )0)
|
#define NULL_UCHARP ((UChar* )0)
|
||||||
|
|
||||||
|
|
||||||
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
||||||
|
|
||||||
#define PLATFORM_GET_INC(val,p,type) do{\
|
#define PLATFORM_GET_INC(val,p,type) do{\
|
||||||
|
@ -287,17 +292,17 @@ typedef unsigned int BitStatusType;
|
||||||
#define BIT_STATUS_CLEAR(stats) (stats) = 0
|
#define BIT_STATUS_CLEAR(stats) (stats) = 0
|
||||||
#define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0)
|
#define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0)
|
||||||
#define BIT_STATUS_AT(stats,n) \
|
#define BIT_STATUS_AT(stats,n) \
|
||||||
((n) < BIT_STATUS_BITS_NUM ? ((stats) & (1 << n)) : ((stats) & 1))
|
((n) < (int )BIT_STATUS_BITS_NUM ? ((stats) & (1 << n)) : ((stats) & 1))
|
||||||
|
|
||||||
#define BIT_STATUS_ON_AT(stats,n) do {\
|
#define BIT_STATUS_ON_AT(stats,n) do {\
|
||||||
if ((n) < BIT_STATUS_BITS_NUM)\
|
if ((n) < (int )BIT_STATUS_BITS_NUM) \
|
||||||
(stats) |= (1 << (n));\
|
(stats) |= (1 << (n));\
|
||||||
else\
|
else\
|
||||||
(stats) |= 1;\
|
(stats) |= 1;\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\
|
#define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\
|
||||||
if ((n) < BIT_STATUS_BITS_NUM)\
|
if ((n) < (int )BIT_STATUS_BITS_NUM)\
|
||||||
(stats) |= (1 << (n));\
|
(stats) |= (1 << (n));\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -353,7 +358,7 @@ typedef Bits* BitSetRef;
|
||||||
|
|
||||||
#define BITSET_CLEAR(bs) do {\
|
#define BITSET_CLEAR(bs) do {\
|
||||||
int i;\
|
int i;\
|
||||||
for (i = 0; i < BITSET_SIZE; i++) { (bs)[i] = 0; }\
|
for (i = 0; i < (int )BITSET_SIZE; i++) { (bs)[i] = 0; } \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define BS_ROOM(bs,pos) (bs)[pos / BITS_IN_ROOM]
|
#define BS_ROOM(bs,pos) (bs)[pos / BITS_IN_ROOM]
|
||||||
|
@ -520,7 +525,7 @@ enum OpCode {
|
||||||
OP_BACKREFN_IC,
|
OP_BACKREFN_IC,
|
||||||
OP_BACKREF_MULTI,
|
OP_BACKREF_MULTI,
|
||||||
OP_BACKREF_MULTI_IC,
|
OP_BACKREF_MULTI_IC,
|
||||||
OP_BACKREF_AT_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
|
OP_BACKREF_WITH_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
|
||||||
|
|
||||||
OP_MEMORY_START,
|
OP_MEMORY_START,
|
||||||
OP_MEMORY_START_PUSH, /* push back-tracker to stack */
|
OP_MEMORY_START_PUSH, /* push back-tracker to stack */
|
||||||
|
@ -831,6 +836,9 @@ extern int onig_st_insert_strend P_((hash_table_type* table, const UChar* str_ke
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int onigenc_property_list_add_property P_((UChar* name, const OnigCodePoint* prop, hash_table_type **table, const OnigCodePoint*** plist, int *pnum, int *psize));
|
extern int onigenc_property_list_add_property P_((UChar* name, const OnigCodePoint* prop, hash_table_type **table, const OnigCodePoint*** plist, int *pnum, int *psize));
|
||||||
extern int onigenc_property_list_init P_((int (*f)()));
|
|
||||||
|
typedef int (*ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE)(void);
|
||||||
|
|
||||||
|
extern int onigenc_property_list_init P_((ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE));
|
||||||
|
|
||||||
#endif /* REGINT_H */
|
#endif /* REGINT_H */
|
||||||
|
|
450
regparse.c
450
regparse.c
File diff suppressed because it is too large
Load diff
|
@ -213,7 +213,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NodeBase base;
|
NodeBase base;
|
||||||
int state;
|
int state;
|
||||||
int ref_num;
|
int group_num;
|
||||||
UChar* name;
|
UChar* name;
|
||||||
UChar* name_end;
|
UChar* name_end;
|
||||||
struct _Node* target; /* EncloseNode : ENCLOSE_MEMORY */
|
struct _Node* target; /* EncloseNode : ENCLOSE_MEMORY */
|
||||||
|
@ -340,6 +340,7 @@ extern void onig_node_str_clear P_((Node* node));
|
||||||
extern int onig_free_node_list P_((void));
|
extern int onig_free_node_list P_((void));
|
||||||
extern int onig_names_free P_((regex_t* reg));
|
extern int onig_names_free P_((regex_t* reg));
|
||||||
extern int onig_parse_make_tree P_((Node** root, const UChar* pattern, const UChar* end, regex_t* reg, ScanEnv* env));
|
extern int onig_parse_make_tree P_((Node** root, const UChar* pattern, const UChar* end, regex_t* reg, ScanEnv* env));
|
||||||
|
extern int onig_free_shared_cclass_table P_((void));
|
||||||
|
|
||||||
#ifdef ONIG_DEBUG
|
#ifdef ONIG_DEBUG
|
||||||
#ifdef USE_NAMED_GROUP
|
#ifdef USE_NAMED_GROUP
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#define RUBY_VERSION "1.9.0"
|
#define RUBY_VERSION "1.9.0"
|
||||||
#define RUBY_RELEASE_DATE "2008-01-03"
|
#define RUBY_RELEASE_DATE "2008-01-04"
|
||||||
#define RUBY_VERSION_CODE 190
|
#define RUBY_VERSION_CODE 190
|
||||||
#define RUBY_RELEASE_CODE 20080103
|
#define RUBY_RELEASE_CODE 20080104
|
||||||
#define RUBY_PATCHLEVEL 0
|
#define RUBY_PATCHLEVEL 0
|
||||||
|
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
#define RUBY_VERSION_TEENY 0
|
#define RUBY_VERSION_TEENY 0
|
||||||
#define RUBY_RELEASE_YEAR 2008
|
#define RUBY_RELEASE_YEAR 2008
|
||||||
#define RUBY_RELEASE_MONTH 1
|
#define RUBY_RELEASE_MONTH 1
|
||||||
#define RUBY_RELEASE_DAY 3
|
#define RUBY_RELEASE_DAY 4
|
||||||
|
|
||||||
#ifdef RUBY_EXTERN
|
#ifdef RUBY_EXTERN
|
||||||
RUBY_EXTERN const char ruby_version[];
|
RUBY_EXTERN const char ruby_version[];
|
||||||
|
|
Loading…
Reference in a new issue