Created
November 29, 2016 15:51
-
-
Save k-takata/833f4ef7c4f94428e8de938103e97d5f to your computer and use it in GitHub Desktop.
Onigmo issue #48
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/regexec.c b/regexec.c | |
index e57c962..f56246a 100644 | |
--- a/regexec.c | |
+++ b/regexec.c | |
@@ -804,6 +804,7 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end, | |
#define STACK_POP do {\ | |
switch (pop_level) {\ | |
case STACK_POP_LEVEL_FREE:\ | |
+fprintf(stderr, "STACK_POP_LEVEL_FREE\n");\ | |
while (1) {\ | |
stk--;\ | |
STACK_BASE_CHECK(stk, "STACK_POP"); \ | |
@@ -812,9 +813,11 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end, | |
}\ | |
break;\ | |
case STACK_POP_LEVEL_MEM_START:\ | |
+fprintf(stderr, "STACK_POP_LEVEL_MEM_START\n");\ | |
while (1) {\ | |
stk--;\ | |
STACK_BASE_CHECK(stk, "STACK_POP 2"); \ | |
+fprintf(stderr, "stk: %d %s\n", (int)(stk - stk_base), stack_type_str(stk->type));\ | |
if ((stk->type & STK_MASK_POP_USED) != 0) break;\ | |
else if (stk->type == STK_MEM_START) {\ | |
mem_start_stk[stk->u.mem.num] = stk->u.mem.start;\ | |
@@ -824,6 +827,7 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end, | |
}\ | |
break;\ | |
default:\ | |
+fprintf(stderr, "STACK_POP default\n");\ | |
while (1) {\ | |
stk--;\ | |
STACK_BASE_CHECK(stk, "STACK_POP 3"); \ | |
diff --git a/regint.h b/regint.h | |
index 9b60fdc..aa6e47f 100644 | |
--- a/regint.h | |
+++ b/regint.h | |
@@ -31,10 +31,10 @@ | |
*/ | |
/* for debug */ | |
-/* #define ONIG_DEBUG_PARSE_TREE */ | |
-/* #define ONIG_DEBUG_COMPILE */ | |
-/* #define ONIG_DEBUG_SEARCH */ | |
-/* #define ONIG_DEBUG_MATCH */ | |
+ #define ONIG_DEBUG_PARSE_TREE */ | |
+ #define ONIG_DEBUG_COMPILE */ | |
+ #define ONIG_DEBUG_SEARCH */ | |
+ #define ONIG_DEBUG_MATCH */ | |
/* #define ONIG_DEBUG_MEMLEAK */ | |
/* #define ONIG_DONT_OPTIMIZE */ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Execute this on python: | |
from testpy import *; import onigmo | |
init('utf-8') | |
x3('\(((?:[^(]|\g<0>)*)\)', "(abc)(", 1, 4, 1) | |
---- | |
code length: 93 | |
0:[call:(10)] 5:[jump:(+82)] 10:[mem-start-push:0] 13:[exact1:(] 15:[mem-start:1] | |
18:[push-if-peek-next:(+59):)] 24:[null-check-start:0] 27:[push:(+38)] 32:[cclass-not:1] 65:[jump:(+5)] | |
70:[call:(10)] 75:[null-check-end-memst-push:0] 78:[jump:(-65)] 83:[mem-end:1] 86:[exact1:)] | |
88:[mem-end-rec:0] 91:[return] 92:[end] | |
onig_search (entry point): str: 60955048 (03A219A8), end: 6, start: 0, range: 6 | |
onig_search(apply anchor): end: 6, start: 0, range: 6 | |
forward_search_range: str: 60955048 (03A219A8), end: 60955054 (03A219AE), s: 60955048 (03A219A8), range: 60955054 (03A219AE) | |
forward_search_range success: low: 0, high: 0, dmin: 0, dmax: 0 | |
match_at: str: 60955048 (03A219A8), end: 60955054 (03A219AE), start: 60955048 (03A219A8), sprev: 0 (00000000) | |
size: 6, start offset: 0 | |
ofs> str stk:type addr:opcode | |
0> "(abc)(" 0:Alt 0:[call:(10)] | |
0> "(abc)(" 1:Call 10:[mem-start-push:0] | |
0> "(abc)(" 2:MemS 13:[exact1:(] | |
1> "abc)(" 2:MemS 15:[mem-start:1] | |
1> "abc)(" 2:MemS 18:[push-if-peek-next:(+59):)] | |
1> "abc)(" 2:MemS 24:[null-check-start:0] | |
1> "abc)(" 3:NulChS 27:[push:(+38)] | |
1> "abc)(" 4:Alt 32:[cclass-not:1] | |
2> "bc)(" 4:Alt 65:[jump:(+5)] | |
2> "bc)(" 4:Alt 75:[null-check-end-memst-push:0] | |
2> "bc)(" 5:NulChE 78:[jump:(-65)] | |
2> "bc)(" 5:NulChE 18:[push-if-peek-next:(+59):)] | |
2> "bc)(" 5:NulChE 24:[null-check-start:0] | |
2> "bc)(" 6:NulChS 27:[push:(+38)] | |
2> "bc)(" 7:Alt 32:[cclass-not:1] | |
3> "c)(" 7:Alt 65:[jump:(+5)] | |
3> "c)(" 7:Alt 75:[null-check-end-memst-push:0] | |
3> "c)(" 8:NulChE 78:[jump:(-65)] | |
3> "c)(" 8:NulChE 18:[push-if-peek-next:(+59):)] | |
3> "c)(" 8:NulChE 24:[null-check-start:0] | |
3> "c)(" 9:NulChS 27:[push:(+38)] | |
3> "c)(" 10:Alt 32:[cclass-not:1] | |
4> ")(" 10:Alt 65:[jump:(+5)] | |
4> ")(" 10:Alt 75:[null-check-end-memst-push:0] | |
4> ")(" 11:NulChE 78:[jump:(-65)] | |
4> ")(" 11:NulChE 18:[push-if-peek-next:(+59):)] | |
4> ")(" 12:Alt 24:[null-check-start:0] | |
4> ")(" 13:NulChS 27:[push:(+38)] | |
4> ")(" 14:Alt 32:[cclass-not:1] | |
5> "(" 14:Alt 65:[jump:(+5)] | |
5> "(" 14:Alt 75:[null-check-end-memst-push:0] | |
5> "(" 15:NulChE 78:[jump:(-65)] | |
5> "(" 15:NulChE 18:[push-if-peek-next:(+59):)] | |
5> "(" 15:NulChE 24:[null-check-start:0] | |
5> "(" 16:NulChS 27:[push:(+38)] | |
5> "(" 17:Alt 32:[cclass-not:1] | |
STACK_POP_LEVEL_MEM_START | |
stk: 17 Alt | |
5> "(" 16:NulChS 70:[call:(10)] | |
5> "(" 17:Call 10:[mem-start-push:0] | |
5> "(" 18:MemS 13:[exact1:(] | |
6> "" 18:MemS 15:[mem-start:1] | |
6> "" 18:MemS 18:[push-if-peek-next:(+59):)] | |
6> "" 18:MemS 24:[null-check-start:0] | |
6> "" 19:NulChS 27:[push:(+38)] | |
6> "" 20:Alt 32:[cclass-not:1] | |
STACK_POP_LEVEL_MEM_START | |
stk: 20 Alt | |
6> "" 19:NulChS 70:[call:(10)] | |
6> "" 20:Call 10:[mem-start-push:0] | |
6> "" 21:MemS 13:[exact1:(] | |
STACK_POP_LEVEL_MEM_START | |
stk: 21 MemS | |
stk: 20 Call | |
stk: 19 NulChS | |
stk: 18 MemS | |
stk: 17 Call | |
stk: 16 NulChS | |
stk: 15 NulChE | |
stk: 14 Alt | |
4> ")(" 13:NulChS 70:[call:(10)] | |
4> ")(" 14:Call 10:[mem-start-push:0] | |
4> ")(" 15:MemS 13:[exact1:(] | |
STACK_POP_LEVEL_MEM_START | |
stk: 15 MemS | |
stk: 14 Call | |
stk: 13 NulChS | |
stk: 12 Alt | |
4> ")(" 11:NulChE 83:[mem-end:1] | |
4> ")(" 11:NulChE 86:[exact1:)] | |
5> "(" 11:NulChE 88:[mem-end-rec:0] | |
5> "(" 12:MemEMk 91:[return] | |
5> "(" 13:Ret 5:[jump:(+82)] | |
5> "(" 13:Ret 92:[end] | |
FAIL: /\(((?:[^(]|\g<0>)*)\)/ '(abc)(' 1-4 : 6-4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment