Index: EcnlProtoTool/trunk/onigmo-6.1.3/src/regint.h
===================================================================
--- EcnlProtoTool/trunk/onigmo-5.15.0/src/regint.h	(revision 321)
+++ EcnlProtoTool/trunk/onigmo-6.1.3/src/regint.h	(revision 331)
@@ -1,4 +1,4 @@
-#ifndef REGINT_H
-#define REGINT_H
+#ifndef ONIGMO_REGINT_H
+#define ONIGMO_REGINT_H
 /**********************************************************************
   regint.h -  Onigmo (Oniguruma-mod) (regular expression library)
@@ -6,5 +6,5 @@
 /*-
  * Copyright (c) 2002-2013  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
- * Copyright (c) 2011-2014  K.Takata  <kentkt AT csc DOT jp>
+ * Copyright (c) 2011-2016  K.Takata  <kentkt AT csc DOT jp>
  * All rights reserved.
  *
@@ -36,4 +36,5 @@
 /* #define ONIG_DEBUG_SEARCH */
 /* #define ONIG_DEBUG_MATCH */
+/* #define ONIG_DEBUG_MEMLEAK */
 /* #define ONIG_DONT_OPTIMIZE */
 
@@ -43,23 +44,23 @@
 #if defined(ONIG_DEBUG_PARSE_TREE) || defined(ONIG_DEBUG_MATCH) || \
     defined(ONIG_DEBUG_SEARCH) || defined(ONIG_DEBUG_COMPILE) || \
-    defined(ONIG_DEBUG_STATISTICS)
-#ifndef ONIG_DEBUG
-#define ONIG_DEBUG
-#endif
+    defined(ONIG_DEBUG_STATISTICS) || defined(ONIG_DEBUG_MEMLEAK)
+# ifndef ONIG_DEBUG
+#  define ONIG_DEBUG
+# endif
 #endif
 
 #ifndef UNALIGNED_WORD_ACCESS
-#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
-    defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
-    defined(__powerpc64__) || \
-    defined(__mc68020__)
-#define UNALIGNED_WORD_ACCESS 1
-#else
-#define UNALIGNED_WORD_ACCESS 0
-#endif
+# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
+     defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
+     defined(__powerpc64__) || \
+     defined(__mc68020__)
+#  define UNALIGNED_WORD_ACCESS 1
+# else
+#  define UNALIGNED_WORD_ACCESS 0
+# endif
 #endif
 
 #if UNALIGNED_WORD_ACCESS
-#define PLATFORM_UNALIGNED_WORD_ACCESS
+# define PLATFORM_UNALIGNED_WORD_ACCESS
 #endif
 
@@ -74,177 +75,163 @@
 #define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE     /* /\n$/ =~ "\n" */
 #define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
-/* #define USE_RECOMPILE_API */
 /* !!! moved to regenc.h. */ /* #define USE_CRNL_AS_LINE_TERMINATOR */
 #define USE_NO_INVALID_QUANTIFIER
 
 /* internal config */
-#define USE_PARSE_TREE_NODE_RECYCLE
-#define USE_OP_PUSH_OR_JUMP_EXACT
+/* #define USE_OP_PUSH_OR_JUMP_EXACT */
 #define USE_QTFR_PEEK_NEXT
 #define USE_ST_LIBRARY
-#define USE_SHARED_CCLASS_TABLE
 #define USE_SUNDAY_QUICK_SEARCH
 
 #define INIT_MATCH_STACK_SIZE                     160
 #define DEFAULT_MATCH_STACK_LIMIT_SIZE              0 /* unlimited */
+#define DEFAULT_PARSE_DEPTH_LIMIT                4096
+
+#define OPT_EXACT_MAXLEN   24
 
 /* check config */
 #if defined(USE_PERL_SUBEXP_CALL) || defined(USE_CAPITAL_P_NAMED_GROUP)
-#if !defined(USE_NAMED_GROUP) || !defined(USE_SUBEXP_CALL)
-#error USE_NAMED_GROUP and USE_SUBEXP_CALL must be defined.
-#endif
+# if !defined(USE_NAMED_GROUP) || !defined(USE_SUBEXP_CALL)
+#  error USE_NAMED_GROUP and USE_SUBEXP_CALL must be defined.
+# endif
 #endif
 
 #if defined(__GNUC__)
-#  define ARG_UNUSED  __attribute__ ((unused))
+# define ARG_UNUSED  __attribute__ ((unused))
 #else
-#  define ARG_UNUSED
-#endif
+# define ARG_UNUSED
+#endif
+
+#if !defined(RUBY) && defined(RUBY_EXPORT)
+# define RUBY
+#endif
+#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>
 
 /* */
 /* escape other system UChar definition */
-#include "config.h"
 #ifdef ONIG_ESCAPE_UCHAR_COLLISION
-#undef ONIG_ESCAPE_UCHAR_COLLISION
+# undef ONIG_ESCAPE_UCHAR_COLLISION
 #endif
 
 #define USE_WORD_BEGIN_END          /* "\<": word-begin, "\>": word-end */
-#define USE_CAPTURE_HISTORY
+#ifdef RUBY
+# undef USE_CAPTURE_HISTORY
+#else
+# define USE_CAPTURE_HISTORY
+#endif
 #define USE_VARIABLE_META_CHARS
-#define USE_POSIX_API_REGION_OPTION     /* needed for POSIX API support */
 #define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
 /* #define USE_COMBINATION_EXPLOSION_CHECK */     /* (X*)* */
 
-/* multithread config */
-/* #define USE_MULTI_THREAD_SYSTEM */
-/* #define USE_DEFAULT_MULTI_THREAD_SYSTEM */
-
-#if defined(USE_MULTI_THREAD_SYSTEM) \
-  && defined(USE_DEFAULT_MULTI_THREAD_SYSTEM)
-
-#if defined(_WIN32) && !defined(MUSL_LIBC)
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-extern CRITICAL_SECTION gOnigMutex;
-#define THREAD_SYSTEM_INIT      InitializeCriticalSection(&gOnigMutex)
-#define THREAD_SYSTEM_END       DeleteCriticalSection(&gOnigMutex)
-#define THREAD_ATOMIC_START     EnterCriticalSection(&gOnigMutex)
-#define THREAD_ATOMIC_END       LeaveCriticalSection(&gOnigMutex)
-#define THREAD_PASS             Sleep(0)
-#else /* _WIN32 */
-#include <pthread.h>
-#include <sched.h>
-extern pthread_mutex_t gOnigMutex;
-#define THREAD_SYSTEM_INIT      pthread_mutex_init(&gOnigMutex, NULL)
-#define THREAD_SYSTEM_END       pthread_mutex_destroy(&gOnigMutex)
-#define THREAD_ATOMIC_START     pthread_mutex_lock(&gOnigMutex)
-#define THREAD_ATOMIC_END       pthread_mutex_unlock(&gOnigMutex)
-#define THREAD_PASS             sched_yield()
-#endif /* _WIN32 */
-
-#else /* USE_DEFAULT_MULTI_THREAD_SYSTEM */
-
-#ifndef THREAD_SYSTEM_INIT
-#define THREAD_SYSTEM_INIT      /* depend on thread system */
-#endif
-#ifndef THREAD_SYSTEM_END
-#define THREAD_SYSTEM_END       /* depend on thread system */
-#endif
-#ifndef THREAD_ATOMIC_START
-#define THREAD_ATOMIC_START     /* depend on thread system */
-#endif
-#ifndef THREAD_ATOMIC_END
-#define THREAD_ATOMIC_END       /* depend on thread system */
-#endif
-#ifndef THREAD_PASS
-#define THREAD_PASS             /* depend on thread system */
-#endif
-
-#endif /* USE_DEFAULT_MULTI_THREAD_SYSTEM */
 
 #ifndef xmalloc
-#define xmalloc     malloc
-#define xrealloc    realloc
-#define xcalloc     calloc
-#define xfree       free
-#endif
-
-#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
+# define xmalloc     malloc
+# define xrealloc    realloc
+# define xcalloc     calloc
+# define xfree       free
+#endif
+
+#ifdef RUBY
+
+# 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
 /* */
-#define onig_st_is_member              st_is_member
+# define onig_st_is_member              st_is_member
+
+#endif /* RUBY */
 
 #define STATE_CHECK_STRING_THRESHOLD_LEN             7
 #define STATE_CHECK_BUFF_MAX_SIZE               0x4000
 
-#define THREAD_PASS_LIMIT_COUNT     8
 #define xmemset     memset
 #define xmemcpy     memcpy
 #define xmemmove    memmove
 
-#if defined(_WIN32) && !defined(__GNUC__) && !defined(MUSL_LIBC)
-#define xalloca     _alloca
-#define xvsnprintf  _vsnprintf
+#if ((defined(RUBY_MSVCRT_VERSION) && RUBY_MSVCRT_VERSION >= 90) \
+        || (!defined(RUBY_MSVCRT_VERSION) && defined(_WIN32))) \
+    && !defined(__GNUC__)
+# 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)
 #else
-/*#define xalloca     alloca*/
-#define xvsnprintf  vsnprintf
-#endif
-
-
-#if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM)
-#define ONIG_STATE_INC(reg) (reg)->state++
-#define ONIG_STATE_DEC(reg) (reg)->state--
-
-#define ONIG_STATE_INC_THREAD(reg) do {\
-  THREAD_ATOMIC_START;\
-  (reg)->state++;\
-  THREAD_ATOMIC_END;\
-} while(0)
-#define ONIG_STATE_DEC_THREAD(reg) do {\
-  THREAD_ATOMIC_START;\
-  (reg)->state--;\
-  THREAD_ATOMIC_END;\
-} while(0)
-#else
-#define ONIG_STATE_INC(reg)         /* Nothing */
-#define ONIG_STATE_DEC(reg)         /* Nothing */
-#define ONIG_STATE_INC_THREAD(reg)  /* Nothing */
-#define ONIG_STATE_DEC_THREAD(reg)  /* Nothing */
-#endif /* USE_RECOMPILE_API && USE_MULTI_THREAD_SYSTEM */
-
-#ifdef HAVE_STDLIB_H
+# define xalloca     alloca
+# define xvsnprintf  vsnprintf
+# define xsnprintf   snprintf
+# define xstrcat(dest,src,size)	  strcat(dest,src)
+#endif
+
+#if defined(ONIG_DEBUG_MEMLEAK) && defined(_MSC_VER)
+# define _CRTDBG_MAP_ALLOC
+# include <malloc.h>
+# include <crtdbg.h>
+#endif
+
 #include <stdlib.h>
-#endif
 
 #if defined(HAVE_ALLOCA_H) && (defined(_AIX) || !defined(__GNUC__))
-#include <alloca.h>
-#endif
-
-#ifdef HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif
+# include <alloca.h>
+#endif
+
+#include <string.h>
 
 #include <ctype.h>
 #ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
+# include <sys/types.h>
 #endif
 
@@ -257,10 +244,8 @@
 #endif
 
-#ifdef STDC_HEADERS
-# include <stddef.h>
-#endif
-
-#if defined(_WIN32) && !defined(MUSL_LIBC)
-#include <malloc.h>	/* for alloca() */
+#include <stddef.h>
+
+#ifdef _WIN32
+# include <malloc.h>	/* for alloca() */
 #endif
 
@@ -269,36 +254,42 @@
 #endif
 
-#if defined(_WIN32) && !defined(MUSL_LIBC)
-#if defined(_MSC_VER) && (_MSC_VER < 1300)
-#ifndef _INTPTR_T_DEFINED
-#define _INTPTR_T_DEFINED
+#ifdef _WIN32
+# if defined(_MSC_VER) && (_MSC_VER < 1300)
+#  ifndef _INTPTR_T_DEFINED
+#   define _INTPTR_T_DEFINED
 typedef int intptr_t;
-#endif
-#ifndef _UINTPTR_T_DEFINED
-#define _UINTPTR_T_DEFINED
+#  endif
+#  ifndef _UINTPTR_T_DEFINED
+#   define _UINTPTR_T_DEFINED
 typedef unsigned int uintptr_t;
-#endif
-#endif
+#  endif
+# endif
 #endif /* _WIN32 */
 
 #ifndef PRIdPTR
-#ifdef _WIN64
-#define PRIdPTR	"I64d"
-#define PRIuPTR	"I64u"
-#define PRIxPTR	"I64x"
-#else
-#define PRIdPTR	"ld"
-#define PRIuPTR	"lu"
-#define PRIxPTR	"lx"
-#endif
+# ifdef _WIN64
+#  define PRIdPTR	"I64d"
+#  define PRIuPTR	"I64u"
+#  define PRIxPTR	"I64x"
+# else
+#  define PRIdPTR	"ld"
+#  define PRIuPTR	"lu"
+#  define PRIxPTR	"lx"
+# endif
+#endif
+
+#ifndef PRIdPTRDIFF
+# define PRIdPTRDIFF PRIdPTR
 #endif
 
 #include "regenc.h"
 
+RUBY_SYMBOL_EXPORT_BEGIN
+
 #ifdef MIN
-#undef MIN
+# undef MIN
 #endif
 #ifdef MAX
-#undef MAX
+# undef MAX
 #endif
 #define MIN(a,b) (((a)>(b))?(b):(a))
@@ -315,5 +306,5 @@
 #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
 
-#define PLATFORM_GET_INC(val,p,type) do{\
+# define PLATFORM_GET_INC(val,p,type) do{\
   val  = *(type* )p;\
   (p) += sizeof(type);\
@@ -322,5 +313,5 @@
 #else
 
-#define PLATFORM_GET_INC(val,p,type) do{\
+# define PLATFORM_GET_INC(val,p,type) do{\
   xmemcpy(&val, (p), sizeof(type));\
   (p) += sizeof(type);\
@@ -328,7 +319,7 @@
 
 /* sizeof(OnigCodePoint) */
-#define WORD_ALIGNMENT_SIZE     SIZEOF_LONG
-
-#define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
+# define WORD_ALIGNMENT_SIZE     SIZEOF_LONG
+
+# define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
   (pad_size) = WORD_ALIGNMENT_SIZE \
                - ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
@@ -336,5 +327,5 @@
 } while (0)
 
-#define ALIGNMENT_RIGHT(addr) do {\
+# define ALIGNMENT_RIGHT(addr) do {\
   (addr) += (WORD_ALIGNMENT_SIZE - 1);\
   (addr) -= ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
@@ -400,5 +391,4 @@
 #define IS_NOTBOS(option)         ((option) & ONIG_OPTION_NOTBOS)
 #define IS_NOTEOS(option)         ((option) & ONIG_OPTION_NOTEOS)
-#define IS_POSIX_REGION(option)   ((option) & ONIG_OPTION_POSIX_REGION)
 #define IS_ASCII_RANGE(option)    ((option) & ONIG_OPTION_ASCII_RANGE)
 #define IS_POSIX_BRACKET_ALL_RANGE(option)  ((option) & ONIG_OPTION_POSIX_BRACKET_ALL_RANGE)
@@ -583,5 +573,4 @@
   OP_CCLASS_MB_NOT,
   OP_CCLASS_MIX_NOT,
-  OP_CCLASS_NODE,       /* pointer to CClassNode node */
 
   OP_ANYCHAR,                 /* "."  */
@@ -612,5 +601,4 @@
   OP_SEMI_END_BUF,
   OP_BEGIN_POSITION,
-  OP_BEGIN_POS_OR_LINE,   /* used for implicit anchor optimization */
 
   OP_BACKREF1,
@@ -657,4 +645,7 @@
   OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
   OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end   */
+  OP_PUSH_ABSENT_POS,      /* (?~...)  start */
+  OP_ABSENT,               /* (?~...)  start of inner loop */
+  OP_ABSENT_END,           /* (?~...)  end   */
 
   OP_CALL,                 /* \g<name> */
@@ -744,10 +735,13 @@
 #define SIZE_OP_RETURN                  SIZE_OPCODE
 #define SIZE_OP_CONDITION              (SIZE_OPCODE + SIZE_MEMNUM + SIZE_RELADDR)
+#define SIZE_OP_PUSH_ABSENT_POS         SIZE_OPCODE
+#define SIZE_OP_ABSENT                 (SIZE_OPCODE + SIZE_RELADDR)
+#define SIZE_OP_ABSENT_END              SIZE_OPCODE
 
 #ifdef USE_COMBINATION_EXPLOSION_CHECK
-#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)
+# 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)
 #endif
 
@@ -797,11 +791,8 @@
 /* cclass node */
 #define FLAG_NCCLASS_NOT           (1<<0)
-#define FLAG_NCCLASS_SHARE         (1<<1)
 
 #define NCCLASS_SET_NOT(nd)     NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
-#define NCCLASS_SET_SHARE(nd)   NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_SHARE)
 #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)
-#define IS_NCCLASS_SHARE(nd)    IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_SHARE)
 
 typedef struct {
@@ -858,4 +849,8 @@
     } call_frame;
 #endif
+    struct {
+      UChar *abs_pstr;        /* absent start position */
+      const UChar *end_pstr;  /* end position */
+    } absent_pos;
   } u;
 } OnigStackType;
@@ -901,51 +896,43 @@
 
 
-extern void onig_print_compiled_byte_code P_((FILE* f, UChar* bp, UChar** nextp, OnigEncoding enc));
-
-#ifdef ONIG_DEBUG_STATISTICS
-extern void onig_statistics_init P_((void));
-extern void onig_print_statistics P_((FILE* f));
-#endif
-#endif
-
-extern UChar* onig_error_code_to_format P_((OnigPosition code));
-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, OnigDistance size));
-extern int  onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo));
-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_transfer P_((regex_t* to, regex_t* from));
-extern int  onig_is_code_in_cc P_((OnigEncoding enc, OnigCodePoint code, CClassNode* cc));
-extern int  onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, CClassNode* cc));
+extern void onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar* bpend, UChar** nextp, OnigEncoding enc);
+
+# ifdef ONIG_DEBUG_STATISTICS
+extern void onig_statistics_init(void);
+extern void onig_print_statistics(FILE* f);
+# endif
+#endif
+
+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);
 
 /* strend hash */
 typedef void hash_table_type;
-typedef uintptr_t hash_data_type;
-
-extern hash_table_type* onig_st_init_strend_table_with_size P_((int size));
-extern int onig_st_lookup_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value));
-extern int onig_st_insert_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value));
-
-/* encoding property management */
-#define PROPERTY_LIST_ADD_PROP(Name, CR) \
-  r = onigenc_property_list_add_property((UChar* )Name, CR,\
-	      &PropertyNameTable, &PropertyList, &PropertyListNum,\
-	      &PropertyListSize);\
-  if (r != 0) goto end
-
-#define PROPERTY_LIST_INIT_CHECK \
-  if (PropertyInited == 0) {\
-    int r = onigenc_property_list_init(init_property_list);\
-    if (r != 0) return r;\
-  }
-
-extern int onigenc_property_list_add_property P_((UChar* name, const OnigCodePoint* prop, hash_table_type **table, const OnigCodePoint*** plist, int *pnum, int *psize));
-
-typedef int (*ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE)(void);
-
-extern int onigenc_property_list_init P_((ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE));
-
-extern size_t onig_memsize P_((const regex_t *reg));
-extern size_t onig_region_memsize P_((const struct re_registers *regs));
-
-#endif /* REGINT_H */
+#ifdef RUBY
+# include "ruby/st.h"
+#else
+# include "st.h"
+#endif
+typedef st_data_t hash_data_type;
+
+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);
+
+#ifdef RUBY
+extern size_t onig_memsize(const regex_t *reg);
+extern size_t onig_region_memsize(const struct re_registers *regs);
+#endif
+
+RUBY_SYMBOL_EXPORT_END
+
+#endif /* ONIGMO_REGINT_H */
