2016-12-10 12:47:04 -05:00
|
|
|
#ifndef ONIGMO_REGINT_H
|
|
|
|
#define ONIGMO_REGINT_H
|
2004-03-05 10:31:51 -05:00
|
|
|
/**********************************************************************
|
2012-02-17 02:42:23 -05:00
|
|
|
regint.h - Onigmo (Oniguruma-mod) (regular expression library)
|
2004-03-05 10:31:51 -05:00
|
|
|
**********************************************************************/
|
* ascii.c, euc_jp.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, utf8.c:
imported Oni Guruma 3.4.0.
* parse.y, re.c: Now mbclen() takes unsigned char as its argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-04 09:43:08 -05:00
|
|
|
/*-
|
2015-11-26 03:31:27 -05:00
|
|
|
* Copyright (c) 2002-2013 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
|
2016-12-10 12:47:04 -05:00
|
|
|
* Copyright (c) 2011-2016 K.Takata <kentkt AT csc DOT jp>
|
* ascii.c, euc_jp.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, utf8.c:
imported Oni Guruma 3.4.0.
* parse.y, re.c: Now mbclen() takes unsigned char as its argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-04 09:43:08 -05:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
/* for debug */
|
|
|
|
/* #define ONIG_DEBUG_PARSE_TREE */
|
|
|
|
/* #define ONIG_DEBUG_COMPILE */
|
|
|
|
/* #define ONIG_DEBUG_SEARCH */
|
|
|
|
/* #define ONIG_DEBUG_MATCH */
|
2016-12-10 12:47:04 -05:00
|
|
|
/* #define ONIG_DEBUG_MEMLEAK */
|
2004-03-05 10:31:51 -05:00
|
|
|
/* #define ONIG_DONT_OPTIMIZE */
|
|
|
|
|
|
|
|
/* for byte-code statistical data. */
|
|
|
|
/* #define ONIG_DEBUG_STATISTICS */
|
|
|
|
|
|
|
|
#if defined(ONIG_DEBUG_PARSE_TREE) || defined(ONIG_DEBUG_MATCH) || \
|
* ascii.c, euc_jp.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, utf8.c:
imported Oni Guruma 3.4.0.
* parse.y, re.c: Now mbclen() takes unsigned char as its argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-04 09:43:08 -05:00
|
|
|
defined(ONIG_DEBUG_SEARCH) || defined(ONIG_DEBUG_COMPILE) || \
|
2016-12-10 12:47:04 -05:00
|
|
|
defined(ONIG_DEBUG_STATISTICS) || defined(ONIG_DEBUG_MEMLEAK)
|
|
|
|
# ifndef ONIG_DEBUG
|
|
|
|
# define ONIG_DEBUG
|
|
|
|
# endif
|
2004-03-05 10:31:51 -05:00
|
|
|
#endif
|
|
|
|
|
2016-01-15 06:25:29 -05:00
|
|
|
#ifndef UNALIGNED_WORD_ACCESS
|
2016-12-10 12:47:04 -05:00
|
|
|
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
|
|
|
|
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
|
2020-08-13 13:15:54 -04:00
|
|
|
defined(__powerpc64__) || defined(__aarch64__) || \
|
2016-12-10 12:47:04 -05:00
|
|
|
defined(__mc68020__)
|
|
|
|
# define UNALIGNED_WORD_ACCESS 1
|
|
|
|
# else
|
|
|
|
# define UNALIGNED_WORD_ACCESS 0
|
|
|
|
# endif
|
2016-01-15 06:25:29 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if UNALIGNED_WORD_ACCESS
|
2016-12-10 12:47:04 -05:00
|
|
|
# define PLATFORM_UNALIGNED_WORD_ACCESS
|
2004-03-05 10:31:51 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* config */
|
|
|
|
/* spec. config */
|
|
|
|
#define USE_NAMED_GROUP
|
|
|
|
#define USE_SUBEXP_CALL
|
2012-02-17 02:42:23 -05:00
|
|
|
#define USE_PERL_SUBEXP_CALL
|
|
|
|
#define USE_CAPITAL_P_NAMED_GROUP
|
2008-01-03 10:55:04 -05:00
|
|
|
#define USE_BACKREF_WITH_LEVEL /* \k<name+n>, \k<name-n> */
|
|
|
|
#define USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT /* /(?:()|())*\2/ */
|
2004-03-05 10:31:51 -05:00
|
|
|
#define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
|
|
|
|
#define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
|
2008-01-03 10:55:04 -05:00
|
|
|
/* !!! moved to regenc.h. */ /* #define USE_CRNL_AS_LINE_TERMINATOR */
|
2012-02-17 02:42:23 -05:00
|
|
|
#define USE_NO_INVALID_QUANTIFIER
|
2006-02-04 07:31:19 -05:00
|
|
|
|
2004-03-05 10:31:51 -05:00
|
|
|
/* internal config */
|
2016-12-10 12:47:04 -05:00
|
|
|
/* #define USE_OP_PUSH_OR_JUMP_EXACT */
|
2007-07-23 05:39:30 -04:00
|
|
|
#define USE_QTFR_PEEK_NEXT
|
|
|
|
#define USE_ST_LIBRARY
|
2012-02-17 02:42:23 -05:00
|
|
|
#define USE_SUNDAY_QUICK_SEARCH
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
#define INIT_MATCH_STACK_SIZE 160
|
2004-04-27 12:20:02 -04:00
|
|
|
#define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */
|
2016-12-10 12:47:04 -05:00
|
|
|
#define DEFAULT_PARSE_DEPTH_LIMIT 4096
|
|
|
|
|
|
|
|
#define OPT_EXACT_MAXLEN 24
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2012-02-17 02:42:23 -05:00
|
|
|
/* check config */
|
|
|
|
#if defined(USE_PERL_SUBEXP_CALL) || defined(USE_CAPITAL_P_NAMED_GROUP)
|
2016-12-10 12:47:04 -05:00
|
|
|
# if !defined(USE_NAMED_GROUP) || !defined(USE_SUBEXP_CALL)
|
|
|
|
# error USE_NAMED_GROUP and USE_SUBEXP_CALL must be defined.
|
|
|
|
# endif
|
2012-02-17 02:42:23 -05:00
|
|
|
#endif
|
|
|
|
|
2008-01-03 10:55:04 -05:00
|
|
|
#if defined(__GNUC__)
|
2016-12-10 12:47:04 -05:00
|
|
|
# define ARG_UNUSED __attribute__ ((unused))
|
2008-01-03 10:55:04 -05:00
|
|
|
#else
|
2016-12-10 12:47:04 -05:00
|
|
|
# define ARG_UNUSED
|
2008-01-03 10:55:04 -05:00
|
|
|
#endif
|
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
#if !defined(RUBY) && defined(RUBY_EXPORT)
|
|
|
|
# define RUBY
|
2007-05-24 22:13:18 -04:00
|
|
|
#endif
|
2016-12-10 12:47:04 -05:00
|
|
|
#ifdef RUBY
|
|
|
|
# ifndef RUBY_DEFINES_H
|
|
|
|
# include "ruby/ruby.h"
|
|
|
|
# undef xmalloc
|
|
|
|
# undef xrealloc
|
|
|
|
# undef xcalloc
|
|
|
|
# undef xfree
|
|
|
|
# endif
|
|
|
|
#else /* RUBY */
|
|
|
|
# include "config.h"
|
|
|
|
# if SIZEOF_LONG_LONG > 0
|
|
|
|
# define LONG_LONG long long
|
|
|
|
# endif
|
|
|
|
#endif /* RUBY */
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2014-07-15 23:27:25 -04:00
|
|
|
|
|
|
|
/* */
|
|
|
|
/* escape other system UChar definition */
|
2007-05-22 21:32:08 -04:00
|
|
|
#ifdef ONIG_ESCAPE_UCHAR_COLLISION
|
2016-12-10 12:47:04 -05:00
|
|
|
# undef ONIG_ESCAPE_UCHAR_COLLISION
|
2007-05-22 21:32:08 -04:00
|
|
|
#endif
|
2014-07-15 23:27:25 -04:00
|
|
|
|
2012-02-17 02:42:23 -05:00
|
|
|
#define USE_WORD_BEGIN_END /* "\<": word-begin, "\>": word-end */
|
2016-12-10 12:47:04 -05:00
|
|
|
#ifdef RUBY
|
|
|
|
# undef USE_CAPTURE_HISTORY
|
|
|
|
#else
|
|
|
|
# define USE_CAPTURE_HISTORY
|
|
|
|
#endif
|
2004-03-05 10:31:51 -05:00
|
|
|
#define USE_VARIABLE_META_CHARS
|
2007-05-22 21:32:08 -04:00
|
|
|
#define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
|
2006-08-27 08:58:22 -04:00
|
|
|
/* #define USE_COMBINATION_EXPLOSION_CHECK */ /* (X*)* */
|
2012-02-17 02:42:23 -05:00
|
|
|
|
2014-07-15 23:27:25 -04:00
|
|
|
|
2007-05-22 21:32:08 -04:00
|
|
|
#ifndef xmalloc
|
2016-12-10 12:47:04 -05:00
|
|
|
# define xmalloc malloc
|
|
|
|
# define xrealloc realloc
|
|
|
|
# define xcalloc calloc
|
|
|
|
# define xfree free
|
2007-05-22 21:32:08 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RUBY
|
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
# define CHECK_INTERRUPT_IN_MATCH_AT rb_thread_check_ints()
|
|
|
|
# define onig_st_init_table st_init_table
|
|
|
|
# define onig_st_init_table_with_size st_init_table_with_size
|
|
|
|
# define onig_st_init_numtable st_init_numtable
|
|
|
|
# define onig_st_init_numtable_with_size st_init_numtable_with_size
|
|
|
|
# define onig_st_init_strtable st_init_strtable
|
|
|
|
# define onig_st_init_strtable_with_size st_init_strtable_with_size
|
|
|
|
# define onig_st_delete st_delete
|
|
|
|
# define onig_st_delete_safe st_delete_safe
|
|
|
|
# define onig_st_insert st_insert
|
|
|
|
# define onig_st_lookup st_lookup
|
|
|
|
# define onig_st_foreach st_foreach
|
|
|
|
# define onig_st_add_direct st_add_direct
|
|
|
|
# define onig_st_free_table st_free_table
|
|
|
|
# define onig_st_cleanup_safe st_cleanup_safe
|
|
|
|
# define onig_st_copy st_copy
|
|
|
|
# define onig_st_nothing_key_clone st_nothing_key_clone
|
|
|
|
# define onig_st_nothing_key_free st_nothing_key_free
|
|
|
|
# define onig_st_is_member st_is_member
|
|
|
|
|
|
|
|
# define USE_UPPER_CASE_TABLE
|
|
|
|
#else /* RUBY */
|
|
|
|
|
|
|
|
# define CHECK_INTERRUPT_IN_MATCH_AT
|
|
|
|
|
|
|
|
# define st_init_table onig_st_init_table
|
|
|
|
# define st_init_table_with_size onig_st_init_table_with_size
|
|
|
|
# define st_init_numtable onig_st_init_numtable
|
|
|
|
# define st_init_numtable_with_size onig_st_init_numtable_with_size
|
|
|
|
# define st_init_strtable onig_st_init_strtable
|
|
|
|
# define st_init_strtable_with_size onig_st_init_strtable_with_size
|
|
|
|
# define st_delete onig_st_delete
|
|
|
|
# define st_delete_safe onig_st_delete_safe
|
|
|
|
# define st_insert onig_st_insert
|
|
|
|
# define st_lookup onig_st_lookup
|
|
|
|
# define st_foreach onig_st_foreach
|
|
|
|
# define st_add_direct onig_st_add_direct
|
|
|
|
# define st_free_table onig_st_free_table
|
|
|
|
# define st_cleanup_safe onig_st_cleanup_safe
|
|
|
|
# define st_copy onig_st_copy
|
|
|
|
# define st_nothing_key_clone onig_st_nothing_key_clone
|
|
|
|
# define st_nothing_key_free onig_st_nothing_key_free
|
2007-05-22 21:32:08 -04:00
|
|
|
/* */
|
2016-12-10 12:47:04 -05:00
|
|
|
# define onig_st_is_member st_is_member
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
#endif /* RUBY */
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2006-08-27 08:58:22 -04:00
|
|
|
#define STATE_CHECK_STRING_THRESHOLD_LEN 7
|
2007-05-22 21:32:08 -04:00
|
|
|
#define STATE_CHECK_BUFF_MAX_SIZE 0x4000
|
2006-08-27 08:58:22 -04:00
|
|
|
|
2004-03-05 10:31:51 -05:00
|
|
|
#define xmemset memset
|
|
|
|
#define xmemcpy memcpy
|
|
|
|
#define xmemmove memmove
|
2007-07-23 05:39:30 -04:00
|
|
|
|
2017-02-11 10:08:33 -05:00
|
|
|
#if ((defined(RUBY_MSVCRT_VERSION) && RUBY_MSVCRT_VERSION >= 90) \
|
|
|
|
|| (!defined(RUBY_MSVCRT_VERSION) && defined(_WIN32))) \
|
|
|
|
&& !defined(__GNUC__)
|
2016-12-10 12:47:04 -05:00
|
|
|
# define xalloca _alloca
|
|
|
|
# define xvsnprintf(buf,size,fmt,args) _vsnprintf_s(buf,size,_TRUNCATE,fmt,args)
|
|
|
|
# define xsnprintf sprintf_s
|
|
|
|
# define xstrcat(dest,src,size) strcat_s(dest,size,src)
|
2004-03-05 10:31:51 -05:00
|
|
|
#else
|
2016-12-10 12:47:04 -05:00
|
|
|
# define xalloca alloca
|
|
|
|
# define xvsnprintf vsnprintf
|
|
|
|
# define xsnprintf snprintf
|
|
|
|
# define xstrcat(dest,src,size) strcat(dest,src)
|
2004-03-05 10:31:51 -05:00
|
|
|
#endif
|
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
#if defined(ONIG_DEBUG_MEMLEAK) && defined(_MSC_VER)
|
|
|
|
# define _CRTDBG_MAP_ALLOC
|
|
|
|
# include <malloc.h>
|
|
|
|
# include <crtdbg.h>
|
|
|
|
#endif
|
2007-07-23 05:39:30 -04:00
|
|
|
|
2004-03-05 10:31:51 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2007-12-13 23:47:57 -05:00
|
|
|
#if defined(HAVE_ALLOCA_H) && (defined(_AIX) || !defined(__GNUC__))
|
2016-12-10 12:47:04 -05:00
|
|
|
# include <alloca.h>
|
2004-03-05 10:31:51 -05:00
|
|
|
#endif
|
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
#include <string.h>
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
#include <ctype.h>
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 10:21:48 -05:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2016-12-10 12:47:04 -05:00
|
|
|
# include <sys/types.h>
|
* ascii.c, euc_jp.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, utf8.c:
imported Oni Guruma 3.4.0.
* parse.y, re.c: Now mbclen() takes unsigned char as its argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-04 09:43:08 -05:00
|
|
|
#endif
|
2007-05-22 21:32:08 -04:00
|
|
|
|
2012-02-17 02:42:23 -05:00
|
|
|
#ifdef HAVE_STDINT_H
|
|
|
|
# include <stdint.h>
|
|
|
|
#endif
|
|
|
|
|
2014-07-15 23:27:25 -04:00
|
|
|
#ifdef HAVE_INTTYPES_H
|
|
|
|
# include <inttypes.h>
|
|
|
|
#endif
|
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
#include <stddef.h>
|
2012-02-17 02:42:23 -05:00
|
|
|
|
2014-07-15 23:27:25 -04:00
|
|
|
#ifdef _WIN32
|
2016-12-10 12:47:04 -05:00
|
|
|
# include <malloc.h> /* for alloca() */
|
2012-02-17 02:42:23 -05:00
|
|
|
#endif
|
|
|
|
|
2004-03-05 10:31:51 -05:00
|
|
|
#ifdef ONIG_DEBUG
|
|
|
|
# include <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
2012-02-17 02:42:23 -05:00
|
|
|
#ifdef _WIN32
|
2016-12-10 12:47:04 -05:00
|
|
|
# if defined(_MSC_VER) && (_MSC_VER < 1300)
|
|
|
|
# ifndef _INTPTR_T_DEFINED
|
|
|
|
# define _INTPTR_T_DEFINED
|
2012-02-17 02:42:23 -05:00
|
|
|
typedef int intptr_t;
|
2016-12-10 12:47:04 -05:00
|
|
|
# endif
|
|
|
|
# ifndef _UINTPTR_T_DEFINED
|
|
|
|
# define _UINTPTR_T_DEFINED
|
2012-02-17 02:42:23 -05:00
|
|
|
typedef unsigned int uintptr_t;
|
2016-12-10 12:47:04 -05:00
|
|
|
# endif
|
|
|
|
# endif
|
2012-02-17 02:42:23 -05:00
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
2014-07-15 23:27:25 -04:00
|
|
|
#ifndef PRIdPTR
|
2016-12-10 12:47:04 -05:00
|
|
|
# ifdef _WIN64
|
|
|
|
# define PRIdPTR "I64d"
|
|
|
|
# define PRIuPTR "I64u"
|
|
|
|
# define PRIxPTR "I64x"
|
|
|
|
# else
|
|
|
|
# define PRIdPTR "ld"
|
|
|
|
# define PRIuPTR "lu"
|
|
|
|
# define PRIxPTR "lx"
|
|
|
|
# endif
|
2014-07-15 23:27:25 -04:00
|
|
|
#endif
|
2016-12-10 12:47:04 -05:00
|
|
|
|
|
|
|
#ifndef PRIdPTRDIFF
|
|
|
|
# define PRIdPTRDIFF PRIdPTR
|
2014-07-15 23:27:25 -04:00
|
|
|
#endif
|
|
|
|
|
2004-03-05 10:31:51 -05:00
|
|
|
#include "regenc.h"
|
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2010-07-21 17:38:25 -04:00
|
|
|
|
2004-03-05 10:31:51 -05:00
|
|
|
#ifdef MIN
|
2016-12-10 12:47:04 -05:00
|
|
|
# undef MIN
|
2004-03-05 10:31:51 -05:00
|
|
|
#endif
|
|
|
|
#ifdef MAX
|
2016-12-10 12:47:04 -05:00
|
|
|
# undef MAX
|
2004-03-05 10:31:51 -05:00
|
|
|
#endif
|
|
|
|
#define MIN(a,b) (((a)>(b))?(b):(a))
|
|
|
|
#define MAX(a,b) (((a)<(b))?(b):(a))
|
|
|
|
|
|
|
|
#define IS_NULL(p) (((void*)(p)) == (void*)0)
|
|
|
|
#define IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
|
|
|
|
#define CHECK_NULL_RETURN(p) if (IS_NULL(p)) return NULL
|
2007-07-23 05:39:30 -04:00
|
|
|
#define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
|
2004-03-05 10:31:51 -05:00
|
|
|
#define NULL_UCHARP ((UChar* )0)
|
|
|
|
|
2012-02-17 02:42:23 -05:00
|
|
|
#define ONIG_LAST_CODE_POINT (~((OnigCodePoint )0))
|
|
|
|
|
2007-07-23 05:39:30 -04:00
|
|
|
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
# define PLATFORM_GET_INC(val,p,type) do{\
|
2007-07-23 05:39:30 -04:00
|
|
|
val = *(type* )p;\
|
|
|
|
(p) += sizeof(type);\
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
# define PLATFORM_GET_INC(val,p,type) do{\
|
2007-07-23 05:39:30 -04:00
|
|
|
xmemcpy(&val, (p), sizeof(type));\
|
|
|
|
(p) += sizeof(type);\
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
/* sizeof(OnigCodePoint) */
|
2016-12-10 12:47:04 -05:00
|
|
|
# define WORD_ALIGNMENT_SIZE SIZEOF_LONG
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
# define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
|
2004-03-05 10:31:51 -05:00
|
|
|
(pad_size) = WORD_ALIGNMENT_SIZE \
|
2008-07-02 12:45:05 -04:00
|
|
|
- ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
|
2004-03-05 10:31:51 -05:00
|
|
|
if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
|
|
|
|
} while (0)
|
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
# define ALIGNMENT_RIGHT(addr) do {\
|
2004-03-05 10:31:51 -05:00
|
|
|
(addr) += (WORD_ALIGNMENT_SIZE - 1);\
|
2008-07-02 12:45:05 -04:00
|
|
|
(addr) -= ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
|
2004-03-05 10:31:51 -05:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#endif /* PLATFORM_UNALIGNED_WORD_ACCESS */
|
|
|
|
|
|
|
|
/* stack pop level */
|
|
|
|
#define STACK_POP_LEVEL_FREE 0
|
|
|
|
#define STACK_POP_LEVEL_MEM_START 1
|
|
|
|
#define STACK_POP_LEVEL_ALL 2
|
|
|
|
|
|
|
|
/* optimize flags */
|
|
|
|
#define ONIG_OPTIMIZE_NONE 0
|
|
|
|
#define ONIG_OPTIMIZE_EXACT 1 /* Slow Search */
|
|
|
|
#define ONIG_OPTIMIZE_EXACT_BM 2 /* Boyer Moore Search */
|
2012-02-17 02:42:23 -05:00
|
|
|
#define ONIG_OPTIMIZE_EXACT_BM_NOT_REV 3 /* BM (applied to a multibyte string) */
|
2004-03-05 10:31:51 -05:00
|
|
|
#define ONIG_OPTIMIZE_EXACT_IC 4 /* Slow Search (ignore case) */
|
|
|
|
#define ONIG_OPTIMIZE_MAP 5 /* char map */
|
2012-02-17 02:42:23 -05:00
|
|
|
#define ONIG_OPTIMIZE_EXACT_BM_IC 6 /* BM (ignore case) */
|
|
|
|
#define ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC 7 /* BM (applied to a multibyte string) (ignore case) */
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
/* bit status */
|
|
|
|
typedef unsigned int BitStatusType;
|
|
|
|
|
|
|
|
#define BIT_STATUS_BITS_NUM (sizeof(BitStatusType) * 8)
|
|
|
|
#define BIT_STATUS_CLEAR(stats) (stats) = 0
|
|
|
|
#define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0)
|
|
|
|
#define BIT_STATUS_AT(stats,n) \
|
2015-11-26 03:31:27 -05:00
|
|
|
((n) < (int )BIT_STATUS_BITS_NUM ? ((stats) & ((BitStatusType )1 << n)) : ((stats) & 1))
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
#define BIT_STATUS_ON_AT(stats,n) do {\
|
2015-11-26 03:31:27 -05:00
|
|
|
if ((n) < (int )BIT_STATUS_BITS_NUM)\
|
2004-03-05 10:31:51 -05:00
|
|
|
(stats) |= (1 << (n));\
|
|
|
|
else\
|
|
|
|
(stats) |= 1;\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\
|
2015-11-26 03:31:27 -05:00
|
|
|
if ((n) < (int )BIT_STATUS_BITS_NUM)\
|
2004-03-05 10:31:51 -05:00
|
|
|
(stats) |= (1 << (n));\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
|
#define INT_MAX_LIMIT ((1UL << (SIZEOF_INT * 8 - 1)) - 1)
|
|
|
|
|
|
|
|
#define DIGITVAL(code) ((code) - '0')
|
|
|
|
#define ODIGITVAL(code) DIGITVAL(code)
|
|
|
|
#define XDIGITVAL(enc,code) \
|
|
|
|
(ONIGENC_IS_CODE_DIGIT(enc,code) ? DIGITVAL(code) \
|
|
|
|
: (ONIGENC_IS_CODE_UPPER(enc,code) ? (code) - 'A' + 10 : (code) - 'a' + 10))
|
|
|
|
|
|
|
|
#define IS_SINGLELINE(option) ((option) & ONIG_OPTION_SINGLELINE)
|
|
|
|
#define IS_MULTILINE(option) ((option) & ONIG_OPTION_MULTILINE)
|
|
|
|
#define IS_IGNORECASE(option) ((option) & ONIG_OPTION_IGNORECASE)
|
|
|
|
#define IS_EXTEND(option) ((option) & ONIG_OPTION_EXTEND)
|
|
|
|
#define IS_FIND_LONGEST(option) ((option) & ONIG_OPTION_FIND_LONGEST)
|
|
|
|
#define IS_FIND_NOT_EMPTY(option) ((option) & ONIG_OPTION_FIND_NOT_EMPTY)
|
|
|
|
#define IS_FIND_CONDITION(option) ((option) & \
|
|
|
|
(ONIG_OPTION_FIND_LONGEST | ONIG_OPTION_FIND_NOT_EMPTY))
|
|
|
|
#define IS_NOTBOL(option) ((option) & ONIG_OPTION_NOTBOL)
|
|
|
|
#define IS_NOTEOL(option) ((option) & ONIG_OPTION_NOTEOL)
|
2014-07-15 23:27:25 -04:00
|
|
|
#define IS_NOTBOS(option) ((option) & ONIG_OPTION_NOTBOS)
|
|
|
|
#define IS_NOTEOS(option) ((option) & ONIG_OPTION_NOTEOS)
|
2012-02-17 02:42:23 -05:00
|
|
|
#define IS_ASCII_RANGE(option) ((option) & ONIG_OPTION_ASCII_RANGE)
|
|
|
|
#define IS_POSIX_BRACKET_ALL_RANGE(option) ((option) & ONIG_OPTION_POSIX_BRACKET_ALL_RANGE)
|
|
|
|
#define IS_WORD_BOUND_ALL_RANGE(option) ((option) & ONIG_OPTION_WORD_BOUND_ALL_RANGE)
|
|
|
|
#define IS_NEWLINE_CRLF(option) ((option) & ONIG_OPTION_NEWLINE_CRLF)
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
/* OP_SET_OPTION is required for these options.
|
|
|
|
#define IS_DYNAMIC_OPTION(option) \
|
|
|
|
(((option) & (ONIG_OPTION_MULTILINE | ONIG_OPTION_IGNORECASE)) != 0)
|
|
|
|
*/
|
|
|
|
/* ignore-case and multibyte status are included in compiled code. */
|
|
|
|
#define IS_DYNAMIC_OPTION(option) 0
|
|
|
|
|
2007-05-22 21:32:08 -04:00
|
|
|
#define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag) \
|
|
|
|
((case_fold_flag) & ~INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR)
|
|
|
|
|
* ascii.c, euc_jp.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, utf8.c:
imported Oni Guruma 3.4.0.
* parse.y, re.c: Now mbclen() takes unsigned char as its argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-04 09:43:08 -05:00
|
|
|
#define REPEAT_INFINITE -1
|
|
|
|
#define IS_REPEAT_INFINITE(n) ((n) == REPEAT_INFINITE)
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
/* bitset */
|
|
|
|
#define BITS_PER_BYTE 8
|
|
|
|
#define SINGLE_BYTE_SIZE (1 << BITS_PER_BYTE)
|
2013-03-01 11:36:37 -05:00
|
|
|
#define BITS_IN_ROOM ((int )sizeof(Bits) * BITS_PER_BYTE)
|
2004-03-05 10:31:51 -05:00
|
|
|
#define BITSET_SIZE (SINGLE_BYTE_SIZE / BITS_IN_ROOM)
|
|
|
|
|
|
|
|
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
|
|
|
|
typedef unsigned int Bits;
|
|
|
|
#else
|
|
|
|
typedef unsigned char Bits;
|
|
|
|
#endif
|
|
|
|
typedef Bits BitSet[BITSET_SIZE];
|
|
|
|
typedef Bits* BitSetRef;
|
|
|
|
|
2012-02-17 02:42:23 -05:00
|
|
|
#define SIZE_BITSET (int )sizeof(BitSet)
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
#define BITSET_CLEAR(bs) do {\
|
|
|
|
int i;\
|
2013-03-01 11:36:37 -05:00
|
|
|
for (i = 0; i < BITSET_SIZE; i++) { (bs)[i] = 0; } \
|
2004-03-05 10:31:51 -05:00
|
|
|
} while (0)
|
|
|
|
|
2013-03-01 11:36:37 -05:00
|
|
|
#define BS_ROOM(bs,pos) (bs)[(int )(pos) / BITS_IN_ROOM]
|
2014-10-17 04:50:01 -04:00
|
|
|
#define BS_BIT(pos) (1U << ((int )(pos) % BITS_IN_ROOM))
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
#define BITSET_AT(bs, pos) (BS_ROOM(bs,pos) & BS_BIT(pos))
|
|
|
|
#define BITSET_SET_BIT(bs, pos) BS_ROOM(bs,pos) |= BS_BIT(pos)
|
|
|
|
#define BITSET_CLEAR_BIT(bs, pos) BS_ROOM(bs,pos) &= ~(BS_BIT(pos))
|
|
|
|
#define BITSET_INVERT_BIT(bs, pos) BS_ROOM(bs,pos) ^= BS_BIT(pos)
|
|
|
|
|
|
|
|
/* bytes buffer */
|
|
|
|
typedef struct _BBuf {
|
|
|
|
UChar* p;
|
|
|
|
unsigned int used;
|
|
|
|
unsigned int alloc;
|
|
|
|
} BBuf;
|
|
|
|
|
|
|
|
#define BBUF_INIT(buf,size) onig_bbuf_init((BBuf* )(buf), (size))
|
|
|
|
|
|
|
|
#define BBUF_SIZE_INC(buf,inc) do{\
|
2015-11-26 03:31:27 -05:00
|
|
|
UChar *tmp;\
|
2004-03-05 10:31:51 -05:00
|
|
|
(buf)->alloc += (inc);\
|
2015-11-26 03:31:27 -05:00
|
|
|
tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
|
|
|
|
if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
|
|
|
|
(buf)->p = tmp;\
|
2004-03-05 10:31:51 -05:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define BBUF_EXPAND(buf,low) do{\
|
2015-11-26 03:31:27 -05:00
|
|
|
UChar *tmp;\
|
2004-03-05 10:31:51 -05:00
|
|
|
do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
|
2015-11-26 03:31:27 -05:00
|
|
|
tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
|
|
|
|
if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
|
|
|
|
(buf)->p = tmp;\
|
2004-03-05 10:31:51 -05:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define BBUF_ENSURE_SIZE(buf,size) do{\
|
|
|
|
unsigned int new_alloc = (buf)->alloc;\
|
|
|
|
while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
|
|
|
|
if ((buf)->alloc != new_alloc) {\
|
2015-11-26 03:31:27 -05:00
|
|
|
UChar *tmp;\
|
|
|
|
tmp = (UChar* )xrealloc((buf)->p, new_alloc);\
|
|
|
|
if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
|
|
|
|
(buf)->p = tmp;\
|
2004-03-05 10:31:51 -05:00
|
|
|
(buf)->alloc = new_alloc;\
|
|
|
|
}\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define BBUF_WRITE(buf,pos,bytes,n) do{\
|
2012-02-17 02:42:23 -05:00
|
|
|
int used = (pos) + (int )(n);\
|
2004-03-05 10:31:51 -05:00
|
|
|
if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
|
|
|
|
xmemcpy((buf)->p + (pos), (bytes), (n));\
|
|
|
|
if ((buf)->used < (unsigned int )used) (buf)->used = used;\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define BBUF_WRITE1(buf,pos,byte) do{\
|
|
|
|
int used = (pos) + 1;\
|
|
|
|
if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
|
2013-03-01 11:36:37 -05:00
|
|
|
(buf)->p[(pos)] = (UChar )(byte);\
|
2004-03-05 10:31:51 -05:00
|
|
|
if ((buf)->used < (unsigned int )used) (buf)->used = used;\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define BBUF_ADD(buf,bytes,n) BBUF_WRITE((buf),(buf)->used,(bytes),(n))
|
|
|
|
#define BBUF_ADD1(buf,byte) BBUF_WRITE1((buf),(buf)->used,(byte))
|
|
|
|
#define BBUF_GET_ADD_ADDRESS(buf) ((buf)->p + (buf)->used)
|
|
|
|
#define BBUF_GET_OFFSET_POS(buf) ((buf)->used)
|
|
|
|
|
|
|
|
/* from < to */
|
|
|
|
#define BBUF_MOVE_RIGHT(buf,from,to,n) do {\
|
|
|
|
if ((unsigned int )((to)+(n)) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
|
|
|
|
xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
|
|
|
|
if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/* from > to */
|
|
|
|
#define BBUF_MOVE_LEFT(buf,from,to,n) do {\
|
|
|
|
xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/* from > to */
|
|
|
|
#define BBUF_MOVE_LEFT_REDUCE(buf,from,to) do {\
|
|
|
|
xmemmove((buf)->p + (to), (buf)->p + (from), (buf)->used - (from));\
|
|
|
|
(buf)->used -= (from - to);\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define BBUF_INSERT(buf,pos,bytes,n) do {\
|
|
|
|
if (pos >= (buf)->used) {\
|
|
|
|
BBUF_WRITE(buf,pos,bytes,n);\
|
|
|
|
}\
|
|
|
|
else {\
|
|
|
|
BBUF_MOVE_RIGHT((buf),(pos),(pos) + (n),((buf)->used - (pos)));\
|
|
|
|
xmemcpy((buf)->p + (pos), (bytes), (n));\
|
|
|
|
}\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define BBUF_GET_BYTE(buf, pos) (buf)->p[(pos)]
|
|
|
|
|
|
|
|
|
|
|
|
#define ANCHOR_BEGIN_BUF (1<<0)
|
|
|
|
#define ANCHOR_BEGIN_LINE (1<<1)
|
|
|
|
#define ANCHOR_BEGIN_POSITION (1<<2)
|
|
|
|
#define ANCHOR_END_BUF (1<<3)
|
|
|
|
#define ANCHOR_SEMI_END_BUF (1<<4)
|
|
|
|
#define ANCHOR_END_LINE (1<<5)
|
|
|
|
|
|
|
|
#define ANCHOR_WORD_BOUND (1<<6)
|
|
|
|
#define ANCHOR_NOT_WORD_BOUND (1<<7)
|
|
|
|
#define ANCHOR_WORD_BEGIN (1<<8)
|
|
|
|
#define ANCHOR_WORD_END (1<<9)
|
|
|
|
#define ANCHOR_PREC_READ (1<<10)
|
|
|
|
#define ANCHOR_PREC_READ_NOT (1<<11)
|
|
|
|
#define ANCHOR_LOOK_BEHIND (1<<12)
|
|
|
|
#define ANCHOR_LOOK_BEHIND_NOT (1<<13)
|
|
|
|
|
|
|
|
#define ANCHOR_ANYCHAR_STAR (1<<14) /* ".*" optimize info */
|
2006-02-12 10:05:19 -05:00
|
|
|
#define ANCHOR_ANYCHAR_STAR_ML (1<<15) /* ".*" optimize info (multi-line) */
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2012-02-17 02:42:23 -05:00
|
|
|
#define ANCHOR_KEEP (1<<16)
|
|
|
|
|
2004-03-05 10:31:51 -05:00
|
|
|
/* operation code */
|
|
|
|
enum OpCode {
|
|
|
|
OP_FINISH = 0, /* matching process terminator (no more alternative) */
|
|
|
|
OP_END = 1, /* pattern code terminator (success end) */
|
|
|
|
|
|
|
|
OP_EXACT1 = 2, /* single byte, N = 1 */
|
|
|
|
OP_EXACT2, /* single byte, N = 2 */
|
|
|
|
OP_EXACT3, /* single byte, N = 3 */
|
|
|
|
OP_EXACT4, /* single byte, N = 4 */
|
|
|
|
OP_EXACT5, /* single byte, N = 5 */
|
|
|
|
OP_EXACTN, /* single byte */
|
|
|
|
OP_EXACTMB2N1, /* mb-length = 2 N = 1 */
|
|
|
|
OP_EXACTMB2N2, /* mb-length = 2 N = 2 */
|
|
|
|
OP_EXACTMB2N3, /* mb-length = 2 N = 3 */
|
|
|
|
OP_EXACTMB2N, /* mb-length = 2 */
|
|
|
|
OP_EXACTMB3N, /* mb-length = 3 */
|
|
|
|
OP_EXACTMBN, /* other length */
|
|
|
|
|
|
|
|
OP_EXACT1_IC, /* single byte, N = 1, ignore case */
|
|
|
|
OP_EXACTN_IC, /* single byte, ignore case */
|
|
|
|
|
|
|
|
OP_CCLASS,
|
|
|
|
OP_CCLASS_MB,
|
|
|
|
OP_CCLASS_MIX,
|
|
|
|
OP_CCLASS_NOT,
|
|
|
|
OP_CCLASS_MB_NOT,
|
|
|
|
OP_CCLASS_MIX_NOT,
|
|
|
|
|
|
|
|
OP_ANYCHAR, /* "." */
|
|
|
|
OP_ANYCHAR_ML, /* "." multi-line */
|
|
|
|
OP_ANYCHAR_STAR, /* ".*" */
|
|
|
|
OP_ANYCHAR_ML_STAR, /* ".*" multi-line */
|
|
|
|
OP_ANYCHAR_STAR_PEEK_NEXT,
|
|
|
|
OP_ANYCHAR_ML_STAR_PEEK_NEXT,
|
|
|
|
|
|
|
|
OP_WORD,
|
|
|
|
OP_NOT_WORD,
|
|
|
|
OP_WORD_BOUND,
|
|
|
|
OP_NOT_WORD_BOUND,
|
|
|
|
OP_WORD_BEGIN,
|
|
|
|
OP_WORD_END,
|
|
|
|
|
2012-02-17 02:42:23 -05:00
|
|
|
OP_ASCII_WORD,
|
|
|
|
OP_NOT_ASCII_WORD,
|
|
|
|
OP_ASCII_WORD_BOUND,
|
|
|
|
OP_NOT_ASCII_WORD_BOUND,
|
|
|
|
OP_ASCII_WORD_BEGIN,
|
|
|
|
OP_ASCII_WORD_END,
|
|
|
|
|
2004-03-05 10:31:51 -05:00
|
|
|
OP_BEGIN_BUF,
|
|
|
|
OP_END_BUF,
|
|
|
|
OP_BEGIN_LINE,
|
|
|
|
OP_END_LINE,
|
|
|
|
OP_SEMI_END_BUF,
|
|
|
|
OP_BEGIN_POSITION,
|
|
|
|
|
|
|
|
OP_BACKREF1,
|
|
|
|
OP_BACKREF2,
|
|
|
|
OP_BACKREFN,
|
|
|
|
OP_BACKREFN_IC,
|
|
|
|
OP_BACKREF_MULTI,
|
|
|
|
OP_BACKREF_MULTI_IC,
|
2008-01-03 10:55:04 -05:00
|
|
|
OP_BACKREF_WITH_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
OP_MEMORY_START,
|
|
|
|
OP_MEMORY_START_PUSH, /* push back-tracker to stack */
|
|
|
|
OP_MEMORY_END_PUSH, /* push back-tracker to stack */
|
|
|
|
OP_MEMORY_END_PUSH_REC, /* push back-tracker to stack */
|
|
|
|
OP_MEMORY_END,
|
|
|
|
OP_MEMORY_END_REC, /* push marker to stack */
|
|
|
|
|
2012-02-17 02:42:23 -05:00
|
|
|
OP_KEEP,
|
|
|
|
|
2004-03-05 10:31:51 -05:00
|
|
|
OP_FAIL, /* pop stack and move */
|
|
|
|
OP_JUMP,
|
|
|
|
OP_PUSH,
|
|
|
|
OP_POP,
|
|
|
|
OP_PUSH_OR_JUMP_EXACT1, /* if match exact then push, else jump. */
|
|
|
|
OP_PUSH_IF_PEEK_NEXT, /* if match exact then push, else none. */
|
|
|
|
OP_REPEAT, /* {n,m} */
|
|
|
|
OP_REPEAT_NG, /* {n,m}? (non greedy) */
|
|
|
|
OP_REPEAT_INC,
|
|
|
|
OP_REPEAT_INC_NG, /* non greedy */
|
2004-10-30 02:56:18 -04:00
|
|
|
OP_REPEAT_INC_SG, /* search and get in stack */
|
|
|
|
OP_REPEAT_INC_NG_SG, /* search and get in stack (non greedy) */
|
2004-03-05 10:31:51 -05:00
|
|
|
OP_NULL_CHECK_START, /* null loop checker start */
|
|
|
|
OP_NULL_CHECK_END, /* null loop checker end */
|
|
|
|
OP_NULL_CHECK_END_MEMST, /* null loop checker end (with capture status) */
|
|
|
|
OP_NULL_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
|
|
|
|
|
|
|
|
OP_PUSH_POS, /* (?=...) start */
|
|
|
|
OP_POP_POS, /* (?=...) end */
|
|
|
|
OP_PUSH_POS_NOT, /* (?!...) start */
|
|
|
|
OP_FAIL_POS, /* (?!...) end */
|
|
|
|
OP_PUSH_STOP_BT, /* (?>...) start */
|
|
|
|
OP_POP_STOP_BT, /* (?>...) end */
|
|
|
|
OP_LOOK_BEHIND, /* (?<=...) start (no needs end opcode) */
|
|
|
|
OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
|
|
|
|
OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end */
|
2017-02-11 10:08:33 -05:00
|
|
|
OP_PUSH_ABSENT_POS, /* (?~...) start */
|
|
|
|
OP_ABSENT, /* (?~...) start of inner loop */
|
|
|
|
OP_ABSENT_END, /* (?~...) end */
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
OP_CALL, /* \g<name> */
|
2006-08-27 08:58:22 -04:00
|
|
|
OP_RETURN,
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2012-02-17 02:42:23 -05:00
|
|
|
OP_CONDITION,
|
|
|
|
|
2006-08-27 08:58:22 -04:00
|
|
|
OP_STATE_CHECK_PUSH, /* combination explosion check and push */
|
|
|
|
OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump */
|
|
|
|
OP_STATE_CHECK, /* check only */
|
|
|
|
OP_STATE_CHECK_ANYCHAR_STAR,
|
2007-07-23 05:39:30 -04:00
|
|
|
OP_STATE_CHECK_ANYCHAR_ML_STAR,
|
|
|
|
|
|
|
|
/* no need: IS_DYNAMIC_OPTION() == 0 */
|
|
|
|
OP_SET_OPTION_PUSH, /* set option and push recover option */
|
|
|
|
OP_SET_OPTION /* set option */
|
2006-08-27 08:58:22 -04:00
|
|
|
};
|
2004-03-05 10:31:51 -05:00
|
|
|
|
* ascii.c, euc_jp.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, utf8.c:
imported Oni Guruma 3.4.0.
* parse.y, re.c: Now mbclen() takes unsigned char as its argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-04 09:43:08 -05:00
|
|
|
typedef int RelAddrType;
|
|
|
|
typedef int AbsAddrType;
|
|
|
|
typedef int LengthType;
|
|
|
|
typedef int RepeatNumType;
|
|
|
|
typedef short int MemNumType;
|
2006-08-27 08:58:22 -04:00
|
|
|
typedef short int StateCheckNumType;
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 10:21:48 -05:00
|
|
|
typedef void* PointerType;
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2006-08-27 08:58:22 -04:00
|
|
|
#define SIZE_OPCODE 1
|
2012-02-17 02:42:23 -05:00
|
|
|
#define SIZE_RELADDR (int )sizeof(RelAddrType)
|
|
|
|
#define SIZE_ABSADDR (int )sizeof(AbsAddrType)
|
|
|
|
#define SIZE_LENGTH (int )sizeof(LengthType)
|
|
|
|
#define SIZE_MEMNUM (int )sizeof(MemNumType)
|
|
|
|
#define SIZE_STATE_CHECK_NUM (int )sizeof(StateCheckNumType)
|
|
|
|
#define SIZE_REPEATNUM (int )sizeof(RepeatNumType)
|
|
|
|
#define SIZE_OPTION (int )sizeof(OnigOptionType)
|
|
|
|
#define SIZE_CODE_POINT (int )sizeof(OnigCodePoint)
|
|
|
|
#define SIZE_POINTER (int )sizeof(PointerType)
|
2004-03-05 10:31:51 -05:00
|
|
|
|
|
|
|
|
2004-11-27 22:06:39 -05:00
|
|
|
#define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType)
|
|
|
|
#define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType)
|
|
|
|
#define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType)
|
|
|
|
#define GET_MEMNUM_INC(num,p) PLATFORM_GET_INC(num, p, MemNumType)
|
|
|
|
#define GET_REPEATNUM_INC(num,p) PLATFORM_GET_INC(num, p, RepeatNumType)
|
|
|
|
#define GET_OPTION_INC(option,p) PLATFORM_GET_INC(option, p, OnigOptionType)
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 10:21:48 -05:00
|
|
|
#define GET_POINTER_INC(ptr,p) PLATFORM_GET_INC(ptr, p, PointerType)
|
2006-08-27 08:58:22 -04:00
|
|
|
#define GET_STATE_CHECK_NUM_INC(num,p) PLATFORM_GET_INC(num, p, StateCheckNumType)
|
2004-11-27 22:06:39 -05:00
|
|
|
|
2004-03-05 10:31:51 -05:00
|
|
|
/* code point's address must be aligned address. */
|
|
|
|
#define GET_CODE_POINT(code,p) code = *((OnigCodePoint* )(p))
|
|
|
|
#define GET_BYTE_INC(byte,p) do{\
|
|
|
|
byte = *(p);\
|
|
|
|
(p)++;\
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
/* op-code + arg size */
|
|
|
|
#define SIZE_OP_ANYCHAR_STAR SIZE_OPCODE
|
|
|
|
#define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT (SIZE_OPCODE + 1)
|
|
|
|
#define SIZE_OP_JUMP (SIZE_OPCODE + SIZE_RELADDR)
|
|
|
|
#define SIZE_OP_PUSH (SIZE_OPCODE + SIZE_RELADDR)
|
|
|
|
#define SIZE_OP_POP SIZE_OPCODE
|
|
|
|
#define SIZE_OP_PUSH_OR_JUMP_EXACT1 (SIZE_OPCODE + SIZE_RELADDR + 1)
|
|
|
|
#define SIZE_OP_PUSH_IF_PEEK_NEXT (SIZE_OPCODE + SIZE_RELADDR + 1)
|
|
|
|
#define SIZE_OP_REPEAT_INC (SIZE_OPCODE + SIZE_MEMNUM)
|
|
|
|
#define SIZE_OP_REPEAT_INC_NG (SIZE_OPCODE + SIZE_MEMNUM)
|
|
|
|
#define SIZE_OP_PUSH_POS SIZE_OPCODE
|
|
|
|
#define SIZE_OP_PUSH_POS_NOT (SIZE_OPCODE + SIZE_RELADDR)
|
|
|
|
#define SIZE_OP_POP_POS SIZE_OPCODE
|
|
|
|
#define SIZE_OP_FAIL_POS SIZE_OPCODE
|
|
|
|
#define SIZE_OP_SET_OPTION (SIZE_OPCODE + SIZE_OPTION)
|
|
|
|
#define SIZE_OP_SET_OPTION_PUSH (SIZE_OPCODE + SIZE_OPTION)
|
|
|
|
#define SIZE_OP_FAIL SIZE_OPCODE
|
|
|
|
#define SIZE_OP_MEMORY_START (SIZE_OPCODE + SIZE_MEMNUM)
|
|
|
|
#define SIZE_OP_MEMORY_START_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
|
|
|
|
#define SIZE_OP_MEMORY_END_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
|
|
|
|
#define SIZE_OP_MEMORY_END_PUSH_REC (SIZE_OPCODE + SIZE_MEMNUM)
|
|
|
|
#define SIZE_OP_MEMORY_END (SIZE_OPCODE + SIZE_MEMNUM)
|
|
|
|
#define SIZE_OP_MEMORY_END_REC (SIZE_OPCODE + SIZE_MEMNUM)
|
|
|
|
#define SIZE_OP_PUSH_STOP_BT SIZE_OPCODE
|
|
|
|
#define SIZE_OP_POP_STOP_BT SIZE_OPCODE
|
|
|
|
#define SIZE_OP_NULL_CHECK_START (SIZE_OPCODE + SIZE_MEMNUM)
|
|
|
|
#define SIZE_OP_NULL_CHECK_END (SIZE_OPCODE + SIZE_MEMNUM)
|
|
|
|
#define SIZE_OP_LOOK_BEHIND (SIZE_OPCODE + SIZE_LENGTH)
|
|
|
|
#define SIZE_OP_PUSH_LOOK_BEHIND_NOT (SIZE_OPCODE + SIZE_RELADDR + SIZE_LENGTH)
|
|
|
|
#define SIZE_OP_FAIL_LOOK_BEHIND_NOT SIZE_OPCODE
|
|
|
|
#define SIZE_OP_CALL (SIZE_OPCODE + SIZE_ABSADDR)
|
|
|
|
#define SIZE_OP_RETURN SIZE_OPCODE
|
2012-02-17 02:42:23 -05:00
|
|
|
#define SIZE_OP_CONDITION (SIZE_OPCODE + SIZE_MEMNUM + SIZE_RELADDR)
|
2017-02-11 10:08:33 -05:00
|
|
|
#define SIZE_OP_PUSH_ABSENT_POS SIZE_OPCODE
|
|
|
|
#define SIZE_OP_ABSENT (SIZE_OPCODE + SIZE_RELADDR)
|
|
|
|
#define SIZE_OP_ABSENT_END SIZE_OPCODE
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2006-08-27 08:58:22 -04:00
|
|
|
#ifdef USE_COMBINATION_EXPLOSION_CHECK
|
2016-12-10 12:47:04 -05:00
|
|
|
# define SIZE_OP_STATE_CHECK (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
|
|
|
|
# define SIZE_OP_STATE_CHECK_PUSH (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
|
|
|
|
# define SIZE_OP_STATE_CHECK_PUSH_OR_JUMP (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
|
|
|
|
# define SIZE_OP_STATE_CHECK_ANYCHAR_STAR (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
|
2006-08-27 08:58:22 -04:00
|
|
|
#endif
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2007-05-22 21:32:08 -04:00
|
|
|
#define MC_ESC(syn) (syn)->meta_char_table.esc
|
|
|
|
#define MC_ANYCHAR(syn) (syn)->meta_char_table.anychar
|
|
|
|
#define MC_ANYTIME(syn) (syn)->meta_char_table.anytime
|
|
|
|
#define MC_ZERO_OR_ONE_TIME(syn) (syn)->meta_char_table.zero_or_one_time
|
|
|
|
#define MC_ONE_OR_MORE_TIME(syn) (syn)->meta_char_table.one_or_more_time
|
|
|
|
#define MC_ANYCHAR_ANYTIME(syn) (syn)->meta_char_table.anychar_anytime
|
* ascii.c, euc_jp.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, utf8.c:
imported Oni Guruma 3.4.0.
* parse.y, re.c: Now mbclen() takes unsigned char as its argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-04 09:43:08 -05:00
|
|
|
|
2007-05-22 21:32:08 -04:00
|
|
|
#define IS_MC_ESC_CODE(code, syn) \
|
|
|
|
((code) == MC_ESC(syn) && \
|
2006-02-04 07:31:19 -05:00
|
|
|
!IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE))
|
|
|
|
|
|
|
|
|
2004-04-27 11:53:16 -04:00
|
|
|
#define SYN_POSIX_COMMON_OP \
|
|
|
|
( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_POSIX_BRACKET | \
|
|
|
|
ONIG_SYN_OP_DECIMAL_BACKREF | \
|
|
|
|
ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_ASTERISK_ZERO_INF | \
|
|
|
|
ONIG_SYN_OP_LINE_ANCHOR | \
|
|
|
|
ONIG_SYN_OP_ESC_CONTROL_CHARS )
|
|
|
|
|
|
|
|
#define SYN_GNU_REGEX_OP \
|
|
|
|
( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | \
|
|
|
|
ONIG_SYN_OP_POSIX_BRACKET | ONIG_SYN_OP_DECIMAL_BACKREF | \
|
|
|
|
ONIG_SYN_OP_BRACE_INTERVAL | ONIG_SYN_OP_LPAREN_SUBEXP | \
|
|
|
|
ONIG_SYN_OP_VBAR_ALT | \
|
|
|
|
ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF | \
|
|
|
|
ONIG_SYN_OP_QMARK_ZERO_ONE | \
|
|
|
|
ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR | ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR | \
|
|
|
|
ONIG_SYN_OP_ESC_W_WORD | \
|
|
|
|
ONIG_SYN_OP_ESC_B_WORD_BOUND | ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | \
|
|
|
|
ONIG_SYN_OP_ESC_S_WHITE_SPACE | ONIG_SYN_OP_ESC_D_DIGIT | \
|
|
|
|
ONIG_SYN_OP_LINE_ANCHOR )
|
|
|
|
|
|
|
|
#define SYN_GNU_REGEX_BV \
|
|
|
|
( ONIG_SYN_CONTEXT_INDEP_ANCHORS | ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | \
|
|
|
|
ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \
|
|
|
|
ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
|
|
|
|
|
2007-07-23 05:39:30 -04:00
|
|
|
|
|
|
|
#define NCCLASS_FLAGS(cc) ((cc)->flags)
|
|
|
|
#define NCCLASS_FLAG_SET(cc,flag) (NCCLASS_FLAGS(cc) |= (flag))
|
|
|
|
#define NCCLASS_FLAG_CLEAR(cc,flag) (NCCLASS_FLAGS(cc) &= ~(flag))
|
|
|
|
#define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0)
|
|
|
|
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 10:21:48 -05:00
|
|
|
/* cclass node */
|
2007-07-23 05:39:30 -04:00
|
|
|
#define FLAG_NCCLASS_NOT (1<<0)
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 10:21:48 -05:00
|
|
|
|
2007-07-23 05:39:30 -04:00
|
|
|
#define NCCLASS_SET_NOT(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
|
|
|
|
#define NCCLASS_CLEAR_NOT(nd) NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT)
|
|
|
|
#define IS_NCCLASS_NOT(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT)
|
2007-05-22 21:32:08 -04:00
|
|
|
|
2007-07-23 05:39:30 -04:00
|
|
|
typedef struct {
|
|
|
|
int type;
|
|
|
|
/* struct _Node* next; */
|
|
|
|
/* unsigned int flags; */
|
|
|
|
} NodeBase;
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 10:21:48 -05:00
|
|
|
|
|
|
|
typedef struct {
|
2007-07-23 05:39:30 -04:00
|
|
|
NodeBase base;
|
|
|
|
unsigned int flags;
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 10:21:48 -05:00
|
|
|
BitSet bs;
|
2007-07-23 05:39:30 -04:00
|
|
|
BBuf* mbuf; /* multi-byte info or NULL */
|
* ascii.c, euc_jp.c, hash.c, oniggnu.h, oniguruma.h, regcomp.c, regenc.c, regenc.h, regerror.c, regexec.c, reggnu.c, regint.h, regparse.c, regparse.h, sjis.c, st.c, st.h, utf8.c: imported Oni Guruma 3.5.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-28 10:21:48 -05:00
|
|
|
} CClassNode;
|
|
|
|
|
2010-08-25 21:50:07 -04:00
|
|
|
typedef intptr_t OnigStackIndex;
|
2007-05-22 21:32:08 -04:00
|
|
|
|
|
|
|
typedef struct _OnigStackType {
|
|
|
|
unsigned int type;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
UChar *pcode; /* byte code position */
|
|
|
|
UChar *pstr; /* string position */
|
|
|
|
UChar *pstr_prev; /* previous char position of pstr */
|
|
|
|
#ifdef USE_COMBINATION_EXPLOSION_CHECK
|
|
|
|
unsigned int state_check;
|
|
|
|
#endif
|
2012-02-17 02:42:23 -05:00
|
|
|
UChar *pkeep; /* keep pattern position */
|
2007-05-22 21:32:08 -04:00
|
|
|
} state;
|
|
|
|
struct {
|
|
|
|
int count; /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */
|
|
|
|
UChar *pcode; /* byte code position (head of repeated target) */
|
|
|
|
int num; /* repeat id */
|
|
|
|
} repeat;
|
|
|
|
struct {
|
|
|
|
OnigStackIndex si; /* index of stack */
|
|
|
|
} repeat_inc;
|
|
|
|
struct {
|
|
|
|
int num; /* memory num */
|
|
|
|
UChar *pstr; /* start/end position */
|
2013-04-13 07:30:35 -04:00
|
|
|
/* Following information is set, if this stack type is MEM-START */
|
2007-05-22 21:32:08 -04:00
|
|
|
OnigStackIndex start; /* prev. info (for backtrack "(...)*" ) */
|
|
|
|
OnigStackIndex end; /* prev. info (for backtrack "(...)*" ) */
|
|
|
|
} mem;
|
|
|
|
struct {
|
|
|
|
int num; /* null check id */
|
|
|
|
UChar *pstr; /* start position */
|
|
|
|
} null_check;
|
|
|
|
#ifdef USE_SUBEXP_CALL
|
|
|
|
struct {
|
|
|
|
UChar *ret_addr; /* byte code position */
|
|
|
|
int num; /* null check id */
|
|
|
|
UChar *pstr; /* string position */
|
|
|
|
} call_frame;
|
|
|
|
#endif
|
2017-02-11 10:08:33 -05:00
|
|
|
struct {
|
|
|
|
UChar *abs_pstr; /* absent start position */
|
|
|
|
const UChar *end_pstr; /* end position */
|
|
|
|
} absent_pos;
|
2007-05-22 21:32:08 -04:00
|
|
|
} u;
|
|
|
|
} OnigStackType;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void* stack_p;
|
2009-06-29 22:08:54 -04:00
|
|
|
size_t stack_n;
|
2007-05-22 21:32:08 -04:00
|
|
|
OnigOptionType options;
|
|
|
|
OnigRegion* region;
|
2012-02-17 02:42:23 -05:00
|
|
|
const UChar* start; /* search start position */
|
|
|
|
const UChar* gpos; /* global position (for \G: BEGIN_POSITION) */
|
2007-05-22 21:32:08 -04:00
|
|
|
#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
|
2012-02-17 02:42:23 -05:00
|
|
|
OnigPosition best_len; /* for ONIG_OPTION_FIND_LONGEST */
|
2007-05-22 21:32:08 -04:00
|
|
|
UChar* best_s;
|
|
|
|
#endif
|
|
|
|
#ifdef USE_COMBINATION_EXPLOSION_CHECK
|
|
|
|
void* state_check_buff;
|
|
|
|
int state_check_buff_size;
|
|
|
|
#endif
|
|
|
|
} OnigMatchArg;
|
|
|
|
|
|
|
|
|
|
|
|
#define IS_CODE_SB_WORD(enc,code) \
|
|
|
|
(ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2015-11-26 03:31:27 -05:00
|
|
|
typedef struct OnigEndCallListItem {
|
|
|
|
struct OnigEndCallListItem* next;
|
|
|
|
void (*func)(void);
|
|
|
|
} OnigEndCallListItemType;
|
|
|
|
|
|
|
|
extern void onig_add_end_call(void (*func)(void));
|
|
|
|
|
|
|
|
|
2004-03-05 10:31:51 -05:00
|
|
|
#ifdef ONIG_DEBUG
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
short int opcode;
|
2010-11-17 01:21:11 -05:00
|
|
|
const char* name;
|
2004-03-05 10:31:51 -05:00
|
|
|
short int arg_type;
|
|
|
|
} OnigOpInfoType;
|
|
|
|
|
|
|
|
extern OnigOpInfoType OnigOpInfo[];
|
|
|
|
|
2015-11-26 03:31:27 -05:00
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
extern void onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar* bpend, UChar** nextp, OnigEncoding enc);
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
# ifdef ONIG_DEBUG_STATISTICS
|
|
|
|
extern void onig_statistics_init(void);
|
|
|
|
extern void onig_print_statistics(FILE* f);
|
|
|
|
# endif
|
2004-03-05 10:31:51 -05:00
|
|
|
#endif
|
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
extern UChar* onig_error_code_to_format(OnigPosition code);
|
|
|
|
extern void onig_vsnprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, va_list args);
|
|
|
|
extern void onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...);
|
|
|
|
extern int onig_bbuf_init(BBuf* buf, OnigDistance size);
|
|
|
|
extern int onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo);
|
|
|
|
#ifdef RUBY
|
|
|
|
extern int onig_compile_ruby(regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo, const char *sourcefile, int sourceline);
|
|
|
|
#endif
|
|
|
|
extern void onig_transfer(regex_t* to, regex_t* from);
|
|
|
|
extern int onig_is_code_in_cc(OnigEncoding enc, OnigCodePoint code, CClassNode* cc);
|
|
|
|
extern int onig_is_code_in_cc_len(int enclen, OnigCodePoint code, CClassNode* cc);
|
2004-03-05 10:31:51 -05:00
|
|
|
|
2007-05-22 21:32:08 -04:00
|
|
|
/* strend hash */
|
|
|
|
typedef void hash_table_type;
|
2007-06-26 03:28:42 -04:00
|
|
|
#ifdef RUBY
|
2016-12-10 12:47:04 -05:00
|
|
|
# include "ruby/st.h"
|
2007-06-26 03:28:42 -04:00
|
|
|
#else
|
2016-12-10 12:47:04 -05:00
|
|
|
# include "st.h"
|
2007-06-26 03:28:42 -04:00
|
|
|
#endif
|
2016-12-10 12:47:04 -05:00
|
|
|
typedef st_data_t hash_data_type;
|
2007-05-22 21:32:08 -04:00
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
extern hash_table_type* onig_st_init_strend_table_with_size(st_index_t size);
|
|
|
|
extern int onig_st_lookup_strend(hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value);
|
|
|
|
extern int onig_st_insert_strend(hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value);
|
2007-05-22 21:32:08 -04:00
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
#ifdef RUBY
|
|
|
|
extern size_t onig_memsize(const regex_t *reg);
|
|
|
|
extern size_t onig_region_memsize(const struct re_registers *regs);
|
|
|
|
#endif
|
2010-08-14 02:17:38 -04:00
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2010-07-21 17:38:25 -04:00
|
|
|
|
2016-12-10 12:47:04 -05:00
|
|
|
#endif /* ONIGMO_REGINT_H */
|