1
0
Fork 0
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:
matz 2008-01-03 15:55:04 +00:00
parent 1aaf8b1713
commit 52ed8c4edd
23 changed files with 866 additions and 646 deletions

View file

@ -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>
* io.c (io_ungetc): move data in buffer if it is required to store the

View file

@ -137,7 +137,7 @@ eucjp_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
int c, i, len;
OnigCodePoint n;
len = enc_len(ONIG_ENCODING_EUC_JP, p, end);
len = enclen(ONIG_ENCODING_EUC_JP, p, end);
n = (OnigCodePoint )*p++;
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 & 0xff0000) >= 0x800000) return 3;
else if ((code & 0xff00) >= 0x8000) return 2;
else return 0;
else
return ONIGERR_INVALID_CODE_POINT_VALUE;
}
#if 0
@ -188,8 +189,8 @@ eucjp_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)
*p++ = (UChar )(code & 0xff);
#if 1
if (enc_len(ONIG_ENCODING_EUC_JP, buf, p) != (p - buf))
return ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE;
if (enclen(ONIG_ENCODING_EUC_JP, buf, p) != (p - buf))
return ONIGERR_INVALID_CODE_POINT_VALUE;
#endif
return p - buf;
}
@ -210,7 +211,7 @@ eucjp_mbc_case_fold(OnigCaseFoldType flag,
else {
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++) {
*lower++ = *p++;
}
@ -232,7 +233,7 @@ eucjp_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc
p = s;
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;
p += len;
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);
if (ctype >= (unsigned int )PropertyListNum)
return ONIGENC_ERR_TYPE_BUG;
return ONIGERR_TYPE_BUG;
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
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)
{
if (ctype <= ONIGENC_MAX_STD_CTYPE) {
@ -332,8 +333,8 @@ eucjp_get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
PROPERTY_LIST_INIT_CHECK;
ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
if (ctype >= PropertyListNum)
return ONIGENC_ERR_TYPE_BUG;
if (ctype >= (OnigCtype )PropertyListNum)
return ONIGERR_TYPE_BUG;
*ranges = PropertyList[ctype];
return 0;

View file

@ -2,7 +2,7 @@
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.
*
* 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
static int
iso_8859_10_is_mbc_ambiguous(OnigCaseFoldType flag,
const UChar** pp, const UChar* end)
is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
{
int v;
const UChar* p = *pp;
@ -155,52 +154,52 @@ iso_8859_10_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding e
}
static const OnigPairCaseFoldCodes CaseFoldMap[] = {
{ 0xa1, 0xb1 },
{ 0xa2, 0xb2 },
{ 0xa3, 0xb3 },
{ 0xa4, 0xb4 },
{ 0xa5, 0xb5 },
{ 0xa6, 0xb6 },
{ 0xa8, 0xb8 },
{ 0xa9, 0xb9 },
{ 0xaa, 0xba },
{ 0xab, 0xbb },
{ 0xac, 0xbc },
{ 0xae, 0xbe },
{ 0xaf, 0xbf },
{ 0xa1, 0xb1 },
{ 0xa2, 0xb2 },
{ 0xa3, 0xb3 },
{ 0xa4, 0xb4 },
{ 0xa5, 0xb5 },
{ 0xa6, 0xb6 },
{ 0xa8, 0xb8 },
{ 0xa9, 0xb9 },
{ 0xaa, 0xba },
{ 0xab, 0xbb },
{ 0xac, 0xbc },
{ 0xae, 0xbe },
{ 0xaf, 0xbf },
{ 0xc0, 0xe0 },
{ 0xc1, 0xe1 },
{ 0xc2, 0xe2 },
{ 0xc3, 0xe3 },
{ 0xc4, 0xe4 },
{ 0xc5, 0xe5 },
{ 0xc6, 0xe6 },
{ 0xc7, 0xe7 },
{ 0xc8, 0xe8 },
{ 0xc9, 0xe9 },
{ 0xca, 0xea },
{ 0xcb, 0xeb },
{ 0xcc, 0xec },
{ 0xcd, 0xed },
{ 0xce, 0xee },
{ 0xcf, 0xef },
{ 0xc0, 0xe0 },
{ 0xc1, 0xe1 },
{ 0xc2, 0xe2 },
{ 0xc3, 0xe3 },
{ 0xc4, 0xe4 },
{ 0xc5, 0xe5 },
{ 0xc6, 0xe6 },
{ 0xc7, 0xe7 },
{ 0xc8, 0xe8 },
{ 0xc9, 0xe9 },
{ 0xca, 0xea },
{ 0xcb, 0xeb },
{ 0xcc, 0xec },
{ 0xcd, 0xed },
{ 0xce, 0xee },
{ 0xcf, 0xef },
{ 0xd0, 0xf0 },
{ 0xd1, 0xf1 },
{ 0xd2, 0xf2 },
{ 0xd3, 0xf3 },
{ 0xd4, 0xf4 },
{ 0xd5, 0xf5 },
{ 0xd6, 0xf6 },
{ 0xd7, 0xf7 },
{ 0xd8, 0xf8 },
{ 0xd9, 0xf9 },
{ 0xda, 0xfa },
{ 0xdb, 0xfb },
{ 0xdc, 0xfc },
{ 0xdd, 0xfd },
{ 0xde, 0xfe }
{ 0xd0, 0xf0 },
{ 0xd1, 0xf1 },
{ 0xd2, 0xf2 },
{ 0xd3, 0xf3 },
{ 0xd4, 0xf4 },
{ 0xd5, 0xf5 },
{ 0xd6, 0xf6 },
{ 0xd7, 0xf7 },
{ 0xd8, 0xf8 },
{ 0xd9, 0xf9 },
{ 0xda, 0xfa },
{ 0xdb, 0xfb },
{ 0xdc, 0xfc },
{ 0xdd, 0xfd },
{ 0xde, 0xfe }
};
static int

View file

@ -2,7 +2,7 @@
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.
*
* Redistribution and use in source and binary forms, with or without

View file

@ -2,7 +2,7 @@
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.
*
* 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
static int
iso_8859_13_is_mbc_ambiguous(OnigCaseFoldType flag,
const UChar** pp, const UChar* end)
is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
{
int v;
const UChar* p = *pp;
@ -159,37 +158,37 @@ iso_8859_13_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding e
}
static const OnigPairCaseFoldCodes CaseFoldMap[] = {
{ 0xc0, 0xe0 },
{ 0xc1, 0xe1 },
{ 0xc2, 0xe2 },
{ 0xc3, 0xe3 },
{ 0xc4, 0xe4 },
{ 0xc5, 0xe5 },
{ 0xc6, 0xe6 },
{ 0xc7, 0xe7 },
{ 0xc8, 0xe8 },
{ 0xc9, 0xe9 },
{ 0xca, 0xea },
{ 0xcb, 0xeb },
{ 0xcc, 0xec },
{ 0xcd, 0xed },
{ 0xce, 0xee },
{ 0xcf, 0xef },
{ 0xc0, 0xe0 },
{ 0xc1, 0xe1 },
{ 0xc2, 0xe2 },
{ 0xc3, 0xe3 },
{ 0xc4, 0xe4 },
{ 0xc5, 0xe5 },
{ 0xc6, 0xe6 },
{ 0xc7, 0xe7 },
{ 0xc8, 0xe8 },
{ 0xc9, 0xe9 },
{ 0xca, 0xea },
{ 0xcb, 0xeb },
{ 0xcc, 0xec },
{ 0xcd, 0xed },
{ 0xce, 0xee },
{ 0xcf, 0xef },
{ 0xd0, 0xf0 },
{ 0xd1, 0xf1 },
{ 0xd2, 0xf2 },
{ 0xd3, 0xf3 },
{ 0xd4, 0xf4 },
{ 0xd5, 0xf5 },
{ 0xd6, 0xf6 },
{ 0xd8, 0xf8 },
{ 0xd9, 0xf9 },
{ 0xda, 0xfa },
{ 0xdb, 0xfb },
{ 0xdc, 0xfc },
{ 0xdd, 0xfd },
{ 0xde, 0xfe }
{ 0xd0, 0xf0 },
{ 0xd1, 0xf1 },
{ 0xd2, 0xf2 },
{ 0xd3, 0xf3 },
{ 0xd4, 0xf4 },
{ 0xd5, 0xf5 },
{ 0xd6, 0xf6 },
{ 0xd8, 0xf8 },
{ 0xd9, 0xf9 },
{ 0xda, 0xfa },
{ 0xdb, 0xfb },
{ 0xdc, 0xfc },
{ 0xdd, 0xfd },
{ 0xde, 0xfe }
};
static int

View file

@ -2,7 +2,7 @@
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.
*
* Redistribution and use in source and binary forms, with or without
@ -124,8 +124,8 @@ iso_8859_14_mbc_case_fold(OnigCaseFoldType flag,
#if 0
static int
iso_8859_14_is_mbc_ambiguous(OnigCaseFoldType flag,
const UChar** pp, const UChar* end)
is_mbc_ambiguous(OnigCaseFoldType flag,
const UChar** pp, const UChar* end)
{
int v;
const UChar* p = *pp;
@ -155,53 +155,53 @@ iso_8859_14_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding e
}
static const OnigPairCaseFoldCodes CaseFoldMap[] = {
{ 0xa1, 0xa2 },
{ 0xa4, 0xa5 },
{ 0xa6, 0xab },
{ 0xa8, 0xb8 },
{ 0xaa, 0xba },
{ 0xac, 0xbc },
{ 0xaf, 0xff },
{ 0xa1, 0xa2 },
{ 0xa4, 0xa5 },
{ 0xa6, 0xab },
{ 0xa8, 0xb8 },
{ 0xaa, 0xba },
{ 0xac, 0xbc },
{ 0xaf, 0xff },
{ 0xb0, 0xb1 },
{ 0xb2, 0xb3 },
{ 0xb4, 0xb5 },
{ 0xb7, 0xb9 },
{ 0xbb, 0xbf },
{ 0xbd, 0xbe },
{ 0xb0, 0xb1 },
{ 0xb2, 0xb3 },
{ 0xb4, 0xb5 },
{ 0xb7, 0xb9 },
{ 0xbb, 0xbf },
{ 0xbd, 0xbe },
{ 0xc0, 0xe0 },
{ 0xc1, 0xe1 },
{ 0xc2, 0xe2 },
{ 0xc3, 0xe3 },
{ 0xc4, 0xe4 },
{ 0xc5, 0xe5 },
{ 0xc6, 0xe6 },
{ 0xc7, 0xe7 },
{ 0xc8, 0xe8 },
{ 0xc9, 0xe9 },
{ 0xca, 0xea },
{ 0xcb, 0xeb },
{ 0xcc, 0xec },
{ 0xcd, 0xed },
{ 0xce, 0xee },
{ 0xcf, 0xef },
{ 0xc0, 0xe0 },
{ 0xc1, 0xe1 },
{ 0xc2, 0xe2 },
{ 0xc3, 0xe3 },
{ 0xc4, 0xe4 },
{ 0xc5, 0xe5 },
{ 0xc6, 0xe6 },
{ 0xc7, 0xe7 },
{ 0xc8, 0xe8 },
{ 0xc9, 0xe9 },
{ 0xca, 0xea },
{ 0xcb, 0xeb },
{ 0xcc, 0xec },
{ 0xcd, 0xed },
{ 0xce, 0xee },
{ 0xcf, 0xef },
{ 0xd0, 0xf0 },
{ 0xd1, 0xf1 },
{ 0xd2, 0xf2 },
{ 0xd3, 0xf3 },
{ 0xd4, 0xf4 },
{ 0xd5, 0xf5 },
{ 0xd6, 0xf6 },
{ 0xd7, 0xf7 },
{ 0xd8, 0xf8 },
{ 0xd9, 0xf9 },
{ 0xda, 0xfa },
{ 0xdb, 0xfb },
{ 0xdc, 0xfc },
{ 0xdd, 0xfd },
{ 0xde, 0xfe }
{ 0xd0, 0xf0 },
{ 0xd1, 0xf1 },
{ 0xd2, 0xf2 },
{ 0xd3, 0xf3 },
{ 0xd4, 0xf4 },
{ 0xd5, 0xf5 },
{ 0xd6, 0xf6 },
{ 0xd7, 0xf7 },
{ 0xd8, 0xf8 },
{ 0xd9, 0xf9 },
{ 0xda, 0xfa },
{ 0xdb, 0xfb },
{ 0xdc, 0xfc },
{ 0xdd, 0xfd },
{ 0xde, 0xfe }
};
static int

View file

@ -2,7 +2,7 @@
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.
*
* Redistribution and use in source and binary forms, with or without
@ -124,8 +124,8 @@ iso_8859_15_mbc_case_fold(OnigCaseFoldType flag,
#if 0
static int
iso_8859_15_is_mbc_ambiguous(OnigCaseFoldType flag,
const UChar** pp, const UChar* end)
is_mbc_ambiguous(OnigCaseFoldType flag,
const UChar** pp, const UChar* end)
{
int v;
const UChar* p = *pp;
@ -159,43 +159,43 @@ iso_8859_15_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding e
}
static const OnigPairCaseFoldCodes CaseFoldMap[] = {
{ 0xa6, 0xa8 },
{ 0xa6, 0xa8 },
{ 0xb4, 0xb8 },
{ 0xbc, 0xbd },
{ 0xbe, 0xff },
{ 0xb4, 0xb8 },
{ 0xbc, 0xbd },
{ 0xbe, 0xff },
{ 0xc0, 0xe0 },
{ 0xc1, 0xe1 },
{ 0xc2, 0xe2 },
{ 0xc3, 0xe3 },
{ 0xc4, 0xe4 },
{ 0xc5, 0xe5 },
{ 0xc6, 0xe6 },
{ 0xc7, 0xe7 },
{ 0xc8, 0xe8 },
{ 0xc9, 0xe9 },
{ 0xca, 0xea },
{ 0xcb, 0xeb },
{ 0xcc, 0xec },
{ 0xcd, 0xed },
{ 0xce, 0xee },
{ 0xcf, 0xef },
{ 0xc0, 0xe0 },
{ 0xc1, 0xe1 },
{ 0xc2, 0xe2 },
{ 0xc3, 0xe3 },
{ 0xc4, 0xe4 },
{ 0xc5, 0xe5 },
{ 0xc6, 0xe6 },
{ 0xc7, 0xe7 },
{ 0xc8, 0xe8 },
{ 0xc9, 0xe9 },
{ 0xca, 0xea },
{ 0xcb, 0xeb },
{ 0xcc, 0xec },
{ 0xcd, 0xed },
{ 0xce, 0xee },
{ 0xcf, 0xef },
{ 0xd0, 0xf0 },
{ 0xd1, 0xf1 },
{ 0xd2, 0xf2 },
{ 0xd3, 0xf3 },
{ 0xd4, 0xf4 },
{ 0xd5, 0xf5 },
{ 0xd6, 0xf6 },
{ 0xd8, 0xf8 },
{ 0xd9, 0xf9 },
{ 0xda, 0xfa },
{ 0xdb, 0xfb },
{ 0xdc, 0xfc },
{ 0xdd, 0xfd },
{ 0xde, 0xfe }
{ 0xd0, 0xf0 },
{ 0xd1, 0xf1 },
{ 0xd2, 0xf2 },
{ 0xd3, 0xf3 },
{ 0xd4, 0xf4 },
{ 0xd5, 0xf5 },
{ 0xd6, 0xf6 },
{ 0xd8, 0xf8 },
{ 0xd9, 0xf9 },
{ 0xda, 0xfa },
{ 0xdb, 0xfb },
{ 0xdc, 0xfc },
{ 0xdd, 0xfd },
{ 0xde, 0xfe }
};
static int

View file

@ -2,7 +2,7 @@
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.
*
* 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
static int
iso_8859_16_is_mbc_ambiguous(OnigCaseFoldType flag,
const UChar** pp, const UChar* end)
is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
{
int v;
const UChar* p = *pp;
@ -155,50 +154,50 @@ iso_8859_16_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding e
}
static const OnigPairCaseFoldCodes CaseFoldMap[] = {
{ 0xa1, 0xa2 },
{ 0xa3, 0xb3 },
{ 0xa6, 0xa8 },
{ 0xaa, 0xba },
{ 0xac, 0xae },
{ 0xaf, 0xbf },
{ 0xa1, 0xa2 },
{ 0xa3, 0xb3 },
{ 0xa6, 0xa8 },
{ 0xaa, 0xba },
{ 0xac, 0xae },
{ 0xaf, 0xbf },
{ 0xb2, 0xb9 },
{ 0xb4, 0xb8 },
{ 0xbc, 0xbd },
{ 0xbe, 0xff },
{ 0xb2, 0xb9 },
{ 0xb4, 0xb8 },
{ 0xbc, 0xbd },
{ 0xbe, 0xff },
{ 0xc0, 0xe0 },
{ 0xc1, 0xe1 },
{ 0xc2, 0xe2 },
{ 0xc3, 0xe3 },
{ 0xc4, 0xe4 },
{ 0xc5, 0xe5 },
{ 0xc6, 0xe6 },
{ 0xc7, 0xe7 },
{ 0xc8, 0xe8 },
{ 0xc9, 0xe9 },
{ 0xca, 0xea },
{ 0xcb, 0xeb },
{ 0xcc, 0xec },
{ 0xcd, 0xed },
{ 0xce, 0xee },
{ 0xcf, 0xef },
{ 0xc0, 0xe0 },
{ 0xc1, 0xe1 },
{ 0xc2, 0xe2 },
{ 0xc3, 0xe3 },
{ 0xc4, 0xe4 },
{ 0xc5, 0xe5 },
{ 0xc6, 0xe6 },
{ 0xc7, 0xe7 },
{ 0xc8, 0xe8 },
{ 0xc9, 0xe9 },
{ 0xca, 0xea },
{ 0xcb, 0xeb },
{ 0xcc, 0xec },
{ 0xcd, 0xed },
{ 0xce, 0xee },
{ 0xcf, 0xef },
{ 0xd0, 0xf0 },
{ 0xd1, 0xf1 },
{ 0xd2, 0xf2 },
{ 0xd3, 0xf3 },
{ 0xd4, 0xf4 },
{ 0xd5, 0xf5 },
{ 0xd6, 0xf6 },
{ 0xd7, 0xf7 },
{ 0xd8, 0xf8 },
{ 0xd9, 0xf9 },
{ 0xda, 0xfa },
{ 0xdb, 0xfb },
{ 0xdc, 0xfc },
{ 0xdd, 0xfd },
{ 0xde, 0xfe }
{ 0xd0, 0xf0 },
{ 0xd1, 0xf1 },
{ 0xd2, 0xf2 },
{ 0xd3, 0xf3 },
{ 0xd4, 0xf4 },
{ 0xd5, 0xf5 },
{ 0xd6, 0xf6 },
{ 0xd7, 0xf7 },
{ 0xd8, 0xf8 },
{ 0xd9, 0xf9 },
{ 0xda, 0xfa },
{ 0xdb, 0xfb },
{ 0xdc, 0xfc },
{ 0xdd, 0xfd },
{ 0xde, 0xfe }
};
static int

View file

@ -2,7 +2,7 @@
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.
*
* Redistribution and use in source and binary forms, with or without

View file

@ -2,7 +2,7 @@
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.
*
* 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
static int
iso_8859_9_is_mbc_ambiguous(OnigCaseFoldType flag,
const UChar** pp, const UChar* end)
is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
{
int v;
const UChar* p = *pp;

View file

@ -141,7 +141,7 @@ sjis_code_to_mbclen(OnigCodePoint code, OnigEncoding enc)
return 2;
}
else
return 0;
return ONIGERR_INVALID_CODE_POINT_VALUE;
}
static OnigCodePoint
@ -150,7 +150,7 @@ sjis_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
int c, i, len;
OnigCodePoint n;
len = enc_len(ONIG_ENCODING_SJIS, p, end);
len = enclen(ONIG_ENCODING_SJIS, p, end);
c = *p++;
n = c;
if (len == 1) return n;
@ -172,8 +172,8 @@ sjis_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc)
*p++ = (UChar )(code & 0xff);
#if 0
if (enc_len(ONIG_ENCODING_SJIS, buf) != (p - buf))
return REGERR_INVALID_WIDE_CHAR_VALUE;
if (enclen(ONIG_ENCODING_SJIS, buf) != (p - buf))
return REGERR_INVALID_CODE_POINT_VALUE;
#endif
return p - buf;
}
@ -192,7 +192,7 @@ sjis_mbc_case_fold(OnigCaseFoldType flag,
}
else {
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++) {
*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;
p += len;
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);
if (ctype >= (unsigned int )PropertyListNum)
return ONIGENC_ERR_TYPE_BUG;
return ONIGERR_TYPE_BUG;
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
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)
{
if (ctype <= ONIGENC_MAX_STD_CTYPE) {
@ -343,8 +343,8 @@ sjis_get_ctype_code_range(int ctype, OnigCodePoint* sb_out,
PROPERTY_LIST_INIT_CHECK;
ctype -= (ONIGENC_MAX_STD_CTYPE + 1);
if (ctype >= PropertyListNum)
return ONIGENC_ERR_TYPE_BUG;
if (ctype >= (OnigCtype )PropertyListNum)
return ONIGERR_TYPE_BUG;
*ranges = PropertyList[ctype];
return 0;

View file

@ -10618,7 +10618,7 @@ static PosixBracketEntryType HashEntryData[] = {
static const OnigCodePoint* CodeRanges[CODE_RANGES_NUM];
static int CodeRangeTableInited = 0;
static void init_code_range_array() {
static void init_code_range_array(void) {
THREAD_ATOMIC_START;
CodeRanges[0] = CR_NEWLINE;
@ -10756,7 +10756,7 @@ onigenc_unicode_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncodi
}
if (ctype >= CODE_RANGES_NUM) {
return ONIGENC_ERR_TYPE_BUG;
return ONIGERR_TYPE_BUG;
}
if (CodeRangeTableInited == 0) init_code_range_array();
@ -10769,7 +10769,7 @@ extern int
onigenc_unicode_ctype_code_range(int ctype, const OnigCodePoint* ranges[])
{
if (ctype >= CODE_RANGES_NUM) {
return ONIGENC_ERR_TYPE_BUG;
return ONIGERR_TYPE_BUG;
}
if (CodeRangeTableInited == 0) init_code_range_array();
@ -10780,7 +10780,7 @@ onigenc_unicode_ctype_code_range(int ctype, const OnigCodePoint* ranges[])
}
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[])
{
*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)
return ONIGERR_INVALID_CHAR_PROPERTY_NAME;
p += enc_len(enc, p, end);
p += enclen(enc, p, end);
}
buf[len] = 0;
@ -10903,11 +10903,12 @@ static int init_case_fold_table(void)
FoldTable = st_init_numtable_with_size(1200);
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];
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];
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);
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];
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++) {
p1 = &CaseUnfold_11_Locale[i];
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);
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];
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++) {
p2 = &CaseUnfold_12_Locale[i];
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);
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];
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
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;
OnigCodePoint code;
@ -10963,7 +10970,7 @@ onigenc_unicode_mbc_case_fold(OnigEncoding enc,
if (CaseFoldInited == 0) init_case_fold_table();
code = ONIGENC_MBC_TO_CODE(enc, p, end);
len = enc_len(enc, p, end);
len = enclen(enc, p, end);
*pp += len;
#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(); */
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];
for (j = 0; j < p11->to.n; j++) {
code = p11->from;
@ -11053,7 +11061,8 @@ onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag,
}
else {
#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++) {
p11 = &CaseUnfold_11_Locale[i];
for (j = 0; j < p11->to.n; j++) {
@ -11081,7 +11090,8 @@ onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag,
#endif
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++) {
r = (*f)(CaseUnfold_12[i].to.code[j],
(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
if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) == 0) {
#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++) {
for (j = 0; j < CaseUnfold_12_Locale[i].to.n; j++) {
r = (*f)(CaseUnfold_12_Locale[i].to.code[j],
@ -11121,7 +11132,8 @@ onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag,
}
#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++) {
r = (*f)(CaseUnfold_13[i].to.code[j],
(OnigCodePoint* )CaseUnfold_13[i].from, 3, arg);
@ -11156,7 +11168,7 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
n = 0;
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
if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
@ -11305,7 +11317,7 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
else
codes[1] = code;
clen = enc_len(enc, p, end);
clen = enclen(enc, p, end);
len += clen;
if (onig_st_lookup(Unfold2Table, (st_data_t )codes, (void* )&z2) != 0) {
for (i = 0; i < z2->n; i++) {
@ -11326,7 +11338,7 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
else
codes[2] = code;
clen = enc_len(enc, p, end);
clen = enclen(enc, p, end);
len += clen;
if (onig_st_lookup(Unfold3Table, (st_data_t )codes,
(void* )&z2) != 0) {

View file

@ -272,7 +272,7 @@ utf8_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
int c, len;
OnigCodePoint n;
len = enc_len(ONIG_ENCODING_UTF8, p, end);
len = enclen(ONIG_ENCODING_UTF8, p, end);
c = *p++;
if (len > 1) {
len--;
@ -307,33 +307,9 @@ utf8_code_to_mbclen(OnigCodePoint code, OnigEncoding enc)
else if (code == INVALID_CODE_FF) return 1;
#endif
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
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
else {
return ONIGENC_ERR_TOO_BIG_WIDE_CHAR_VALUE;
return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE;
}
*p++ = UTF8_TRAIL0(code);
@ -421,7 +397,7 @@ utf8_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp,
#if 0
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;
@ -430,7 +406,7 @@ utf8_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
}
else {
(*pp) += enc_len(ONIG_ENCODING_UTF8, p);
(*pp) += enclen(ONIG_ENCODING_UTF8, p);
if (*p == 0xc3) {
int c = *(p + 1);
@ -457,7 +433,7 @@ utf8_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
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)
{
*sb_out = 0x80;
@ -478,7 +454,7 @@ utf8_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
}
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[],
OnigEncoding enc)
{
@ -497,7 +473,7 @@ OnigEncodingDefine(utf8, UTF8) = {
utf8_code_to_mbc,
utf8_mbc_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_is_code_ctype,
utf8_get_ctype_code_range,

View file

@ -39,7 +39,7 @@ extern "C" {
#define ONIGURUMA
#define ONIGURUMA_VERSION_MAJOR 5
#define ONIGURUMA_VERSION_MINOR 9
#define ONIGURUMA_VERSION_TEENY 0
#define ONIGURUMA_VERSION_TEENY 1
#ifdef __cplusplus
# ifndef HAVE_PROTOTYPES
@ -57,6 +57,12 @@ extern "C" {
# endif
#endif
#ifdef HAVE_STDARG_H
# ifndef HAVE_STDARG_PROTOTYPES
# define HAVE_STDARG_PROTOTYPES 1
# endif
#endif
#ifndef P_
#if defined(__STDC__) || defined(_WIN32)
# define P_(args) args
@ -99,12 +105,12 @@ extern "C" {
typedef unsigned char OnigUChar;
typedef unsigned long OnigCodePoint;
typedef unsigned int OnigCtype;
typedef unsigned int OnigDistance;
#define ONIG_INFINITE_DISTANCE ~((OnigDistance )0)
/* case fold flag */
typedef unsigned int OnigCaseFoldType;
typedef unsigned int OnigCaseFoldType; /* case fold flag */
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 (*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 (*is_code_ctype)(OnigCodePoint code, unsigned int ctype, struct OnigEncodingTypeST* enc);
int (*get_ctype_code_range)(int ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], struct OnigEncodingTypeST* enc);
int (*is_code_ctype)(OnigCodePoint code, OnigCtype ctype, 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);
int (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end, struct OnigEncodingTypeST* enc);
void *auxiliary_data;
@ -256,7 +262,7 @@ ONIG_EXTERN OnigEncodingType OnigEncodingGB18030;
#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_SINGLEBYTE(enc) (ONIGENC_MBC_MAXLEN(enc) == 1)
@ -604,6 +610,7 @@ ONIG_EXTERN OnigSyntaxType* OnigDefaultSyntax;
#define ONIGERR_NEVER_ENDING_RECURSION -221
#define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY -222
#define ONIGERR_INVALID_CHAR_PROPERTY_NAME -223
#define ONIGERR_INVALID_CODE_POINT_VALUE -400
#define ONIGERR_INVALID_WIDE_CHAR_VALUE -400
#define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE -401
#define ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION -402

128
regcomp.c
View file

@ -115,7 +115,7 @@ static int
bitset_is_empty(BitSetRef bs)
{
int i;
for (i = 0; i < BITSET_SIZE; i++) {
for (i = 0; i < (int )BITSET_SIZE; i++) {
if (bs[i] != 0) return 0;
}
return 1;
@ -416,8 +416,8 @@ compile_tree_n_times(Node* node, int n, regex_t* reg)
}
static int
add_compile_string_length(UChar* s, int mb_len, int str_len,
regex_t* reg, int ignore_case)
add_compile_string_length(UChar* s ARG_UNUSED, int mb_len, int str_len,
regex_t* reg ARG_UNUSED, int ignore_case)
{
int len;
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);
p = prev = sn->s;
prev_len = enc_len(enc, p, sn->end);
prev_len = enclen(enc, p, sn->end);
p += prev_len;
slen = 1;
rlen = 0;
for (; p < sn->end; ) {
len = enc_len(enc, p, sn->end);
len = enclen(enc, p, sn->end);
if (len == prev_len) {
slen++;
}
@ -518,12 +518,12 @@ compile_string_node(Node* node, regex_t* reg)
ambig = NSTRING_IS_AMBIG(node);
p = prev = sn->s;
prev_len = enc_len(enc, p, end);
prev_len = enclen(enc, p, end);
p += prev_len;
slen = 1;
for (; p < end; ) {
len = enc_len(enc, p, end);
len = enclen(enc, p, end);
if (len == prev_len) {
slen++;
}
@ -1535,7 +1535,7 @@ compile_length_tree(Node* node, regex_t* reg)
{
BRefNode* br = NBREF(node);
#ifdef USE_BACKREF_AT_LEVEL
#ifdef USE_BACKREF_WITH_LEVEL
if (IS_BACKREF_NEST_LEVEL(br)) {
r = SIZE_OPCODE + SIZE_OPTION + SIZE_LENGTH +
SIZE_LENGTH + (SIZE_MEMNUM * br->back_num);
@ -1659,9 +1659,9 @@ compile_tree(Node* node, regex_t* reg)
{
BRefNode* br = NBREF(node);
#ifdef USE_BACKREF_AT_LEVEL
#ifdef USE_BACKREF_WITH_LEVEL
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;
r = add_option(reg, (reg->options & ONIG_OPTION_IGNORECASE));
if (r) return r;
@ -1703,7 +1703,7 @@ compile_tree(Node* node, regex_t* reg)
}
if (r) return r;
#ifdef USE_BACKREF_AT_LEVEL
#ifdef USE_BACKREF_WITH_LEVEL
add_bacref_mems:
#endif
r = add_length(reg, br->back_num);
@ -1951,7 +1951,7 @@ unset_addr_list_fix(UnsetAddrList* uslist, regex_t* reg)
}
#endif
#ifdef USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK
#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
static int
quantifiers_memory_node_info(Node* node)
{
@ -2018,7 +2018,7 @@ quantifiers_memory_node_info(Node* node)
return r;
}
#endif /* USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK */
#endif /* USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT */
static int
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);
UChar *s = sn->s;
while (s < sn->end) {
s += enc_len(reg->enc, s, sn->end);
s += enclen(reg->enc, s, sn->end);
(*len)++;
}
}
@ -3003,25 +3003,12 @@ setup_subexp_call(Node* node, ScanEnv* env)
case NT_CALL:
{
int n, num, *refs;
UChar *p;
CallNode* cn = NCALL(node);
Node** nodes = SCANENV_MEM_NODES(env);
#ifdef USE_NAMED_GROUP
n = onig_name_to_group_numbers(env->reg, cn->name, cn->name_end, &refs);
#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;
}
if (cn->group_num != 0) {
int gnum = cn->group_num;
#ifdef USE_NAMED_GROUP
if (env->num_named > 0 &&
IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
@ -3029,32 +3016,47 @@ setup_subexp_call(Node* node, ScanEnv* env)
return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
}
#endif
if (num > env->num_mem) {
if (gnum > env->num_mem) {
onig_scan_env_set_error_string(env,
ONIGERR_UNDEFINED_GROUP_REFERENCE, cn->name, cn->name_end);
return ONIGERR_UNDEFINED_GROUP_REFERENCE;
}
cn->ref_num = num;
goto set_call_attr;
}
else if (n > 1) {
onig_scan_env_set_error_string(env,
ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL, cn->name, cn->name_end);
return ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL;
}
else {
cn->ref_num = refs[0];
#ifdef USE_NAMED_GROUP
set_call_attr:
cn->target = nodes[cn->ref_num];
#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);
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);
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) {
onig_scan_env_set_error_string(env,
ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL, cn->name, cn->name_end);
return ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL;
}
else {
cn->group_num = refs[0];
goto set_call_attr;
}
}
#endif
}
break;
@ -3389,7 +3391,7 @@ expand_case_fold_string(Node* node, regex_t* reg)
goto err;
}
len = enc_len(reg->enc, p, end);
len = enclen(reg->enc, p, end);
if (n == 0) {
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;
BIT_STATUS_ON_AT(env->backrefed_mem, 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)) {
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 (d == 0) {
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);
if (r < 0) break;
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 */
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)
{
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
};
if (i < sizeof(ByteValTable)/sizeof(ByteValTable[0])) {
if (i < (int )(sizeof(ByteValTable)/sizeof(ByteValTable[0]))) {
if (i == 0 && ONIGENC_MBC_MINLEN(enc) > 1)
return 20;
else
@ -4019,7 +4021,7 @@ distance_value(MinMaxLen* mm)
if (mm->max == ONIG_INFINITE_DISTANCE) return 0;
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 (int )dist_vals[d];
else
@ -4212,7 +4214,7 @@ concat_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OnigEncoding enc)
p = add->s;
end = p + add->len;
for (i = to->len; p < end; ) {
len = enc_len(enc, p, end);
len = enclen(enc, p, end);
if (i + len > OPT_EXACT_MAXLEN) break;
for (j = 0; j < len && p < end; j++)
to->s[i++] = *p++;
@ -4227,14 +4229,14 @@ concat_opt_exact_info(OptExactInfo* to, OptExactInfo* add, OnigEncoding enc)
}
static void
concat_opt_exact_info_str(OptExactInfo* to,
UChar* s, UChar* end, int raw, OnigEncoding enc)
concat_opt_exact_info_str(OptExactInfo* to, UChar* s, UChar* end,
int raw ARG_UNUSED, OnigEncoding enc)
{
int i, j, len;
UChar *p;
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;
for (j = 0; j < len && p < end; j++)
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; ) {
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++) {
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);
}
p += enc_len(enc, p);
p += enclen(enc, p);
}
}
else {
@ -5634,8 +5636,6 @@ onig_init(void)
extern int
onig_end(void)
{
extern int onig_free_shared_cclass_table(void);
THREAD_ATOMIC_START;
#ifdef ONIG_DEBUG_STATISTICS
@ -5679,11 +5679,11 @@ onig_is_in_code_range(const UChar* p, OnigCodePoint code)
}
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;
if (enclen > 1 || (code >= SINGLE_BYTE_SIZE)) {
if (elen > 1 || (code >= SINGLE_BYTE_SIZE)) {
if (IS_NULL(cc->mbuf)) {
found = 0;
}
@ -5776,7 +5776,7 @@ OnigOpInfoType OnigOpInfo[] = {
{ OP_BACKREFN_IC, "backrefn-ic", ARG_SPECIAL },
{ OP_BACKREF_MULTI, "backref_multi", 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, "mem-start", 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;
case OP_EXACT1_IC:
len = enc_len(enc, bp);
len = enclen(enc, bp);
p_string(f, len, bp);
bp += len;
break;
@ -6043,7 +6043,7 @@ onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar** nextp,
}
break;
case OP_BACKREF_AT_LEVEL:
case OP_BACKREF_WITH_LEVEL:
{
OnigOptionType option;
LengthType level;
@ -6182,7 +6182,7 @@ print_indent_tree(FILE* f, Node* node, int indent)
case NT_CCLASS:
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) {
BBuf* bbuf = NCCLASS(node)->mbuf;
for (i = 0; i < bbuf->used; i++) {

View file

@ -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);
if (p < s) {
p += enc_len(enc, p, s);
p += enclen(enc, p, s);
}
return p;
}
@ -68,7 +68,7 @@ onigenc_get_right_adjust_char_head_with_prev(OnigEncoding enc,
if (p < s) {
if (prev) *prev = (const UChar* )p;
p += enc_len(enc, p, s);
p += enclen(enc, p, s);
}
else {
if (prev) *prev = (const UChar* )NULL; /* Sorry */
@ -351,7 +351,7 @@ const UChar OnigEncISO_8859_1_ToUpperCaseTable[256] = {
#endif
extern void
onigenc_set_default_caseconv_table(const UChar* table)
onigenc_set_default_caseconv_table(const UChar* table ARG_UNUSED)
{
/* nothing */
/* obsoleted. */
@ -393,15 +393,16 @@ const OnigPairCaseFoldCodes OnigAsciiLowerMap[] = {
};
extern int
onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag,
onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,
OnigApplyAllCaseFoldFunc f, void* arg,
OnigEncoding enc)
{
OnigCodePoint code;
int i, r;
for (i = 0; i < sizeof(OnigAsciiLowerMap)/sizeof(OnigPairCaseFoldCodes)
; i++) {
for (i = 0;
i < (int )(sizeof(OnigAsciiLowerMap)/sizeof(OnigPairCaseFoldCodes));
i++) {
code = OnigAsciiLowerMap[i].to;
r = (*f)(OnigAsciiLowerMap[i].from, &code, 1, arg);
if (r != 0) return r;
@ -435,8 +436,8 @@ onigenc_ascii_get_case_fold_codes_by_str(OnigCaseFoldType flag,
return 0;
}
extern int
ss_apply_all_case_fold(OnigCaseFoldType flag,
static int
ss_apply_all_case_fold(OnigCaseFoldType flag ARG_UNUSED,
OnigApplyAllCaseFoldFunc f, void* arg)
{
static OnigCodePoint ss[] = { 0x73, 0x73 };
@ -475,7 +476,7 @@ onigenc_apply_all_case_fold_with_map(int map_size,
extern int
onigenc_get_case_fold_codes_by_str_with_map(int map_size,
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[])
{
if (0x41 <= *p && *p <= 0x5a) {
@ -555,7 +556,7 @@ onigenc_get_case_fold_codes_by_str_with_map(int map_size,
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[],
OnigEncoding enc)
{
@ -656,7 +657,7 @@ onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end)
int c, i, len;
OnigCodePoint n;
len = enc_len(enc, p, end);
len = enclen(enc, p, end);
n = (OnigCodePoint )(*p++);
if (len == 1) return n;
@ -669,8 +670,9 @@ onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end)
}
extern int
onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag,
const UChar** pp, const UChar* end, UChar* lower)
onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag ARG_UNUSED,
const UChar** pp, const UChar* end ARG_UNUSED,
UChar* lower)
{
int len;
const UChar *p = *pp;
@ -683,7 +685,7 @@ onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag,
else {
int i;
len = enc_len(enc, p, end);
len = enclen(enc, p, end);
for (i = 0; i < len; i++) {
*lower++ = *p++;
}
@ -704,7 +706,7 @@ onigenc_mbn_is_mbc_ambiguous(OnigEncoding enc, OnigCaseFoldType flag,
return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
}
(*pp) += enc_len(enc, p);
(*pp) += enclen(enc, p);
return FALSE;
}
#endif
@ -736,8 +738,8 @@ onigenc_mb2_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
*p++ = (UChar )(code & 0xff);
#if 1
if (enc_len(enc, buf, p) != (p - buf))
return ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE;
if (enclen(enc, buf, p) != (p - buf))
return ONIGERR_INVALID_CODE_POINT_VALUE;
#endif
return p - buf;
}
@ -759,8 +761,8 @@ onigenc_mb4_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
*p++ = (UChar )(code & 0xff);
#if 1
if (enc_len(enc, buf, p) != (p - buf))
return ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE;
if (enclen(enc, buf, p) != (p - buf))
return ONIGERR_INVALID_CODE_POINT_VALUE;
#endif
return p - buf;
}
@ -843,7 +845,7 @@ onigenc_with_ascii_strncmp(OnigEncoding enc, const UChar* p, const UChar* end,
if (x) return x;
sascii++;
p += enc_len(enc, p, end);
p += enclen(enc, p, end);
}
return 0;
}
@ -900,7 +902,7 @@ onigenc_property_list_add_property(UChar* name, const OnigCodePoint* prop,
}
extern int
onigenc_property_list_init(int (*f)())
onigenc_property_list_init(int (*f)(void))
{
int r;

View file

@ -57,17 +57,21 @@ typedef struct {
#define FALSE 0
#endif
/* error codes */
#define ONIGENC_ERR_MEMORY -5
#define ONIGENC_ERR_TYPE_BUG -6
#define ONIGENC_ERR_INVALID_WIDE_CHAR_VALUE -400
#define ONIGENC_ERR_TOO_BIG_WIDE_CHAR_VALUE -401
#ifndef ARG_UNUSED
#if defined(__GNUC__)
# define ARG_UNUSED __attribute__ ((unused))
#else
# define ARG_UNUSED
#endif
#endif
#define ONIG_IS_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_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 */
#define BIT_CTYPE_NEWLINE (1<< ONIGENC_CTYPE_NEWLINE)
#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_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_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));
@ -141,7 +145,7 @@ ONIG_EXTERN int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint co
/* in enc/unicode.c */
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_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));

View file

@ -142,8 +142,8 @@ onig_error_code_to_format(int code)
p = "too big wide-char value"; break;
case ONIGERR_TOO_LONG_WIDE_CHAR_VALUE:
p = "too long wide-char value"; break;
case ONIGERR_INVALID_WIDE_CHAR_VALUE:
p = "invalid wide-char value"; break;
case ONIGERR_INVALID_CODE_POINT_VALUE:
p = "invalid code point value"; break;
case ONIGERR_EMPTY_GROUP_NAME:
p = "group name is empty"; break;
case ONIGERR_INVALID_GROUP_NAME:
@ -182,6 +182,15 @@ onig_error_code_to_format(int code)
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,
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) {
code = ONIGENC_MBC_TO_CODE(enc, p, end);
if (code >= 0x80) {
if (len + 5 <= buf_size) {
sprintf((char* )(&(buf[len])), "\\x%02X",
(unsigned int )(code & 0377));
len += 5;
if (code > 0xffff && len + 10 <= buf_size) {
sprint_byte_with_x((char*)(&(buf[len])), (unsigned int)(code >> 24));
sprint_byte((char*)(&(buf[len+4])), (unsigned int)(code >> 16));
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 {
break;
@ -209,7 +225,7 @@ static int to_ascii(OnigEncoding enc, UChar *s, UChar *end,
buf[len++] = (UChar )code;
}
p += enc_len(enc, p, end);
p += enclen(enc, p, end);
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) {
if (*p == '\\') {
*s++ = *p++;
len = enc_len(enc, p, pat_end);
len = enclen(enc, p, pat_end);
while (len-- > 0) *s++ = *p++;
}
else if (*p == '/') {
@ -338,7 +354,7 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)
*s++ = *p++;
}
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) {
while (len-- > 0) *s++ = *p++;
}
@ -346,7 +362,7 @@ onig_snprintf_with_pattern(buf, bufsize, enc, pat, pat_end, fmt, va_alist)
int blen;
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);
bp = bs;
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) &&
!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);
bp = bs;
while (len-- > 0) *s++ = *bp++;

121
regexec.c
View file

@ -29,10 +29,12 @@
#include "regint.h"
#define USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
#ifdef USE_CRNL_AS_LINE_TERMINATOR
#define ONIGENC_IS_MBC_CRNL(enc,p,end) \
(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
#ifdef USE_CAPTURE_HISTORY
@ -196,7 +198,7 @@ onig_region_resize(OnigRegion* region, int n)
return 0;
}
extern int
static int
onig_region_resize_clear(OnigRegion* region, int n)
{
int r;
@ -1019,7 +1021,7 @@ static int string_cmp_ic(OnigEncoding enc, int case_fold_flag,
#define IS_EMPTY_STR (str == end)
#define ON_STR_BEGIN(s) ((s) == str)
#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_CHECK(n) (s + (n) <= right_range)
#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_CHECK(n) (s + (n) <= end)
#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
@ -1072,7 +1074,7 @@ make_capture_history_tree(OnigCaptureTreeNode* node, OnigStackType** kp,
}
#endif
#ifdef USE_BACKREF_AT_LEVEL
#ifdef USE_BACKREF_WITH_LEVEL
static int mem_is_in_memp(int mem, int num, UChar* memp)
{
int i;
@ -1140,7 +1142,7 @@ static int backref_match_at_nested_level(regex_t* reg
return 0;
}
#endif /* USE_BACKREF_AT_LEVEL */
#endif /* USE_BACKREF_WITH_LEVEL */
#ifdef ONIG_DEBUG_STATISTICS
@ -1234,7 +1236,7 @@ typedef struct {
/* if sstart == str then set sprev to NULL. */
static int
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,
#endif
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));
bp = buf;
for (i = 0, q = s; i < 7 && q < end; i++) {
len = enc_len(encode, q);
len = enclen(encode, q);
while (len-- > 0) *bp++ = *q++;
}
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;
region = msa->region;
if (region) {
#ifdef USE_POSIX_REGION_OPTION
#ifdef USE_POSIX_API_REGION_OPTION
if (IS_POSIX_REGION(msa->options)) {
posix_regmatch_t* rmt = (posix_regmatch_t* )region;
@ -1351,7 +1353,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
}
else {
#endif /* USE_POSIX_REGION_OPTION */
#endif /* USE_POSIX_API_REGION_OPTION */
region->beg[0] = sstart - str;
region->end[0] = s - str;
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 */
#ifdef USE_POSIX_REGION_OPTION
#ifdef USE_POSIX_API_REGION_OPTION
} /* else IS_POSIX_REGION() */
#endif
} /* if (region) */
@ -1642,7 +1644,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
DATA_ENSURE(1);
if (BITSET_AT(((BitSetRef )p), *s) == 0) goto fail;
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;
break;
@ -1657,7 +1659,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
int mb_len;
DATA_ENSURE(1);
mb_len = enc_len(encode, s, end);
mb_len = enclen(encode, s, end);
DATA_ENSURE(mb_len);
ss = s;
s += mb_len;
@ -1697,7 +1699,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
DATA_ENSURE(1);
if (BITSET_AT(((BitSetRef )p), *s) != 0) goto fail;
p += SIZE_BITSET;
s += enc_len(encode, s, end);
s += enclen(encode, s, end);
MOP_OUT;
break;
@ -1715,7 +1717,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
{
OnigCodePoint code;
UChar *ss;
int mb_len = enc_len(encode, s, end);
int mb_len = enclen(encode, s, end);
if (! DATA_ENSURE_CHECK(mb_len)) {
DATA_ENSURE(1);
@ -1769,7 +1771,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
DATA_ENSURE(1);
GET_POINTER_INC(node, p);
mb_len = enc_len(encode, s, end);
mb_len = enclen(encode, s, end);
ss = s;
s += mb_len;
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);
DATA_ENSURE(1);
n = enc_len(encode, s, end);
n = enclen(encode, s, end);
DATA_ENSURE(n);
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
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);
DATA_ENSURE(1);
n = enc_len(encode, s, end);
n = enclen(encode, s, end);
DATA_ENSURE(n);
s += n;
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);
while (DATA_ENSURE_CHECK1) {
STACK_PUSH_ALT(p, s, sprev);
n = enc_len(encode, s, end);
n = enclen(encode, s, end);
DATA_ENSURE(n);
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
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);
while (DATA_ENSURE_CHECK1) {
STACK_PUSH_ALT(p, s, sprev);
n = enc_len(encode, s, end);
n = enclen(encode, s, end);
if (n > 1) {
DATA_ENSURE(n);
sprev = s;
@ -1830,7 +1832,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (*p == *s) {
STACK_PUSH_ALT(p + 1, s, sprev);
}
n = enc_len(encode, s, end);
n = enclen(encode, s, end);
DATA_ENSURE(n);
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
sprev = s;
@ -1845,7 +1847,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (*p == *s) {
STACK_PUSH_ALT(p + 1, s, sprev);
}
n = enc_len(encode, s, end);
n = enclen(encode, s, end);
if (n > 1) {
DATA_ENSURE(n);
sprev = s;
@ -1868,7 +1870,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (scv) goto fail;
STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem);
n = enc_len(encode, s);
n = enclen(encode, s);
DATA_ENSURE(n);
if (ONIGENC_IS_MBC_NEWLINE(encode, s, end)) goto fail;
sprev = s;
@ -1886,7 +1888,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (scv) goto fail;
STACK_PUSH_ALT_WITH_STATE_CHECK(p, s, sprev, mem);
n = enc_len(encode, s);
n = enclen(encode, s);
if (n > 1) {
DATA_ENSURE(n);
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))
goto fail;
s += enc_len(encode, s, end);
s += enclen(encode, s, end);
MOP_OUT;
break;
@ -1915,7 +1917,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (ONIGENC_IS_MBC_WORD(encode, s, end))
goto fail;
s += enc_len(encode, s, end);
s += enclen(encode, s, end);
MOP_OUT;
break;
@ -2043,14 +2045,14 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
#endif
}
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;
continue;
}
#ifdef USE_CRNL_AS_LINE_TERMINATOR
else if (ONIGENC_IS_MBC_CRNL(encode, s, end)) {
UChar* ss = s + enc_len(encode, s);
ss += enc_len(encode, ss);
UChar* ss = s + enclen(encode, s);
ss += enclen(encode, ss);
if (ON_STR_END(ss)) {
MOP_OUT;
continue;
@ -2157,7 +2159,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
DATA_ENSURE(n);
sprev = s;
STRING_CMP(pstart, s, n);
while (sprev + (len = enc_len(encode, sprev, end)) < s)
while (sprev + (len = enclen(encode, sprev, end)) < s)
sprev += len;
MOP_OUT;
@ -2189,7 +2191,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
DATA_ENSURE(n);
sprev = s;
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;
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);
if (is_fail) continue;
s = swork;
while (sprev + (len = enc_len(encode, sprev, end)) < s)
while (sprev + (len = enclen(encode, sprev, end)) < s)
sprev += len;
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);
if (is_fail) continue;
s = swork;
while (sprev + (len = enc_len(encode, sprev, end)) < s)
while (sprev + (len = enclen(encode, sprev, end)) < s)
sprev += len;
p += (SIZE_MEMNUM * (tlen - i - 1));
@ -2275,8 +2277,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
break;
#ifdef USE_BACKREF_AT_LEVEL
case OP_BACKREF_AT_LEVEL:
#ifdef USE_BACKREF_WITH_LEVEL
case OP_BACKREF_WITH_LEVEL:
{
int len;
OnigOptionType ic;
@ -2289,7 +2291,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
sprev = s;
if (backref_match_at_nested_level(reg, stk, stk_base, ic
, 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;
p += (SIZE_MEMNUM * tlen);
@ -2361,7 +2363,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
continue;
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);
{
int isnull;
@ -2389,7 +2391,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
int isnull;
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);
#else
STACK_NULL_CHECK_REC(isnull, mem, s);
@ -2760,7 +2762,7 @@ slow_search(OnigEncoding enc, UChar* target, UChar* target_end,
if (t == target_end)
return s;
}
s += enc_len(enc, s, end);
s += enclen(enc, s, end);
}
return (UChar* )NULL;
@ -2805,7 +2807,7 @@ slow_search_ic(OnigEncoding enc, int case_fold_flag,
s, text_end))
return s;
s += enc_len(enc, s, text_end);
s += enclen(enc, s, text_end);
}
return (UChar* )NULL;
@ -2903,7 +2905,7 @@ bm_search_notrev(regex_t* reg, const UChar* target, const UChar* target_end,
skip = reg->map[*se];
t = s;
do {
s += enc_len(reg->enc, s, end);
s += enclen(reg->enc, 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];
t = s;
do {
s += enc_len(reg->enc, s, end);
s += enclen(reg->enc, 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
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;
@ -3024,7 +3027,7 @@ map_search(OnigEncoding enc, UChar map[],
while (s < text_range) {
if (map[*s]) return (UChar* )s;
s += enc_len(enc, s, text_range);
s += enclen(enc, s, text_range);
}
return (UChar* )NULL;
}
@ -3086,7 +3089,7 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, On
#endif
if (region
#ifdef USE_POSIX_REGION_OPTION
#ifdef USE_POSIX_API_REGION_OPTION
&& !IS_POSIX_REGION(option)
#endif
) {
@ -3098,7 +3101,7 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at, On
if (r == 0) {
prev = (UChar* )onigenc_get_prev_char_head(reg->enc, str, at);
r = match_at(reg, str, end,
#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
end,
#endif
at, prev, &msa);
@ -3127,7 +3130,7 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
}
else {
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) {
retry_gate:
pprev = p;
p += enc_len(reg->enc, p, end);
p += enclen(reg->enc, p, end);
goto retry;
}
@ -3353,7 +3356,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
UChar *s, *prev;
OnigMatchArg msa;
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;
#endif
@ -3389,7 +3392,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
#endif
if (region
#ifdef USE_POSIX_REGION_OPTION
#ifdef USE_POSIX_API_REGION_OPTION
&& !IS_POSIX_REGION(option)
#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;
#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
#define MATCH_AND_RETURN_CHECK(upper_range) \
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 */ \
}
#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 */
@ -3604,7 +3607,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
while (s <= high) {
MATCH_AND_RETURN_CHECK(orig_range);
prev = s;
s += enc_len(reg->enc, s, end);
s += enclen(reg->enc, s, end);
}
} while (s < range);
goto mismatch;
@ -3617,11 +3620,11 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
do {
MATCH_AND_RETURN_CHECK(orig_range);
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) {
prev = s;
s += enc_len(reg->enc, s, end);
s += enclen(reg->enc, s, end);
}
} while (s < range);
goto mismatch;
@ -3632,7 +3635,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
do {
MATCH_AND_RETURN_CHECK(orig_range);
prev = s;
s += enc_len(reg->enc, s, end);
s += enclen(reg->enc, s, end);
} while (s < range);
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 */
#ifdef USE_MATCH_RANGE_IS_COMPLETE_RANGE
#ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
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
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,
then the region is not setted in match_at(). */
if (IS_FIND_NOT_EMPTY(reg->options) && region
#ifdef USE_POSIX_REGION_OPTION
#ifdef USE_POSIX_API_REGION_OPTION
&& !IS_POSIX_REGION(option)
#endif
) {

View file

@ -51,19 +51,19 @@
(defined(__ppc__) && defined(__APPLE__)) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD86) || \
defined(__mc68020__)
/* #define PLATFORM_UNALIGNED_WORD_ACCESS */
#define PLATFORM_UNALIGNED_WORD_ACCESS
#endif
/* config */
/* spec. config */
#define USE_NAMED_GROUP
#define USE_SUBEXP_CALL
#define USE_BACKREF_AT_LEVEL /* \k<name+n>, \k<name-n> */
#define USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK /* /(?:()|())*\2/ */
#define USE_BACKREF_WITH_LEVEL /* \k<name+n>, \k<name-n> */
#define USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT /* /(?:()|())*\2/ */
#define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
#define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
/* #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 */
#define USE_PARSE_TREE_NODE_RECYCLE
@ -75,6 +75,12 @@
#define INIT_MATCH_STACK_SIZE 160
#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 */
#ifndef RUBY_DEFINES_H
@ -236,7 +242,6 @@
#define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
#define NULL_UCHARP ((UChar* )0)
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
#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_ON_ALL(stats) (stats) = ~((BitStatusType )0)
#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 {\
if ((n) < BIT_STATUS_BITS_NUM)\
if ((n) < (int )BIT_STATUS_BITS_NUM) \
(stats) |= (1 << (n));\
else\
(stats) |= 1;\
} while (0)
#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));\
} while (0)
@ -353,7 +358,7 @@ typedef Bits* BitSetRef;
#define BITSET_CLEAR(bs) do {\
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)
#define BS_ROOM(bs,pos) (bs)[pos / BITS_IN_ROOM]
@ -520,7 +525,7 @@ enum OpCode {
OP_BACKREFN_IC,
OP_BACKREF_MULTI,
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_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_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 */

File diff suppressed because it is too large Load diff

View file

@ -213,7 +213,7 @@ typedef struct {
typedef struct {
NodeBase base;
int state;
int ref_num;
int group_num;
UChar* name;
UChar* name_end;
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_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_free_shared_cclass_table P_((void));
#ifdef ONIG_DEBUG
#ifdef USE_NAMED_GROUP

View file

@ -1,7 +1,7 @@
#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_RELEASE_CODE 20080103
#define RUBY_RELEASE_CODE 20080104
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2008
#define RUBY_RELEASE_MONTH 1
#define RUBY_RELEASE_DAY 3
#define RUBY_RELEASE_DAY 4
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];