/[pcre]/code/branches/pcre16/pcre_jit_test.c
ViewVC logotype

Diff of /code/branches/pcre16/pcre_jit_test.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 824 by zherczeg, Thu Dec 15 11:57:39 2011 UTC revision 825 by zherczeg, Mon Dec 26 21:23:17 2011 UTC
# Line 87  static int regression_tests(void); Line 87  static int regression_tests(void);
87  int main(void)  int main(void)
88  {  {
89          int jit = 0;          int jit = 0;
90    #ifdef SUPPORT_PCRE8
91          pcre_config(PCRE_CONFIG_JIT, &jit);          pcre_config(PCRE_CONFIG_JIT, &jit);
92    #else
93            pcre16_config(PCRE_CONFIG_JIT, &jit);
94    #endif
95          if (!jit) {          if (!jit) {
96                  printf("JIT must be enabled to run pcre_jit_test\n");                  printf("JIT must be enabled to run pcre_jit_test\n");
97                  return 1;                  return 1;
# Line 115  int main(void) Line 119  int main(void)
119  #define F_NOMATCH       0x040000  #define F_NOMATCH       0x040000
120  #define F_DIFF          0x080000  #define F_DIFF          0x080000
121  #define F_FORCECONV     0x100000  #define F_FORCECONV     0x100000
122    #define F_PROPERTY      0x200000
123    
124  struct regression_test_case {  struct regression_test_case {
125          int flags;          int flags;
# Line 192  static struct regression_test_case regre Line 197  static struct regression_test_case regre
197          { PCRE_NOTBOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "^a", "aa\naa" },          { PCRE_NOTBOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "^a", "aa\naa" },
198          { PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0 | F_NOMATCH, "a$", "aa\naa" },          { PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0 | F_NOMATCH, "a$", "aa\naa" },
199          { PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0 | F_NOMATCH, "a$", "aa\r\n" },          { PCRE_NOTEOL | PCRE_NEWLINE_ANY, 0 | F_NOMATCH, "a$", "aa\r\n" },
200          { PCRE_UTF8 | PCRE_DOLLAR_ENDONLY | PCRE_NEWLINE_ANY, 0, "\\p{Any}{2,}$", "aa\r\n" },          { PCRE_UTF8 | PCRE_DOLLAR_ENDONLY | PCRE_NEWLINE_ANY, 0 | F_PROPERTY, "\\p{Any}{2,}$", "aa\r\n" },
201          { PCRE_NOTEOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "a$", "aa\naa" },          { PCRE_NOTEOL | PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0, "a$", "aa\naa" },
202          { PCRE_NEWLINE_CR, 0, ".\\Z", "aaa" },          { PCRE_NEWLINE_CR, 0, ".\\Z", "aaa" },
203          { PCRE_NEWLINE_CR | PCRE_UTF8, 0, "a\\Z", "aaa\r" },          { PCRE_NEWLINE_CR | PCRE_UTF8, 0, "a\\Z", "aaa\r" },
# Line 305  static struct regression_test_case regre Line 310  static struct regression_test_case regre
310    
311          /* Unicode properties. */          /* Unicode properties. */
312          { MUAP, 0, "[1-5\xc3\xa9\\w]", "\xc3\xa1_" },          { MUAP, 0, "[1-5\xc3\xa9\\w]", "\xc3\xa1_" },
313          { MUAP, 0, "[\xc3\x81\\p{Ll}]", "A_\xc3\x89\xc3\xa1" },          { MUAP, 0 | F_PROPERTY, "[\xc3\x81\\p{Ll}]", "A_\xc3\x89\xc3\xa1" },
314          { MUAP, 0, "[\\Wd-h_x-z]+", "a\xc2\xa1#_yhzdxi" },          { MUAP, 0, "[\\Wd-h_x-z]+", "a\xc2\xa1#_yhzdxi" },
315          { MUAP, 0 | F_NOMATCH, "[\\P{Any}]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[\\P{Any}]", "abc" },
316          { MUAP, 0 | F_NOMATCH, "[^\\p{Any}]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[^\\p{Any}]", "abc" },
317          { MUAP, 0 | F_NOMATCH, "[\\P{Any}\xc3\xa1-\xc3\xa8]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[\\P{Any}\xc3\xa1-\xc3\xa8]", "abc" },
318          { MUAP, 0 | F_NOMATCH, "[^\\p{Any}\xc3\xa1-\xc3\xa8]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[^\\p{Any}\xc3\xa1-\xc3\xa8]", "abc" },
319          { MUAP, 0 | F_NOMATCH, "[\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },
320          { MUAP, 0 | F_NOMATCH, "[^\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },          { MUAP, 0 | F_NOMATCH | F_PROPERTY, "[^\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },
321          { MUAP, 0, "[\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },          { MUAP, 0 | F_PROPERTY, "[\xc3\xa1-\xc3\xa8\\p{Any}]", "abc" },
322          { MUAP, 0, "[^\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },          { MUAP, 0 | F_PROPERTY, "[^\xc3\xa1-\xc3\xa8\\P{Any}]", "abc" },
323          { MUAP, 0, "[b-\xc3\xa9\\s]", "a\xc\xe6\x92\xad" },          { MUAP, 0, "[b-\xc3\xa9\\s]", "a\xc\xe6\x92\xad" },
324          { CMUAP, 0, "[\xc2\x85-\xc2\x89\xc3\x89]", "\xc2\x84\xc3\xa9" },          { CMUAP, 0, "[\xc2\x85-\xc2\x89\xc3\x89]", "\xc2\x84\xc3\xa9" },
325          { MUAP, 0, "[^b-d^&\\s]{3,}", "db^ !a\xe2\x80\xa8_ae" },          { MUAP, 0, "[^b-d^&\\s]{3,}", "db^ !a\xe2\x80\xa8_ae" },
326          { MUAP, 0, "[^\\S\\P{Any}][\\sN]{1,3}[\\P{N}]{4}", "\xe2\x80\xaa\xa N\x9\xc3\xa9_0" },          { MUAP, 0 | F_PROPERTY, "[^\\S\\P{Any}][\\sN]{1,3}[\\P{N}]{4}", "\xe2\x80\xaa\xa N\x9\xc3\xa9_0" },
327          { MUA, 0, "[^\\P{L}\x9!D-F\xa]{2,3}", "\x9,.DF\xa.CG\xc3\x81" },          { MUA, 0 | F_PROPERTY, "[^\\P{L}\x9!D-F\xa]{2,3}", "\x9,.DF\xa.CG\xc3\x81" },
328          { CMUAP, 0, "[\xc3\xa1-\xc3\xa9_\xe2\x80\xa0-\xe2\x80\xaf]{1,5}[^\xe2\x80\xa0-\xe2\x80\xaf]", "\xc2\xa1\xc3\x89\xc3\x89\xe2\x80\xaf_\xe2\x80\xa0" },          { CMUAP, 0, "[\xc3\xa1-\xc3\xa9_\xe2\x80\xa0-\xe2\x80\xaf]{1,5}[^\xe2\x80\xa0-\xe2\x80\xaf]", "\xc2\xa1\xc3\x89\xc3\x89\xe2\x80\xaf_\xe2\x80\xa0" },
329          { MUAP, 0, "[\xc3\xa2-\xc3\xa6\xc3\x81-\xc3\x84\xe2\x80\xa8-\xe2\x80\xa9\xe6\x92\xad\\p{Zs}]{2,}", "\xe2\x80\xa7\xe2\x80\xa9\xe6\x92\xad \xe6\x92\xae" },          { MUAP, 0 | F_PROPERTY, "[\xc3\xa2-\xc3\xa6\xc3\x81-\xc3\x84\xe2\x80\xa8-\xe2\x80\xa9\xe6\x92\xad\\p{Zs}]{2,}", "\xe2\x80\xa7\xe2\x80\xa9\xe6\x92\xad \xe6\x92\xae" },
330          { MUAP, 0, "[\\P{L&}]{2}[^\xc2\x85-\xc2\x89\\p{Ll}\\p{Lu}]{2}", "\xc3\xa9\xe6\x92\xad.a\xe6\x92\xad|\xc2\x8a#" },          { MUAP, 0 | F_PROPERTY, "[\\P{L&}]{2}[^\xc2\x85-\xc2\x89\\p{Ll}\\p{Lu}]{2}", "\xc3\xa9\xe6\x92\xad.a\xe6\x92\xad|\xc2\x8a#" },
331          { PCRE_UCP, 0, "[a-b\\s]{2,5}[^a]", "AB  baaa" },          { PCRE_UCP, 0, "[a-b\\s]{2,5}[^a]", "AB  baaa" },
332    
333          /* Possible empty brackets. */          /* Possible empty brackets. */
# Line 406  static struct regression_test_case regre Line 411  static struct regression_test_case regre
411          { CMA, 0, "(?>((?>a{32}|b+|(a*))?(?>c+|d*)?\?)+e)+?f", "aaccebbdde bbdaaaccebbdee bbdaaaccebbdeef" },          { CMA, 0, "(?>((?>a{32}|b+|(a*))?(?>c+|d*)?\?)+e)+?f", "aaccebbdde bbdaaaccebbdee bbdaaaccebbdeef" },
412          { MUA, 0, "(?>(?:(?>aa|a||x)+?b|(?>aa|a||(x))+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },          { MUA, 0, "(?>(?:(?>aa|a||x)+?b|(?>aa|a||(x))+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },
413          { MUA, 0, "(?>(?:(?>aa|a||(x))+?b|(?>aa|a||x)+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },          { MUA, 0, "(?>(?:(?>aa|a||(x))+?b|(?>aa|a||x)+?c)?(?>[ad]{0,2})*?d)+d", "aaacdbaabdcabdbaaacd aacaabdbdcdcaaaadaabcbaadd" },
414          { MUA, 0 | F_NOMATCH, "\\X", "\xcc\x8d\xcc\x8d" },          { MUA, 0 | F_NOMATCH | F_PROPERTY, "\\X", "\xcc\x8d\xcc\x8d" },
415          { MUA, 0, "\\X", "\xcc\x8d\xcc\x8d#\xcc\x8d\xcc\x8d" },          { MUA, 0 | F_PROPERTY, "\\X", "\xcc\x8d\xcc\x8d#\xcc\x8d\xcc\x8d" },
416          { MUA, 0, "\\X+..", "\xcc\x8d#\xcc\x8d#\xcc\x8d\xcc\x8d" },          { MUA, 0 | F_PROPERTY, "\\X+..", "\xcc\x8d#\xcc\x8d#\xcc\x8d\xcc\x8d" },
417          { MUA, 0, "\\X{2,4}", "abcdef" },          { MUA, 0 | F_PROPERTY, "\\X{2,4}", "abcdef" },
418          { MUA, 0, "\\X{2,4}?", "abcdef" },          { MUA, 0 | F_PROPERTY, "\\X{2,4}?", "abcdef" },
419          { MUA, 0 | F_NOMATCH, "\\X{2,4}..", "#\xcc\x8d##" },          { MUA, 0 | F_NOMATCH | F_PROPERTY, "\\X{2,4}..", "#\xcc\x8d##" },
420          { MUA, 0, "\\X{2,4}..", "#\xcc\x8d#\xcc\x8d##" },          { MUA, 0 | F_PROPERTY, "\\X{2,4}..", "#\xcc\x8d#\xcc\x8d##" },
421          { MUA, 0, "(c(ab)?+ab)+", "cabcababcab" },          { MUA, 0, "(c(ab)?+ab)+", "cabcababcab" },
422          { MUA, 0, "(?>(a+)b)+aabab", "aaaabaaabaabab" },          { MUA, 0, "(?>(a+)b)+aabab", "aaaabaaabaabab" },
423    
# Line 471  static struct regression_test_case regre Line 476  static struct regression_test_case regre
476          { MUA, 0, "(?:(aa|bb)(\\1{0,3}?)){2}(dd|)(\\3{0,3}?)b(\\1{0,3}?)(\\1{0,3})", "aaaaaaaaaaaaaaabaaaaa" },          { MUA, 0, "(?:(aa|bb)(\\1{0,3}?)){2}(dd|)(\\3{0,3}?)b(\\1{0,3}?)(\\1{0,3})", "aaaaaaaaaaaaaaabaaaaa" },
477          { MUA, 0, "(a(?:\\1|)a){3}b", "aaaaaaaaaaab" },          { MUA, 0, "(a(?:\\1|)a){3}b", "aaaaaaaaaaab" },
478          { MA, 0, "(a?)b(\\1\\1*\\1+\\1?\\1*?\\1+?\\1??\\1*+\\1++\\1?+\\1{4}\\1{3,5}\\1{4,}\\1{0,5}\\1{3,5}?\\1{4,}?\\1{0,5}?\\1{3,5}+\\1{4,}+\\1{0,5}+#){2}d", "bb#b##d" },          { MA, 0, "(a?)b(\\1\\1*\\1+\\1?\\1*?\\1+?\\1??\\1*+\\1++\\1?+\\1{4}\\1{3,5}\\1{4,}\\1{0,5}\\1{3,5}?\\1{4,}?\\1{0,5}?\\1{3,5}+\\1{4,}+\\1{0,5}+#){2}d", "bb#b##d" },
479          { MUAP, 0, "(\\P{N})\\1{2,}", ".www." },          { MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{2,}", ".www." },
480          { MUAP, 0, "(\\P{N})\\1{0,2}", "wwwww." },          { MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{0,2}", "wwwww." },
481          { MUAP, 0, "(\\P{N})\\1{1,2}ww", "wwww" },          { MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{1,2}ww", "wwww" },
482          { MUAP, 0, "(\\P{N})\\1{1,2}ww", "wwwww" },          { MUAP, 0 | F_PROPERTY, "(\\P{N})\\1{1,2}ww", "wwwww" },
483          { PCRE_UCP, 0, "(\\P{N})\\1{2,}", ".www." },          { PCRE_UCP, 0 | F_PROPERTY, "(\\P{N})\\1{2,}", ".www." },
484          { CMUAP, 0, "(\xf0\x90\x90\x80)\\1", "\xf0\x90\x90\xa8\xf0\x90\x90\xa8" },          { CMUAP, 0, "(\xf0\x90\x90\x80)\\1", "\xf0\x90\x90\xa8\xf0\x90\x90\xa8" },
485    
486          /* Assertions. */          /* Assertions. */
# Line 569  static struct regression_test_case regre Line 574  static struct regression_test_case regre
574          { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a\\K(*ACCEPT)b", "aa" },          { MUA | PCRE_NOTEMPTY_ATSTART, 0, "a\\K(*ACCEPT)b", "aa" },
575    
576          /* First line. */          /* First line. */
577          { MUA | PCRE_FIRSTLINE, 0, "\\p{Any}a", "bb\naaa" },          { MUA | PCRE_FIRSTLINE, 0 | F_PROPERTY, "\\p{Any}a", "bb\naaa" },
578          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "\\p{Any}a", "bb\r\naaa" },          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH | F_PROPERTY, "\\p{Any}a", "bb\r\naaa" },
579          { MUA | PCRE_FIRSTLINE, 0, "(?<=a)", "a" },          { MUA | PCRE_FIRSTLINE, 0, "(?<=a)", "a" },
580          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "[^a][^b]", "ab" },          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "[^a][^b]", "ab" },
581          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "a", "\na" },          { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "a", "\na" },
# Line 580  static struct regression_test_case regre Line 585  static struct regression_test_case regre
585          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "#", "\xc2\x85#" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "#", "\xc2\x85#" },
586          { PCRE_MULTILINE | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "#", "\x85#" },          { PCRE_MULTILINE | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "#", "\x85#" },
587          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "^#", "\xe2\x80\xa8#" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "^#", "\xe2\x80\xa8#" },
588          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "\\p{Any}", "\r\na" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_PROPERTY, "\\p{Any}", "\r\na" },
589          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, ".", "\r" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, ".", "\r" },
590          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "a", "\ra" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0, "a", "\ra" },
591          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_NOMATCH, "ba", "bbb\r\nba" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_NOMATCH, "ba", "bbb\r\nba" },
592          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_NOMATCH, "\\p{Any}{4}|a", "\r\na" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 0 | F_NOMATCH | F_PROPERTY, "\\p{Any}{4}|a", "\r\na" },
593          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 1, ".", "\r\n" },          { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_CRLF | PCRE_FIRSTLINE, 1, ".", "\r\n" },
594    
595          /* Recurse. */          /* Recurse. */
# Line 640  static struct regression_test_case regre Line 645  static struct regression_test_case regre
645          { CMA | PCRE_EXTENDED, 0 | F_FORCECONV, "\xed\xa0\x80 \xed\xb0\x80 !", "\xed\xa0\x80\xed\xb0\x80!" },          { CMA | PCRE_EXTENDED, 0 | F_FORCECONV, "\xed\xa0\x80 \xed\xb0\x80 !", "\xed\xa0\x80\xed\xb0\x80!" },
646          { CMA, 0 | F_FORCECONV, "\xed\xa0\x80+#[^#]+\xed\xa0\x80", "\xed\xa0\x80#a\xed\xa0\x80" },          { CMA, 0 | F_FORCECONV, "\xed\xa0\x80+#[^#]+\xed\xa0\x80", "\xed\xa0\x80#a\xed\xa0\x80" },
647          { CMA, 0 | F_FORCECONV, "(\xed\xa0\x80+)#\\1", "\xed\xa0\x80\xed\xa0\x80#\xed\xa0\x80\xed\xa0\x80" },          { CMA, 0 | F_FORCECONV, "(\xed\xa0\x80+)#\\1", "\xed\xa0\x80\xed\xa0\x80#\xed\xa0\x80\xed\xa0\x80" },
648            { PCRE_MULTILINE | PCRE_NEWLINE_ANY, 0 | F_NO8 | F_FORCECONV, "^-", "a--\xe2\x80\xa8--" },
649            { PCRE_BSR_UNICODE, 0 | F_NO8 | F_FORCECONV, "\\R", "ab\xe2\x80\xa8" },
650            { 0, 0 | F_NO8 | F_FORCECONV, "\\v", "ab\xe2\x80\xa9" },
651            { 0, 0 | F_NO8 | F_FORCECONV, "\\h", "ab\xe1\xa0\x8e" },
652            { 0, 0 | F_NO8 | F_FORCECONV, "\\v+?\\V+?#", "\xe2\x80\xa9\xe2\x80\xa9\xef\xbf\xbf\xef\xbf\xbf#" },
653            { 0, 0 | F_NO8 | F_FORCECONV, "\\h+?\\H+?#", "\xe1\xa0\x8e\xe1\xa0\x8e\xef\xbf\xbf\xef\xbf\xbf#" },
654    
655          /* Deep recursion. */          /* Deep recursion. */
656          { MUA, 0, "((((?:(?:(?:\\w)+)?)*|(?>\\w)+?)+|(?>\\w)?\?)*)?\\s", "aaaaa+ " },          { MUA, 0, "((((?:(?:(?:\\w)+)?)*|(?>\\w)+?)+|(?>\\w)?\?)*)?\\s", "aaaaa+ " },
# Line 714  static pcre_jit_stack* callback(void *ar Line 725  static pcre_jit_stack* callback(void *ar
725          return (pcre_jit_stack *)arg;          return (pcre_jit_stack *)arg;
726  }  }
727    
728  static void setstack(pcre_extra *extra)  #ifdef SUPPORT_PCRE8
729    static void setstack8(pcre_extra *extra)
730  {  {
731          static pcre_jit_stack *stack;          static pcre_jit_stack *stack;
732    
# Line 730  static void setstack(pcre_extra *extra) Line 742  static void setstack(pcre_extra *extra)
742          /* Extra can be NULL. */          /* Extra can be NULL. */
743          pcre_assign_jit_stack(extra, callback, stack);          pcre_assign_jit_stack(extra, callback, stack);
744  }  }
745    #endif /* SUPPORT_PCRE8 */
746    
747    #ifdef SUPPORT_PCRE16
748    static void setstack16(pcre_extra *extra)
749    {
750            static pcre_jit_stack *stack;
751    
752            if (!extra) {
753                    if (stack)
754                            pcre16_jit_stack_free(stack);
755                    stack = NULL;
756                    return;
757            }
758    
759            if (!stack)
760                    stack = pcre16_jit_stack_alloc(1, 1024 * 1024);
761            /* Extra can be NULL. */
762            pcre16_assign_jit_stack(extra, callback, stack);
763    }
764    #endif /* SUPPORT_PCRE8 */
765    
766  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
767    
# Line 803  static int regtest_offsetmap[REGTEST_MAX Line 835  static int regtest_offsetmap[REGTEST_MAX
835    
836  #endif /* SUPPORT_PCRE16 */  #endif /* SUPPORT_PCRE16 */
837    
838    static int check_ascii(const char *input)
839    {
840            const unsigned char *ptr = (unsigned char *)input;
841            while (*ptr) {
842                    if (*ptr > 127)
843                            return 0;
844                    ptr++;
845            }
846            return 1;
847    }
848    
849  static int regression_tests(void)  static int regression_tests(void)
850  {  {
851          struct regression_test_case *current = regression_test_cases;          struct regression_test_case *current = regression_test_cases;
852          const char *error;          const char *error;
853          int i, err_offs, is_successful;          int i, err_offs;
854            int is_successful, is_ascii_pattern, is_ascii_input;
855          int total = 0;          int total = 0;
856          int successful = 0;          int successful = 0;
857          int counter = 0;          int counter = 0;
# Line 859  static int regression_tests(void) Line 903  static int regression_tests(void)
903          while (current->pattern) {          while (current->pattern) {
904                  /* printf("\nPattern: %s :\n", current->pattern); */                  /* printf("\nPattern: %s :\n", current->pattern); */
905                  total++;                  total++;
906                    if (current->start_offset & F_PROPERTY) {
907                            is_ascii_pattern = 0;
908                            is_ascii_input = 0;
909                    } else {
910                            is_ascii_pattern = check_ascii(current->pattern);
911                            is_ascii_input = check_ascii(current->input);
912                    }
913    
914                  error = NULL;                  error = NULL;
915  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
# Line 883  static int regression_tests(void) Line 934  static int regression_tests(void)
934                                  pcre_free(re8);                                  pcre_free(re8);
935                                  re8 = NULL;                                  re8 = NULL;
936                          }                          }
937                  } else if (utf8 && ucp8 && !(current->start_offset & F_NO8))                  } else if (((utf8 && ucp8) || is_ascii_pattern) && !(current->start_offset & F_NO8))
938                          printf("\n8 bit: Cannot compile pattern: %s\n", current->pattern);                          printf("\n8 bit: Cannot compile pattern: %s\n", current->pattern);
939  #endif  #endif
940  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
# Line 913  static int regression_tests(void) Line 964  static int regression_tests(void)
964                                  pcre16_free(re16);                                  pcre16_free(re16);
965                                  re16 = NULL;                                  re16 = NULL;
966                          }                          }
967                  } else if (utf16 && ucp16 && !(current->start_offset & F_NO16))                  } else if (((utf16 && ucp16) || is_ascii_pattern) && !(current->start_offset & F_NO16))
968                          printf("\n16 bit: Cannot compile pattern: %s\n", current->pattern);                          printf("\n16 bit: Cannot compile pattern: %s\n", current->pattern);
969  #endif  #endif
970    
971                  counter++;                  counter++;
972                  if ((counter & 0x3) != 0)                  if ((counter & 0x3) != 0) {
973                          setstack(NULL);  #ifdef SUPPORT_PCRE8
974                            setstack8(NULL);
975    #endif
976    #ifdef SUPPORT_PCRE16
977                            setstack16(NULL);
978    #endif
979                    }
980    
981  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
982                  return_value8_1 = -1000;                  return_value8_1 = -1000;
# Line 929  static int regression_tests(void) Line 986  static int regression_tests(void)
986                  for (i = 0; i < 32; ++i)                  for (i = 0; i < 32; ++i)
987                          ovector8_2[i] = -2;                          ovector8_2[i] = -2;
988                  if (re8) {                  if (re8) {
989                          setstack(extra8);                          setstack8(extra8);
990                          return_value8_1 = pcre_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,                          return_value8_1 = pcre_exec(re8, extra8, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
991                                  current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector8_1, 32);                                  current->flags & (PCRE_NOTBOL | PCRE_NOTEOL | PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART), ovector8_1, 32);
992                          return_value8_2 = pcre_exec(re8, NULL, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,                          return_value8_2 = pcre_exec(re8, NULL, current->input, strlen(current->input), current->start_offset & OFFSET_MASK,
# Line 945  static int regression_tests(void) Line 1002  static int regression_tests(void)
1002                  for (i = 0; i < 32; ++i)                  for (i = 0; i < 32; ++i)
1003                          ovector16_2[i] = -2;                          ovector16_2[i] = -2;
1004                  if (re16) {                  if (re16) {
1005                          setstack(extra16);                          setstack16(extra16);
1006                          if ((current->flags & PCRE_UTF8) || (current->start_offset & F_FORCECONV))                          if ((current->flags & PCRE_UTF8) || (current->start_offset & F_FORCECONV))
1007                                  length16 = convert_utf8_to_utf16(current->input, regtest_buf, regtest_offsetmap, REGTEST_MAX_LENGTH);                                  length16 = convert_utf8_to_utf16(current->input, regtest_buf, regtest_offsetmap, REGTEST_MAX_LENGTH);
1008                          else                          else
# Line 1032  static int regression_tests(void) Line 1089  static int regression_tests(void)
1089    
1090                  if (is_successful) {                  if (is_successful) {
1091  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
1092                          if (!(current->start_offset & F_NO8)) {                          if (!(current->start_offset & F_NO8) && ((utf8 && ucp8) || is_ascii_input)) {
1093                                  if (return_value8_1 < 0 && !(current->start_offset & F_NOMATCH)) {                                  if (return_value8_1 < 0 && !(current->start_offset & F_NOMATCH)) {
1094                                          printf("8 bit: Test should match: [%d] '%s' @ '%s'\n",                                          printf("8 bit: Test should match: [%d] '%s' @ '%s'\n",
1095                                                  total, current->pattern, current->input);                                                  total, current->pattern, current->input);
# Line 1047  static int regression_tests(void) Line 1104  static int regression_tests(void)
1104                          }                          }
1105  #endif  #endif
1106  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
1107                          if (!(current->start_offset & F_NO16)) {                          if (!(current->start_offset & F_NO16) && ((utf16 && ucp16) || is_ascii_input)) {
1108                                  if (return_value16_1 < 0 && !(current->start_offset & F_NOMATCH)) {                                  if (return_value16_1 < 0 && !(current->start_offset & F_NOMATCH)) {
1109                                          printf("16 bit: Test should match: [%d] '%s' @ '%s'\n",                                          printf("16 bit: Test should match: [%d] '%s' @ '%s'\n",
1110                                                  total, current->pattern, current->input);                                                  total, current->pattern, current->input);
# Line 1085  static int regression_tests(void) Line 1142  static int regression_tests(void)
1142                  current++;                  current++;
1143          }          }
1144          tables(1);          tables(1);
1145          setstack(NULL);  #ifdef SUPPORT_PCRE8
1146            setstack8(NULL);
1147    #endif
1148    #ifdef SUPPORT_PCRE16
1149            setstack16(NULL);
1150    #endif
1151    
1152          if (total == successful) {          if (total == successful) {
1153                  printf("\nAll JIT regression tests are successfully passed.\n");                  printf("\nAll JIT regression tests are successfully passed.\n");

Legend:
Removed from v.824  
changed lines
  Added in v.825

  ViewVC Help
Powered by ViewVC 1.1.5