[前][次][番号順一覧][スレッド一覧]

ruby-changes:44973

From: naruse <ko1@a...>
Date: Sun, 11 Dec 2016 02:47:18 +0900 (JST)
Subject: [ruby-changes:44973] naruse:r57045 (trunk): Merge Onigmo 6.0.0

naruse	2016-12-11 02:47:04 +0900 (Sun, 11 Dec 2016)

  New Revision: 57045

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57045

  Log:
    Merge Onigmo 6.0.0
    
    * https://github.com/k-takata/Onigmo/blob/Onigmo-6.0.0/HISTORY
    * fix for ruby 2.4: https://github.com/k-takata/Onigmo/pull/78
    * suppress warning: https://github.com/k-takata/Onigmo/pull/79
    * include/ruby/oniguruma.h: include onigmo.h.
    * template/encdb.h.tmpl: ignore duplicated definition of EUC-CN in
      enc/euc_kr.c. It is defined in enc/gb2313.c with CRuby macro.

  Added files:
    trunk/include/ruby/onigmo.h
  Modified files:
    trunk/NEWS
    trunk/enc/ascii.c
    trunk/enc/big5.c
    trunk/enc/cp949.c
    trunk/enc/emacs_mule.c
    trunk/enc/euc_jp.c
    trunk/enc/euc_kr.c
    trunk/enc/euc_tw.c
    trunk/enc/gb18030.c
    trunk/enc/gbk.c
    trunk/enc/iso_8859_1.c
    trunk/enc/iso_8859_10.c
    trunk/enc/iso_8859_11.c
    trunk/enc/iso_8859_13.c
    trunk/enc/iso_8859_14.c
    trunk/enc/iso_8859_15.c
    trunk/enc/iso_8859_16.c
    trunk/enc/iso_8859_2.c
    trunk/enc/iso_8859_3.c
    trunk/enc/iso_8859_4.c
    trunk/enc/iso_8859_5.c
    trunk/enc/iso_8859_6.c
    trunk/enc/iso_8859_7.c
    trunk/enc/iso_8859_8.c
    trunk/enc/iso_8859_9.c
    trunk/enc/koi8_r.c
    trunk/enc/koi8_u.c
    trunk/enc/mktable.c
    trunk/enc/shift_jis.c
    trunk/enc/unicode.c
    trunk/enc/us_ascii.c
    trunk/enc/utf_16be.c
    trunk/enc/utf_16le.c
    trunk/enc/utf_32be.c
    trunk/enc/utf_32le.c
    trunk/enc/utf_8.c
    trunk/enc/windows_1250.c
    trunk/enc/windows_1251.c
    trunk/enc/windows_1252.c
    trunk/enc/windows_1253.c
    trunk/enc/windows_1254.c
    trunk/enc/windows_1257.c
    trunk/enc/windows_31j.c
    trunk/include/ruby/oniguruma.h
    trunk/re.c
    trunk/regcomp.c
    trunk/regenc.c
    trunk/regenc.h
    trunk/regerror.c
    trunk/regexec.c
    trunk/regint.h
    trunk/regparse.c
    trunk/regparse.h
    trunk/regsyntax.c
    trunk/template/encdb.h.tmpl
    trunk/tool/enc-unicode.rb
Index: regexec.c
===================================================================
--- regexec.c	(revision 57044)
+++ regexec.c	(revision 57045)
@@ -3,7 +3,7 @@ https://github.com/ruby/ruby/blob/trunk/regexec.c#L3
 **********************************************************************/
 /*-
  * Copyright (c) 2002-2008  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.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -30,33 +30,39 @@ https://github.com/ruby/ruby/blob/trunk/regexec.c#L30
 
 #include "regint.h"
 
-/* #define USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE */
+#ifdef RUBY
+# undef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
+#else
+# define USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
+#endif
 
-#ifndef USE_DIRECT_THREADED_VM
+#ifndef USE_TOKEN_THREADED_VM
 # ifdef __GNUC__
-#   define USE_DIRECT_THREADED_VM 1
+#  define USE_TOKEN_THREADED_VM 1
 # else
-#   define USE_DIRECT_THREADED_VM 0
+#  define USE_TOKEN_THREADED_VM 0
 # endif
 #endif
 
-#define ENC_DUMMY_FLAG (1<<24)
+#ifdef RUBY
+# define ENC_DUMMY_FLAG (1<<24)
 static inline int
 rb_enc_asciicompat(OnigEncoding enc)
 {
-    return ONIGENC_MBC_MINLEN(enc)==1 && !((enc)->ruby_encoding_index & ENC_DUMMY_FLAG);
+  return ONIGENC_MBC_MINLEN(enc)==1 && !((enc)->ruby_encoding_index & ENC_DUMMY_FLAG);
 }
-#undef ONIGENC_IS_MBC_ASCII_WORD
-#define ONIGENC_IS_MBC_ASCII_WORD(enc,s,end) \
+# undef ONIGENC_IS_MBC_ASCII_WORD
+# define ONIGENC_IS_MBC_ASCII_WORD(enc,s,end) \
     (rb_enc_asciicompat(enc) ? (ISALNUM(*s) || *s=='_') : \
    onigenc_ascii_is_code_ctype( \
 	ONIGENC_MBC_TO_CODE(enc,s,end),ONIGENC_CTYPE_WORD,enc))
+#endif /* RUBY */
 
 #ifdef USE_CRNL_AS_LINE_TERMINATOR
-#define ONIGENC_IS_MBC_CRNL(enc,p,end) \
+# define ONIGENC_IS_MBC_CRNL(enc,p,end) \
   (ONIGENC_MBC_TO_CODE(enc,p,end) == 13 && \
    ONIGENC_MBC_TO_CODE(enc,(p+enclen(enc,p,end)),end) == 10)
-#define ONIGENC_IS_MBC_NEWLINE_EX(enc,p,start,end,option,check_prev) \
+# define ONIGENC_IS_MBC_NEWLINE_EX(enc,p,start,end,option,check_prev) \
   is_mbc_newline_ex((enc),(p),(start),(end),(option),(check_prev))
 static int
 is_mbc_newline_ex(OnigEncoding enc, const UChar *p, const UChar *start,
@@ -90,7 +96,7 @@ is_mbc_newline_ex(OnigEncoding enc, cons https://github.com/ruby/ruby/blob/trunk/regexec.c#L96
   }
 }
 #else /* USE_CRNL_AS_LINE_TERMINATOR */
-#define ONIGENC_IS_MBC_NEWLINE_EX(enc,p,start,end,option,check_prev) \
+# define ONIGENC_IS_MBC_NEWLINE_EX(enc,p,start,end,option,check_prev) \
   ONIGENC_IS_MBC_NEWLINE((enc), (p), (end))
 #endif /* USE_CRNL_AS_LINE_TERMINATOR */
 
@@ -105,7 +111,7 @@ history_tree_clear(OnigCaptureTreeNode* https://github.com/ruby/ruby/blob/trunk/regexec.c#L111
   if (IS_NOT_NULL(node)) {
     for (i = 0; i < node->num_childs; i++) {
       if (IS_NOT_NULL(node->childs[i])) {
-        history_tree_free(node->childs[i]);
+	history_tree_free(node->childs[i]);
       }
     }
     for (i = 0; i < node->allocated; i++) {
@@ -156,7 +162,7 @@ history_node_new(void) https://github.com/ruby/ruby/blob/trunk/regexec.c#L162
 static int
 history_tree_add_child(OnigCaptureTreeNode* parent, OnigCaptureTreeNode* child)
 {
-#define HISTORY_TREE_INIT_ALLOC_SIZE  8
+# define HISTORY_TREE_INIT_ALLOC_SIZE  8
 
   if (parent->num_childs >= parent->allocated) {
     int n, i;
@@ -164,15 +170,15 @@ history_tree_add_child(OnigCaptureTreeNo https://github.com/ruby/ruby/blob/trunk/regexec.c#L170
     if (IS_NULL(parent->childs)) {
       n = HISTORY_TREE_INIT_ALLOC_SIZE;
       parent->childs =
-        (OnigCaptureTreeNode** )xmalloc(sizeof(OnigCaptureTreeNode*) * n);
+	(OnigCaptureTreeNode** )xmalloc(sizeof(OnigCaptureTreeNode*) * n);
       CHECK_NULL_RETURN_MEMERR(parent->childs);
     }
     else {
       OnigCaptureTreeNode** tmp;
       n = parent->allocated * 2;
       tmp =
-        (OnigCaptureTreeNode** )xrealloc(parent->childs,
-                                         sizeof(OnigCaptureTreeNode*) * n);
+	(OnigCaptureTreeNode** )xrealloc(parent->childs,
+					 sizeof(OnigCaptureTreeNode*) * n);
       if (tmp == 0) {
 	history_tree_clear(parent);
 	return ONIGERR_MEMORY;
@@ -348,7 +354,7 @@ onig_region_free(OnigRegion* r, int free https://github.com/ruby/ruby/blob/trunk/regexec.c#L354
 }
 
 extern void
-onig_region_copy(OnigRegion* to, OnigRegion* from)
+onig_region_copy(OnigRegion* to, const OnigRegion* from)
 {
 #define RREGC_SIZE   (sizeof(int) * from->num_regs)
   int i, r;
@@ -404,7 +410,7 @@ onig_region_copy(OnigRegion* to, OnigReg https://github.com/ruby/ruby/blob/trunk/regexec.c#L410
 #define STK_MASK_MEM_END_OR_MARK   0x8000  /* MEM_END or MEM_END_MARK */
 
 #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
-#define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\
+# define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\
   (msa).stack_p  = (void* )0;\
   (msa).options  = (arg_option);\
   (msa).region   = (arg_region);\
@@ -413,7 +419,7 @@ onig_region_copy(OnigRegion* to, OnigReg https://github.com/ruby/ruby/blob/trunk/regexec.c#L419
   (msa).best_len = ONIG_MISMATCH;\
 } while(0)
 #else
-#define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\
+# define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\
   (msa).stack_p  = (void* )0;\
   (msa).options  = (arg_option);\
   (msa).region   = (arg_region);\
@@ -424,9 +430,9 @@ onig_region_copy(OnigRegion* to, OnigReg https://github.com/ruby/ruby/blob/trunk/regexec.c#L430
 
 #ifdef USE_COMBINATION_EXPLOSION_CHECK
 
-#define STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE  16
+# define STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE  16
 
-#define STATE_CHECK_BUFF_INIT(msa, str_len, offset, state_num) do {	\
+# define STATE_CHECK_BUFF_INIT(msa, str_len, offset, state_num) do {	\
   if ((state_num) > 0 && str_len >= STATE_CHECK_STRING_THRESHOLD_LEN) {\
     unsigned int size = (unsigned int )(((str_len) + 1) * (state_num) + 7) >> 3;\
     offset = ((offset) * (state_num)) >> 3;\
@@ -452,14 +458,14 @@ onig_region_copy(OnigRegion* to, OnigReg https://github.com/ruby/ruby/blob/trunk/regexec.c#L458
   }\
   } while(0)
 
-#define MATCH_ARG_FREE(msa) do {\
+# define MATCH_ARG_FREE(msa) do {\
   if ((msa).stack_p) xfree((msa).stack_p);\
   if ((msa).state_check_buff_size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) { \
     if ((msa).state_check_buff) xfree((msa).state_check_buff);\
   }\
 } while(0)
 #else /* USE_COMBINATION_EXPLOSION_CHECK */
-#define MATCH_ARG_FREE(msa)  if ((msa).stack_p) xfree((msa).stack_p)
+# define MATCH_ARG_FREE(msa)  if ((msa).stack_p) xfree((msa).stack_p)
 #endif /* USE_COMBINATION_EXPLOSION_CHECK */
 
 
@@ -548,9 +554,9 @@ stack_double(OnigStackType** arg_stk_bas https://github.com/ruby/ruby/blob/trunk/regexec.c#L554
     n *= 2;
     if (limit_size != 0 && n > limit_size) {
       if ((unsigned int )(stk_end - stk_base) == limit_size)
-        return ONIGERR_MATCH_STACK_LIMIT_OVER;
+	return ONIGERR_MATCH_STACK_LIMIT_OVER;
       else
-        n = limit_size;
+	n = limit_size;
     }
     x = (OnigStackType* )xrealloc(stk_base, sizeof(OnigStackType) * n);
     if (IS_NULL(x)) {
@@ -587,9 +593,9 @@ stack_double(OnigStackType** arg_stk_bas https://github.com/ruby/ruby/blob/trunk/regexec.c#L593
 #define IS_TO_VOID_TARGET(stk) (((stk)->type & STK_MASK_TO_VOID_TARGET) != 0)
 
 #ifdef USE_COMBINATION_EXPLOSION_CHECK
-#define STATE_CHECK_POS(s,snum) \
+# define STATE_CHECK_POS(s,snum) \
   (((s) - str) * num_comb_exp_check + ((snum) - 1))
-#define STATE_CHECK_VAL(v,snum) do {\
+# define STATE_CHECK_VAL(v,snum) do {\
   if (state_check_buff != NULL) {\
     int x = STATE_CHECK_POS(s,snum);\
     (v) = state_check_buff[x/8] & (1<<(x%8));\
@@ -598,13 +604,13 @@ stack_double(OnigStackType** arg_stk_bas https://github.com/ruby/ruby/blob/trunk/regexec.c#L604
 } while(0)
 
 
-#define ELSE_IF_STATE_CHECK_MARK(stk) \
+# define ELSE_IF_STATE_CHECK_MARK(stk) \
   else if ((stk)->type == STK_STATE_CHECK_MARK) { \
     int x = STATE_CHECK_POS(stk->u.state.pstr, stk->u.state.state_check);\
     state_check_buff[x/8] |= (1<<(x%8));				\
   }
 
-#define STACK_PUSH(stack_type,pat,s,sprev,keep) do {\
+# define STACK_PUSH(stack_type,pat,s,sprev,keep) do {\
   STACK_ENSURE(1);\
   stk->type = (stack_type);\
   stk->u.state.pcode     = (pat);\
@@ -615,14 +621,14 @@ stack_double(OnigStackType** arg_stk_bas https://github.com/ruby/ruby/blob/trunk/regexec.c#L621
   STACK_INC;\
 } while(0)
 
-#define STACK_PUSH_ENSURED(stack_type,pat) do {\
+# define STACK_PUSH_ENSURED(stack_type,pat) do {\
   stk->type = (stack_type);\
   stk->u.state.pcode = (pat);\
   stk->u.state.state_check = 0;\
   STACK_INC;\
 } while(0)
 
-#define STACK_PUSH_ALT_WITH_STATE_CHECK(pat,s,sprev,snum,keep) do {\
+# define STACK_PUSH_ALT_WITH_STATE_CHECK(pat,s,sprev,snum,keep) do {\
   STACK_ENSURE(1);\
   stk->type = STK_ALT;\
   stk->u.state.pcode     = (pat);\
@@ -633,7 +639,7 @@ stack_double(OnigStackType** arg_stk_bas https://github.com/ruby/ruby/blob/trunk/regexec.c#L639
   STACK_INC;\
 } while(0)
 
-#define STACK_PUSH_STATE_CHECK(s,snum) do {\
+# define STACK_PUSH_STATE_CHECK(s,snum) do {\
   if (state_check_buff != NULL) {\
     STACK_ENSURE(1);\
     stk->type = STK_STATE_CHECK_MARK;\
@@ -645,9 +651,9 @@ stack_double(OnigStackType** arg_stk_bas https://github.com/ruby/ruby/blob/trunk/regexec.c#L651
 
 #else /* USE_COMBINATION_EXPLOSION_CHECK */
 
-#define ELSE_IF_STATE_CHECK_MARK(stk)
+# define ELSE_IF_STATE_CHECK_MARK(stk)
 
-#define STACK_PUSH(stack_type,pat,s,sprev,keep) do {\
+# define STACK_PUSH(stack_type,pat,s,sprev,keep) do {\
   STACK_ENSURE(1);\
   stk->type = (stack_type);\
   stk->u.state.pcode     = (pat);\
@@ -657,7 +663,7 @@ stack_double(OnigStackType** arg_stk_bas https://github.com/ruby/ruby/blob/trunk/regexec.c#L663
   STACK_INC;\
 } while(0)
 
-#define STACK_PUSH_ENSURED(stack_type,pat) do {\
+# define STACK_PUSH_ENSURED(stack_type,pat) do {\
   stk->type = (stack_type);\
   stk->u.state.pcode = (pat);\
   STACK_INC;\
@@ -781,13 +787,13 @@ stack_double(OnigStackType** arg_stk_bas https://github.com/ruby/ruby/blob/trunk/regexec.c#L787
 
 
 #ifdef ONIG_DEBUG
-#define STACK_BASE_CHECK(p, at) \
+# define STACK_BASE_CHECK(p, at) \
   if ((p) < stk_base) {\
     fprintf(stderr, "at %s\n", at);\
     goto stack_error;\
   }
 #else
-#define STACK_BASE_CHECK(p, at)
+# define STACK_BASE_CHECK(p, at)
 #endif
 
 #define STACK_POP_ONE do {\
@@ -1124,16 +1130,16 @@ static int string_cmp_ic(OnigEncoding en https://github.com/ruby/ruby/blob/trunk/regexec.c#L1130
 
 
 #define IS_EMPTY_STR           (str == end)
-#define ON_STR_BEGIN(s)       ((s) == str)
-#define ON_STR_END(s)         ((s) == end)
+#define ON_STR_BEGIN(s)        ((s) == str)
+#define ON_STR_END(s)          ((s) == end)
 #ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
-#define DATA_ENSURE_CHECK1     (s < right_range)
-#define DATA_ENSURE_CHECK(n)   (s + (n) <= right_range)
-#define DATA_ENSURE(n)         if (s + (n) > right_range) goto fail
+# define DATA_ENSURE_CHECK1    (s < right_range)
+# define DATA_ENSURE_CHECK(n)  (s + (n) <= right_range)
+# define DATA_ENSURE(n)        if (s + (n) > right_range) goto fail
 #else
-#define DATA_ENSURE_CHECK1     (s < end)
-#define DATA_ENSURE_CHECK(n)   (s + (n) <= end)
-#define DATA_ENSURE(n)         if (s + (n) > end) goto fail
+# define DATA_ENSURE_CHECK1    (s < end)
+# define DATA_ENSURE_CHECK(n)  (s + (n) <= end)
+# define DATA_ENSURE(n)        if (s + (n) > end) goto fail
 #endif /* USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE */
 
 
@@ -1150,29 +1156,29 @@ make_capture_history_tree(OnigCaptureTre https://github.com/ruby/ruby/blob/trunk/regexec.c#L1156
     if (k->type == STK_MEM_START) {
       n = k->u.mem.num;
       if (n <= ONIG_MAX_CAPTURE_HISTORY_GROUP &&
-          BIT_STATUS_AT(reg->capture_history, n) != 0) {
-        child = history_node_new();
-        CHECK_NULL_RETURN_MEMERR(child);
-        child->group = n;
-        child->beg = k->u.mem.pstr - str;
-        r = history_tree_add_child(node, child);
-        if (r != 0) {
-          history_tree_free(child);
-          return r;
-        }
-        *kp = (k + 1);
-        r = make_capture_history_tree(child, kp, stk_top, str, reg);
-        if (r != 0) return r;
+	  BIT_STATUS_AT(reg->capture_history, n) != 0) {
+	child = history_node_new();
+	CHECK_NULL_RETURN_MEMERR(child);
+	child->group = n;
+	child->beg = k->u.mem.pstr - str;
+	r = history_tree_add_child(node, child);
+	if (r != 0) {
+	  history_tree_free(child);
+	  return r;
+	}
+	*kp = (k + 1);
+	r = make_capture_history_tree(child, kp, stk_top, str, reg);
+	if (r != 0) return r;
 
-        k = *kp;
-        child->end = k->u.mem.pstr - str;
+	k = *kp;
+	child->end = k->u.mem.pstr - str;
       }
     }
     else if (k->type == STK_MEM_END) {
       if (k->u.mem.num == node->group) {
-        node->end = k->u.mem.pstr - str;
-        *kp = k;
-        return 0;
+	node->end = k->u.mem.pstr - str;
+	*kp = k;
+	return 0;
       }
     }
     k++;
@@ -1195,10 +1201,10 @@ static int mem_is_in_memp(int mem, int n https://github.com/ruby/ruby/blob/trunk/regexec.c#L1201
   return 0;
 }
 
-static int backref_match_at_nested_level(regex_t* reg
-	 , OnigStackType* top, OnigStackType* stk_base
-	 , int ignore_case, int case_fold_flag
-	 , int nest, int mem_num, UChar* memp, UChar** s, const UChar* send)
+static int backref_match_at_nested_level(regex_t* reg,
+	 OnigStackType* top, OnigStackType* stk_base,
+	 int ignore_case, int case_fold_flag,
+	 int nest, int mem_num, UChar* memp, UChar** s, const UChar* send)
 {
   UChar *ss, *p, *pstart, *pend = NULL_UCHARP;
   int level;
@@ -1255,27 +1261,37 @@ static int backref_match_at_nested_level https://github.com/ruby/ruby/blob/trunk/regexec.c#L1261
 
 #ifdef ONIG_DEBUG_STATISTICS
 
-#define USE_TIMEOFDAY
-
-#ifdef USE_TIMEOFDAY
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+# ifdef _WIN32
+#  include <windows.h>
+static LARGE_INTEGER ts, te, freq;
+#  define GETTIME(t)	  QueryPerformanceCounter(&(t))
+#  define TIMEDIFF(te,ts) (unsigned long )(((te).QuadPart - (ts).QuadPart) \
+			    * 1000000 / freq.QuadPart)
+# else /* _WIN32 */
+
+#  define USE_TIMEOFDAY
+
+#  ifdef USE_TIMEOFDAY
+#   ifdef HAVE_SYS_TIME_H
+#    include <sys/time.h>
+#   endif
+#   ifdef HAVE_UNISTD_H
+#    include <unistd.h>
+#   endif
 static struct timeval ts, te;
-#define GETTIME(t)        gettimeofday(&(t), (struct timezone* )0)
-#define TIMEDIFF(te,ts)   (((te).tv_usec - (ts).tv_usec) + \
-                           (((te).tv_sec - (ts).tv_sec)*1000000))
-#else /* USE_TIMEOFDAY */
-#ifdef HAVE_SYS_TIMES_H
-#include <sys/times.h>
-#endif
+#   define GETTIME(t)      gettimeofday(&(t), (struct timezone* )0)
+#   define TIMEDIFF(te,ts) (((te).tv_usec - (ts).tv_usec) + \
+                            (((te).tv_sec - (ts).tv_sec)*1000000))
+#  else /* USE_TIMEOFDAY */
+#   ifdef HAVE_SYS_TIMES_H
+#    include <sys/times.h>
+#   endif
 static struct tms ts, te;
-#define GETTIME(t)         times(&(t))
-#define TIMEDIFF(te,ts)   ((te).tms_utime - (ts).tms_utime)
-#endif /* USE_TIMEOFDAY */
+#   define GETTIME(t)       times(&(t))
+#   define TIMEDIFF(te,ts)  ((te).tms_utime - (ts).tms_utime)
+#  endif /* USE_TIMEOFDAY */
+
+# endif /* _WIN32 */
 
 static int OpCounter[256];
 static int OpPrevCounter[256];
@@ -1284,14 +1300,14 @@ static int OpCurr = OP_FINISH; https://github.com/ruby/ruby/blob/trunk/regexec.c#L1300
 static int OpPrevTarget = OP_FAIL;
 static int MaxStackDepth = 0;
 
-#define MOP_IN(opcode) do {\
+# define MOP_IN(opcode) do {\
   if (opcode == OpPrevTarget) OpPrevCounter[OpCurr]++;\
   OpCurr = opcode;\
   OpCounter[opcode]++;\
   GETTIME(ts);\
 } while(0)
 
-#define MOP_OUT do {\
+# define MOP_OUT do {\
   GETTIME(te);\
   OpTime[OpCurr] += TIMEDIFF(te, ts);\
 } while(0)
@@ -1304,6 +1320,9 @@ onig_statistics_init(void) https://github.com/ruby/ruby/blob/trunk/regexec.c#L1320
     OpCounter[i] = OpPrevCounter[i] = 0; OpTime[i] = 0;
   }
   MaxStackDepth = 0;
+# ifdef _WIN32
+  QueryPerformanceFrequency(&freq);
+# endif
 }
 
 extern void
@@ -1318,28 +1337,45 @@ onig_print_statistics(FILE* f) https://github.com/ruby/ruby/blob/trunk/regexec.c#L1337
   fprintf(f, "\nmax stack depth: %d\n", MaxStackDepth);
 }
 
-#define STACK_INC do {\
+# define STACK_INC do {\
   stk++;\
   if (stk - stk_base > MaxStackDepth) \
     MaxStackDepth = stk - stk_base;\
 } while(0)
 
 #else /* ONIG_DEBUG_STATISTICS */
-#define STACK_INC     stk++
+# define STACK_INC     stk++
 
-#define MOP_IN(opcode)
-#define MOP_OUT
+# define MOP_IN(opcode)
+# define MOP_OUT
 #endif /* ONIG_DEBUG_STATISTICS */
 
 
-
-/* matching region of POSIX API */
-typedef int regoff_t;
-
-typedef struct {
-  regoff_t  rm_so;
-  regoff_t  rm_eo;
-} posix_regmatch_t;
+#ifdef ONIG_DEBUG_MATCH
+static char *
+stack_type_str(int stack_type)
+{
+  switch (stack_type) {
+    case STK_ALT:		return "Alt   ";
+    case STK_LOOK_BEHIND_NOT:	return "LBNot ";
+    case STK_POS_NOT:		return "PosNot";
+    case STK_MEM_START:		return "MemS  ";
+    case STK_MEM_END:		return "MemE  ";
+    case STK_REPEAT_INC:	return "RepInc";
+    case STK_STATE_CHECK_MARK:	return "StChMk";
+    case STK_NULL_CHECK_START:	return "NulChS";
+    case STK_NULL_CHECK_END:	return "NulChE";
+    case STK_MEM_END_MARK:	return "MemEMk";
+    case STK_POS:		return "Pos   ";
+    case STK_STOP_BT:		return "StopBt";
+    case STK_REPEAT:		return "Rep   ";
+    case STK_CALL_FRAME:	return "Call  ";
+    case STK_RETURN:		return "Ret   ";
+    case STK_VOID:		return "Void  ";
+    default:			return "      ";
+  }
+}
+#endif
 
 /* match data(str - end) from position (sstart). */
 /* if sstart == str then set sprev to NULL. */
@@ -1376,13 +1412,14 @@ match_at(regex_t* reg, const UChar* str, https://github.com/ruby/ruby/blob/trunk/regexec.c#L1412
   int num_comb_exp_check = reg->num_comb_exp_check;
 #endif
 
-#if USE_DIRECT_THREADED_VM
-#define VM_LOOP JUMP;
-#define VM_LOOP_END
-#define CASE(x) L_##x: sbegin = s; OPCODE_EXEC_HOOK;
-#define DEFAULT L_DEFAULT:
-#define NEXT sprev = sbegin; JUMP
-#define JUMP goto *oplabels[*p++]
+#if USE_TOKEN_THREADED_VM
+# define OP_OFFSET  1
+# define VM_LOOP JUMP;
+# define VM_LOOP_END
+# define CASE(x) L_##x: sbegin = s; OPCODE_EXEC_HOOK;
+# define DEFAULT L_DEFAULT:
+# define NEXT sprev = sbegin; JUMP
+# define JUMP goto *oplabels[*p++]
 
   static const void *oplabels[] = {
     &&L_OP_FINISH,               /* matching process terminator (no more alternative) */
@@ -1410,7 +1447,6 @@ match_at(regex_t* reg, const UChar* str, https://github.com/ruby/ruby/blob/trunk/regexec.c#L1447
     &&L_OP_CCLASS_NOT,
     &&L_OP_CCLASS_MB_NOT,
     &&L_OP_CCLASS_MIX_NOT,
-    &&L_OP_CCLASS_NODE,          /* pointer to CClassNode node */
 
     &&L_OP_ANYCHAR,                 /* "."  */
     &&L_OP_ANYCHAR_ML,              /* "."  multi-line */
@@ -1423,24 +1459,24 @@ match_at(regex_t* reg, const UChar* str, https://github.com/ruby/ruby/blob/trunk/regexec.c#L1459
     &&L_OP_NOT_WORD,
     &&L_OP_WORD_BOUND,
     &&L_OP_NOT_WORD_BOUND,
-#ifdef USE_WORD_BEGIN_END
+# ifdef USE_WORD_BEGIN_END
     &&L_OP_WORD_BEGIN,
     &&L_OP_WORD_END,
-#else
+# else
     &&L_DEFAULT,
     &&L_DEFAULT,
-#endif
+# endif
     &&L_OP_ASCII_WORD,
     &&L_OP_NOT_ASCII_WORD,
     &&L_OP_ASCII_WORD_BOUND,
     &&L_OP_NOT_ASCII_WORD_BOUND,
-#ifdef USE_WORD_BEGIN_END
+# ifdef USE_WORD_BEGIN_END
     &&L_OP_ASCII_WORD_BEGIN,
     &&L_OP_ASCII_WORD_END,
-#else
+# else
     &&L_DEFAULT,
     &&L_DEFAULT,
-#endif
+# endif
 
     &&L_OP_BEGIN_BUF,
     &&L_OP_END_BUF,
@@ -1456,25 +1492,25 @@ match_at(regex_t* reg, const UChar* str, https://github.com/ruby/ruby/blob/trunk/regexec.c#L1492
     &&L_OP_BACKREFN_IC,
     &&L_OP_BACKREF_MULTI,
     &&L_OP_BACKREF_MULTI_IC,
-#ifdef USE_BACKREF_W (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]