mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* include/ruby/oniguruma.h: updated to follow Oniguruma 5.9.2.
* re.c (make_regexp): use onig_new() instead of onig_alloc_init(). * re.c (rb_reg_to_s): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e1c33162cf
commit
db37773e13
16 changed files with 116 additions and 171 deletions
|
@ -10,6 +10,13 @@ Mon Mar 1 17:42:45 2010 wanabe <s.wanabe@gmail.com>
|
||||||
|
|
||||||
* configure.in (mingw): do not detect snprintf/vsnprintf.
|
* configure.in (mingw): do not detect snprintf/vsnprintf.
|
||||||
|
|
||||||
|
Mon Mar 1 16:54:21 2010 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* include/ruby/oniguruma.h: updated to follow Oniguruma 5.9.2.
|
||||||
|
|
||||||
|
* re.c (make_regexp): use onig_new() instead of onig_alloc_init().
|
||||||
|
|
||||||
|
* re.c (rb_reg_to_s): ditto.
|
||||||
Sun Feb 28 21:32:36 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Feb 28 21:32:36 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/pty/pty.c (get_device_once): raise on error when fail is
|
* ext/pty/pty.c (get_device_once): raise on error when fail is
|
||||||
|
|
11
enc/euc_tw.c
11
enc/euc_tw.c
|
@ -2,7 +2,7 @@
|
||||||
euc_tw.c - Oniguruma (regular expression library)
|
euc_tw.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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
|
||||||
|
@ -169,15 +169,6 @@ euctw_mbc_case_fold(OnigCaseFoldType flag, const UChar** pp, const UChar* end,
|
||||||
pp, end, lower);
|
pp, end, lower);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
static int
|
|
||||||
euctw_is_mbc_ambiguous(OnigCaseFoldType flag,
|
|
||||||
const UChar** pp, const UChar* end, OnigEncoding enc)
|
|
||||||
{
|
|
||||||
return onigenc_mbn_is_mbc_ambiguous(enc, flag, pp, end);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
euctw_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
|
euctw_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
iso8859_5.c - Oniguruma (regular expression library)
|
iso8859_5.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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 @@
|
||||||
koi8_r.c - Oniguruma (regular expression library)
|
koi8_r.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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 @@
|
||||||
koi8_u.c - Oniguruma (regular expression library)
|
koi8_u.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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 @@
|
||||||
sjis.c - Oniguruma (regular expression library)
|
sjis.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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
|
||||||
|
@ -294,7 +294,7 @@ init_property_list(void)
|
||||||
static int
|
static int
|
||||||
property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)
|
property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)
|
||||||
{
|
{
|
||||||
st_data_t ctype;
|
hash_data_type ctype;
|
||||||
|
|
||||||
PROPERTY_LIST_INIT_CHECK;
|
PROPERTY_LIST_INIT_CHECK;
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ property_name_to_ctype(OnigEncoding enc, UChar* p, UChar* end)
|
||||||
return onigenc_minimum_property_name_to_ctype(enc, p, end);
|
return onigenc_minimum_property_name_to_ctype(enc, p, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctype;
|
return (int)ctype;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
unicode.c - Oniguruma (regular expression library)
|
unicode.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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 @@
|
||||||
utf_16be.c - Oniguruma (regular expression library)
|
utf_16be.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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 @@
|
||||||
utf_16le.c - Oniguruma (regular expression library)
|
utf_16le.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
oniguruma.h - Oniguruma (regular expression library)
|
oniguruma.h - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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
|
||||||
|
@ -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 1
|
#define ONIGURUMA_VERSION_TEENY 2
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
# ifndef HAVE_PROTOTYPES
|
# ifndef HAVE_PROTOTYPES
|
||||||
|
@ -693,10 +693,16 @@ void onig_set_verb_warn_func P_((OnigWarnFunc f));
|
||||||
ONIG_EXTERN
|
ONIG_EXTERN
|
||||||
int onig_new P_((OnigRegex*, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, const OnigSyntaxType* syntax, OnigErrorInfo* einfo));
|
int onig_new P_((OnigRegex*, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, const OnigSyntaxType* syntax, OnigErrorInfo* einfo));
|
||||||
ONIG_EXTERN
|
ONIG_EXTERN
|
||||||
|
int onig_reg_init P_((regex_t* reg, OnigOptionType option, OnigCaseFoldType case_fold_flag, OnigEncoding enc, const OnigSyntaxType* syntax));
|
||||||
|
ONIG_EXTERN
|
||||||
|
int onig_new_without_alloc P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
|
||||||
|
ONIG_EXTERN
|
||||||
int onig_new_deluxe P_((OnigRegex* reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
|
int onig_new_deluxe P_((OnigRegex* reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
|
||||||
ONIG_EXTERN
|
ONIG_EXTERN
|
||||||
void onig_free P_((OnigRegex));
|
void onig_free P_((OnigRegex));
|
||||||
ONIG_EXTERN
|
ONIG_EXTERN
|
||||||
|
void onig_free_body P_((OnigRegex));
|
||||||
|
ONIG_EXTERN
|
||||||
int onig_recompile P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
|
int onig_recompile P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
|
||||||
ONIG_EXTERN
|
ONIG_EXTERN
|
||||||
int onig_recompile_deluxe P_((OnigRegex reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
|
int onig_recompile_deluxe P_((OnigRegex reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
|
||||||
|
|
28
re.c
28
re.c
|
@ -521,15 +521,11 @@ rb_reg_to_s(VALUE re)
|
||||||
if (*ptr == ':' && ptr[len-1] == ')') {
|
if (*ptr == ':' && ptr[len-1] == ')') {
|
||||||
int r;
|
int r;
|
||||||
Regexp *rp;
|
Regexp *rp;
|
||||||
r = onig_alloc_init(&rp, ONIG_OPTION_DEFAULT,
|
|
||||||
ONIGENC_CASE_FOLD_DEFAULT,
|
++ptr;
|
||||||
rb_enc_get(re),
|
len -= 2;
|
||||||
OnigDefaultSyntax);
|
err = onig_new(&rp, ptr, ptr + len, ONIG_OPTION_DEFAULT,
|
||||||
if (r == 0) {
|
rb_enc_get(re), OnigDefaultSyntax, NULL);
|
||||||
++ptr;
|
|
||||||
len -= 2;
|
|
||||||
err = (onig_compile(rp, ptr, ptr + len, NULL, NULL, 0) != 0);
|
|
||||||
}
|
|
||||||
onig_free(rp);
|
onig_free(rp);
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -745,18 +741,10 @@ make_regexp(const char *s, long len, rb_encoding *enc, int flags, onig_errmsg_bu
|
||||||
from that.
|
from that.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
r = onig_alloc_init(&rp, flags, ONIGENC_CASE_FOLD_DEFAULT,
|
r = onig_new(&rp, (UChar*)s, (UChar*)(s + len), flags,
|
||||||
enc, OnigDefaultSyntax);
|
enc, OnigDefaultSyntax, &einfo);
|
||||||
if (r) {
|
if (r) {
|
||||||
onig_error_code_to_str((UChar*)err, r);
|
onig_error_code_to_str((UChar*)err, r, &einfo);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = onig_compile(rp, (UChar*)s, (UChar*)(s + len), &einfo, sourcefile, sourceline);
|
|
||||||
|
|
||||||
if (r != 0) {
|
|
||||||
onig_free(rp);
|
|
||||||
(void )onig_error_code_to_str((UChar*)err, r, &einfo);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return rp;
|
return rp;
|
||||||
|
|
163
regcomp.c
163
regcomp.c
|
@ -2,7 +2,7 @@
|
||||||
regcomp.c - Oniguruma (regular expression library)
|
regcomp.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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
|
||||||
|
@ -5194,19 +5194,21 @@ print_optimize_info(FILE* f, regex_t* reg)
|
||||||
#endif /* ONIG_DEBUG */
|
#endif /* ONIG_DEBUG */
|
||||||
|
|
||||||
|
|
||||||
static void
|
extern void
|
||||||
onig_free_body(regex_t* reg)
|
onig_free_body(regex_t* reg)
|
||||||
{
|
{
|
||||||
if (IS_NOT_NULL(reg->p)) xfree(reg->p);
|
if (IS_NOT_NULL(reg)) {
|
||||||
if (IS_NOT_NULL(reg->exact)) xfree(reg->exact);
|
if (IS_NOT_NULL(reg->p)) xfree(reg->p);
|
||||||
if (IS_NOT_NULL(reg->int_map)) xfree(reg->int_map);
|
if (IS_NOT_NULL(reg->exact)) xfree(reg->exact);
|
||||||
if (IS_NOT_NULL(reg->int_map_backward)) xfree(reg->int_map_backward);
|
if (IS_NOT_NULL(reg->int_map)) xfree(reg->int_map);
|
||||||
if (IS_NOT_NULL(reg->repeat_range)) xfree(reg->repeat_range);
|
if (IS_NOT_NULL(reg->int_map_backward)) xfree(reg->int_map_backward);
|
||||||
if (IS_NOT_NULL(reg->chain)) onig_free(reg->chain);
|
if (IS_NOT_NULL(reg->repeat_range)) xfree(reg->repeat_range);
|
||||||
|
if (IS_NOT_NULL(reg->chain)) onig_free(reg->chain);
|
||||||
|
|
||||||
#ifdef USE_NAMED_GROUP
|
#ifdef USE_NAMED_GROUP
|
||||||
onig_names_free(reg);
|
onig_names_free(reg);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
|
@ -5280,84 +5282,6 @@ onig_chain_reduce(regex_t* reg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
extern int
|
|
||||||
onig_clone(regex_t** to, regex_t* from)
|
|
||||||
{
|
|
||||||
int r, size;
|
|
||||||
regex_t* reg;
|
|
||||||
|
|
||||||
#ifdef USE_MULTI_THREAD_SYSTEM
|
|
||||||
if (ONIG_STATE(from) >= ONIG_STATE_NORMAL) {
|
|
||||||
ONIG_STATE_INC(from);
|
|
||||||
if (IS_NOT_NULL(from->chain) && ONIG_STATE(reg) == ONIG_STATE_NORMAL) {
|
|
||||||
onig_chain_reduce(from);
|
|
||||||
ONIG_STATE_INC(from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int n = 0;
|
|
||||||
while (ONIG_STATE(from) < ONIG_STATE_NORMAL) {
|
|
||||||
if (++n > THREAD_PASS_LIMIT_COUNT)
|
|
||||||
return ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT;
|
|
||||||
THREAD_PASS;
|
|
||||||
}
|
|
||||||
ONIG_STATE_INC(from);
|
|
||||||
}
|
|
||||||
#endif /* USE_MULTI_THREAD_SYSTEM */
|
|
||||||
|
|
||||||
r = onig_alloc_init(®, ONIG_OPTION_NONE, ONIGENC_CASE_FOLD_DEFAULT,
|
|
||||||
from->enc, ONIG_SYNTAX_DEFAULT);
|
|
||||||
if (r != 0) {
|
|
||||||
ONIG_STATE_DEC(from);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
xmemcpy(reg, from, sizeof(onig_t));
|
|
||||||
reg->chain = (regex_t* )NULL;
|
|
||||||
reg->state = ONIG_STATE_NORMAL;
|
|
||||||
|
|
||||||
if (from->p) {
|
|
||||||
reg->p = (UChar* )xmalloc(reg->alloc);
|
|
||||||
if (IS_NULL(reg->p)) goto mem_error;
|
|
||||||
xmemcpy(reg->p, from->p, reg->alloc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (from->exact) {
|
|
||||||
reg->exact = (UChar* )xmalloc(from->exact_end - from->exact);
|
|
||||||
if (IS_NULL(reg->exact)) goto mem_error;
|
|
||||||
reg->exact_end = reg->exact + (from->exact_end - from->exact);
|
|
||||||
xmemcpy(reg->exact, from->exact, reg->exact_end - reg->exact);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (from->int_map) {
|
|
||||||
size = sizeof(int) * ONIG_CHAR_TABLE_SIZE;
|
|
||||||
reg->int_map = (int* )xmalloc(size);
|
|
||||||
if (IS_NULL(reg->int_map)) goto mem_error;
|
|
||||||
xmemcpy(reg->int_map, from->int_map, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (from->int_map_backward) {
|
|
||||||
size = sizeof(int) * ONIG_CHAR_TABLE_SIZE;
|
|
||||||
reg->int_map_backward = (int* )xmalloc(size);
|
|
||||||
if (IS_NULL(reg->int_map_backward)) goto mem_error;
|
|
||||||
xmemcpy(reg->int_map_backward, from->int_map_backward, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_NAMED_GROUP
|
|
||||||
reg->name_table = names_clone(from); /* names_clone is not implemented */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ONIG_STATE_DEC(from);
|
|
||||||
*to = reg;
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
mem_error:
|
|
||||||
ONIG_STATE_DEC(from);
|
|
||||||
return ONIGERR_MEMORY;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ONIG_DEBUG
|
#ifdef ONIG_DEBUG
|
||||||
static void print_compiled_byte_code_list P_((FILE* f, regex_t* reg));
|
static void print_compiled_byte_code_list P_((FILE* f, regex_t* reg));
|
||||||
#endif
|
#endif
|
||||||
|
@ -5378,6 +5302,8 @@ onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end,
|
||||||
UnsetAddrList uslist;
|
UnsetAddrList uslist;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (IS_NOT_NULL(einfo)) einfo->par = (UChar* )NULL;
|
||||||
|
|
||||||
scan_env.sourcefile = sourcefile;
|
scan_env.sourcefile = sourcefile;
|
||||||
scan_env.sourceline = sourceline;
|
scan_env.sourceline = sourceline;
|
||||||
reg->state = ONIG_STATE_COMPILING;
|
reg->state = ONIG_STATE_COMPILING;
|
||||||
|
@ -5577,13 +5503,16 @@ onig_recompile(regex_t* reg, const UChar* pattern, const UChar* pattern_end,
|
||||||
static int onig_inited = 0;
|
static int onig_inited = 0;
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
onig_alloc_init(regex_t** reg, OnigOptionType option,
|
onig_reg_init(regex_t* reg, OnigOptionType option,
|
||||||
OnigCaseFoldType case_fold_flag,
|
OnigCaseFoldType case_fold_flag,
|
||||||
OnigEncoding enc, const OnigSyntaxType* syntax)
|
OnigEncoding enc, const OnigSyntaxType* syntax)
|
||||||
{
|
{
|
||||||
if (! onig_inited)
|
if (! onig_inited)
|
||||||
onig_init();
|
onig_init();
|
||||||
|
|
||||||
|
if (IS_NULL(reg))
|
||||||
|
return ONIGERR_INVALID_ARGUMENT;
|
||||||
|
|
||||||
if (ONIGENC_IS_UNDEF(enc))
|
if (ONIGENC_IS_UNDEF(enc))
|
||||||
return ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED;
|
return ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED;
|
||||||
|
|
||||||
|
@ -5592,9 +5521,7 @@ onig_alloc_init(regex_t** reg, OnigOptionType option,
|
||||||
return ONIGERR_INVALID_COMBINATION_OF_OPTIONS;
|
return ONIGERR_INVALID_COMBINATION_OF_OPTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
*reg = (regex_t* )xmalloc(sizeof(regex_t));
|
(reg)->state = ONIG_STATE_MODIFY;
|
||||||
if (IS_NULL(*reg)) return ONIGERR_MEMORY;
|
|
||||||
(*reg)->state = ONIG_STATE_MODIFY;
|
|
||||||
|
|
||||||
if ((option & ONIG_OPTION_NEGATE_SINGLELINE) != 0) {
|
if ((option & ONIG_OPTION_NEGATE_SINGLELINE) != 0) {
|
||||||
option |= syntax->options;
|
option |= syntax->options;
|
||||||
|
@ -5603,24 +5530,38 @@ onig_alloc_init(regex_t** reg, OnigOptionType option,
|
||||||
else
|
else
|
||||||
option |= syntax->options;
|
option |= syntax->options;
|
||||||
|
|
||||||
(*reg)->enc = enc;
|
(reg)->enc = enc;
|
||||||
(*reg)->options = option;
|
(reg)->options = option;
|
||||||
(*reg)->syntax = syntax;
|
(reg)->syntax = syntax;
|
||||||
(*reg)->optimize = 0;
|
(reg)->optimize = 0;
|
||||||
(*reg)->exact = (UChar* )NULL;
|
(reg)->exact = (UChar* )NULL;
|
||||||
(*reg)->int_map = (int* )NULL;
|
(reg)->int_map = (int* )NULL;
|
||||||
(*reg)->int_map_backward = (int* )NULL;
|
(reg)->int_map_backward = (int* )NULL;
|
||||||
(*reg)->chain = (regex_t* )NULL;
|
(reg)->chain = (regex_t* )NULL;
|
||||||
|
|
||||||
(*reg)->p = (UChar* )NULL;
|
(reg)->p = (UChar* )NULL;
|
||||||
(*reg)->alloc = 0;
|
(reg)->alloc = 0;
|
||||||
(*reg)->used = 0;
|
(reg)->used = 0;
|
||||||
(*reg)->name_table = (void* )NULL;
|
(reg)->name_table = (void* )NULL;
|
||||||
|
|
||||||
(*reg)->case_fold_flag = case_fold_flag;
|
(reg)->case_fold_flag = case_fold_flag;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int
|
||||||
|
onig_new_without_alloc(regex_t* reg, const UChar* pattern,
|
||||||
|
const UChar* pattern_end, OnigOptionType option, OnigEncoding enc,
|
||||||
|
OnigSyntaxType* syntax, OnigErrorInfo* einfo)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = onig_reg_init(reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax);
|
||||||
|
if (r) return r;
|
||||||
|
|
||||||
|
r = onig_compile(reg, pattern, pattern_end, einfo, NULL, 0);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
|
onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
|
||||||
OnigOptionType option, OnigEncoding enc, const OnigSyntaxType* syntax,
|
OnigOptionType option, OnigEncoding enc, const OnigSyntaxType* syntax,
|
||||||
|
@ -5628,20 +5569,22 @@ onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (IS_NOT_NULL(einfo)) einfo->par = (UChar* )NULL;
|
*reg = (regex_t* )xmalloc(sizeof(regex_t));
|
||||||
|
if (IS_NULL(*reg)) return ONIGERR_MEMORY;
|
||||||
|
|
||||||
r = onig_alloc_init(reg, option, ONIGENC_CASE_FOLD_DEFAULT,
|
r = onig_reg_init(*reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax);
|
||||||
enc, syntax);
|
if (r) goto err;
|
||||||
if (r) return r;
|
|
||||||
|
|
||||||
r = onig_compile(*reg, pattern, pattern_end, einfo, NULL, 0);
|
r = onig_compile(*reg, pattern, pattern_end, einfo, NULL, 0);
|
||||||
if (r) {
|
if (r) {
|
||||||
|
err:
|
||||||
onig_free(*reg);
|
onig_free(*reg);
|
||||||
*reg = NULL;
|
*reg = NULL;
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
onig_init(void)
|
onig_init(void)
|
||||||
{
|
{
|
||||||
|
|
5
regenc.h
5
regenc.h
|
@ -4,7 +4,7 @@
|
||||||
regenc.h - Oniguruma (regular expression library)
|
regenc.h - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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
|
||||||
|
@ -153,6 +153,9 @@ ONIG_EXTERN int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFold
|
||||||
ONIG_EXTERN int onigenc_unicode_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc));
|
ONIG_EXTERN int onigenc_unicode_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc));
|
||||||
|
|
||||||
|
|
||||||
|
#define UTF16_IS_SURROGATE_FIRST(c) (((c) & 0xfc) == 0xd8)
|
||||||
|
#define UTF16_IS_SURROGATE_SECOND(c) (((c) & 0xfc) == 0xdc)
|
||||||
|
|
||||||
#define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \
|
#define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \
|
||||||
OnigEncISO_8859_1_ToLowerCaseTable[c]
|
OnigEncISO_8859_1_ToLowerCaseTable[c]
|
||||||
#define ONIGENC_ISO_8859_1_TO_UPPER_CASE(c) \
|
#define ONIGENC_ISO_8859_1_TO_UPPER_CASE(c) \
|
||||||
|
|
24
regexec.c
24
regexec.c
|
@ -2,7 +2,7 @@
|
||||||
regexec.c - Oniguruma (regular expression library)
|
regexec.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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
|
||||||
|
@ -2914,11 +2914,10 @@ bm_search_notrev(regex_t* reg, const UChar* target, const UChar* target_end,
|
||||||
while (s < end) {
|
while (s < end) {
|
||||||
p = se = s + tlen1;
|
p = se = s + tlen1;
|
||||||
t = tail;
|
t = tail;
|
||||||
while (t >= target && *p == *t) {
|
while (*p == *t) {
|
||||||
p--; t--;
|
if (t == target) return (UChar* )s;
|
||||||
|
p--; t--;
|
||||||
}
|
}
|
||||||
if (t < target) return (UChar* )s;
|
|
||||||
|
|
||||||
skip = reg->map[*se];
|
skip = reg->map[*se];
|
||||||
t = s;
|
t = s;
|
||||||
do {
|
do {
|
||||||
|
@ -2930,11 +2929,10 @@ bm_search_notrev(regex_t* reg, const UChar* target, const UChar* target_end,
|
||||||
while (s < end) {
|
while (s < end) {
|
||||||
p = se = s + tlen1;
|
p = se = s + tlen1;
|
||||||
t = tail;
|
t = tail;
|
||||||
while (t >= target && *p == *t) {
|
while (*p == *t) {
|
||||||
p--; t--;
|
if (t == target) return (UChar* )s;
|
||||||
|
p--; t--;
|
||||||
}
|
}
|
||||||
if (t < target) return (UChar* )s;
|
|
||||||
|
|
||||||
skip = reg->int_map[*se];
|
skip = reg->int_map[*se];
|
||||||
t = s;
|
t = s;
|
||||||
do {
|
do {
|
||||||
|
@ -2963,10 +2961,10 @@ bm_search(regex_t* reg, const UChar* target, const UChar* target_end,
|
||||||
while (s < end) {
|
while (s < end) {
|
||||||
p = s;
|
p = s;
|
||||||
t = tail;
|
t = tail;
|
||||||
while (t >= target && *p == *t) {
|
while (*p == *t) {
|
||||||
|
if (t == target) return (UChar* )p;
|
||||||
p--; t--;
|
p--; t--;
|
||||||
}
|
}
|
||||||
if (t < target) return (UChar* )(p + 1);
|
|
||||||
s += reg->map[*s];
|
s += reg->map[*s];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2974,10 +2972,10 @@ bm_search(regex_t* reg, const UChar* target, const UChar* target_end,
|
||||||
while (s < end) {
|
while (s < end) {
|
||||||
p = s;
|
p = s;
|
||||||
t = tail;
|
t = tail;
|
||||||
while (t >= target && *p == *t) {
|
while (*p == *t) {
|
||||||
|
if (t == target) return (UChar* )p;
|
||||||
p--; t--;
|
p--; t--;
|
||||||
}
|
}
|
||||||
if (t < target) return (UChar* )(p + 1);
|
|
||||||
s += reg->int_map[*s];
|
s += reg->int_map[*s];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
regint.h
3
regint.h
|
@ -4,7 +4,7 @@
|
||||||
regint.h - Oniguruma (regular expression library)
|
regint.h - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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
|
||||||
|
@ -799,7 +799,6 @@ extern void onig_print_statistics P_((FILE* f));
|
||||||
extern UChar* onig_error_code_to_format P_((int code));
|
extern UChar* onig_error_code_to_format P_((int code));
|
||||||
extern void onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...));
|
extern void onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...));
|
||||||
extern int onig_bbuf_init P_((BBuf* buf, int size));
|
extern int onig_bbuf_init P_((BBuf* buf, int size));
|
||||||
extern int onig_alloc_init P_((regex_t** reg, OnigOptionType option, OnigCaseFoldType case_fold_flag, OnigEncoding enc, const OnigSyntaxType* syntax));
|
|
||||||
extern int onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo, const char *sourcefile, int sourceline));
|
extern int onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo, const char *sourcefile, int sourceline));
|
||||||
extern void onig_chain_reduce P_((regex_t* reg));
|
extern void onig_chain_reduce P_((regex_t* reg));
|
||||||
extern void onig_chain_link_add P_((regex_t* to, regex_t* add));
|
extern void onig_chain_link_add P_((regex_t* to, regex_t* add));
|
||||||
|
|
18
regparse.c
18
regparse.c
|
@ -3,7 +3,7 @@
|
||||||
regparse.c - Oniguruma (regular expression library)
|
regparse.c - Oniguruma (regular expression library)
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2002-2007 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
* Copyright (c) 2002-2008 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
|
||||||
|
@ -794,6 +794,7 @@ name_add(regex_t* reg, UChar* name, UChar* name_end, int backref, ScanEnv* env)
|
||||||
e = &(t->e[t->num]);
|
e = &(t->e[t->num]);
|
||||||
t->num++;
|
t->num++;
|
||||||
e->name = strdup_with_null(reg->enc, name, name_end);
|
e->name = strdup_with_null(reg->enc, name, name_end);
|
||||||
|
if (IS_NULL(e->name)) return ONIGERR_MEMORY;
|
||||||
e->name_len = name_end - name;
|
e->name_len = name_end - name;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -5499,7 +5500,10 @@ parse_exp(Node** np, OnigToken* tok, int term,
|
||||||
CHECK_NULL_RETURN_MEMERR(qn);
|
CHECK_NULL_RETURN_MEMERR(qn);
|
||||||
NQTFR(qn)->greedy = tok->u.repeat.greedy;
|
NQTFR(qn)->greedy = tok->u.repeat.greedy;
|
||||||
r = set_quantifier(qn, *targetp, group, env);
|
r = set_quantifier(qn, *targetp, group, env);
|
||||||
if (r < 0) return r;
|
if (r < 0) {
|
||||||
|
onig_node_free(qn);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
if (tok->u.repeat.possessive != 0) {
|
if (tok->u.repeat.possessive != 0) {
|
||||||
Node* en;
|
Node* en;
|
||||||
|
@ -5522,9 +5526,15 @@ parse_exp(Node** np, OnigToken* tok, int term,
|
||||||
Node *tmp;
|
Node *tmp;
|
||||||
|
|
||||||
*targetp = node_new_list(*targetp, NULL);
|
*targetp = node_new_list(*targetp, NULL);
|
||||||
CHECK_NULL_RETURN_MEMERR(*targetp);
|
if (IS_NULL(*targetp)) {
|
||||||
|
onig_node_free(qn);
|
||||||
|
return ONIGERR_MEMORY;
|
||||||
|
}
|
||||||
tmp = NCDR(*targetp) = node_new_list(qn, NULL);
|
tmp = NCDR(*targetp) = node_new_list(qn, NULL);
|
||||||
CHECK_NULL_RETURN_MEMERR(tmp);
|
if (IS_NULL(tmp)) {
|
||||||
|
onig_node_free(qn);
|
||||||
|
return ONIGERR_MEMORY;
|
||||||
|
}
|
||||||
targetp = &(NCAR(tmp));
|
targetp = &(NCAR(tmp));
|
||||||
}
|
}
|
||||||
goto re_entry;
|
goto re_entry;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue