comparison src/regexp_nfa.c @ 4464:c83656c9745a v7.3.980

updated for version 7.3.980 Problem: Regexp logs may contain garbage. Character classes don't work correctly for multi-byte characters. Solution: Check for end of post list. Only use "is" functions for characters up to 255. (Ken Takata)
author Bram Moolenaar <bram@vim.org>
date Mon, 20 May 2013 22:20:02 +0200
parents a63361b90979
children dde1cf311be6
comparison
equal deleted inserted replaced
4463:6ff2a37ec138 4464:c83656c9745a
1824 if (retval == FAIL) 1824 if (retval == FAIL)
1825 fprintf(f, ">>> NFA engine failed ... \n"); 1825 fprintf(f, ">>> NFA engine failed ... \n");
1826 else if (retval == OK) 1826 else if (retval == OK)
1827 fprintf(f, ">>> NFA engine succeeded !\n"); 1827 fprintf(f, ">>> NFA engine succeeded !\n");
1828 fprintf(f, "Regexp: \"%s\"\nPostfix notation (char): \"", expr); 1828 fprintf(f, "Regexp: \"%s\"\nPostfix notation (char): \"", expr);
1829 for (p=post_start; *p; p++) 1829 for (p = post_start; *p && p < post_end; p++)
1830 { 1830 {
1831 nfa_set_code(*p); 1831 nfa_set_code(*p);
1832 fprintf(f, "%s, ", code); 1832 fprintf(f, "%s, ", code);
1833 } 1833 }
1834 fprintf(f, "\"\nPostfix notation (int): "); 1834 fprintf(f, "\"\nPostfix notation (int): ");
1835 for (p=post_start; *p; p++) 1835 for (p = post_start; *p && p < post_end; p++)
1836 fprintf(f, "%d ", *p); 1836 fprintf(f, "%d ", *p);
1837 fprintf(f, "\n\n"); 1837 fprintf(f, "\n\n");
1838 fclose(f); 1838 fclose(f);
1839 } 1839 }
1840 } 1840 }
2665 int c; 2665 int c;
2666 { 2666 {
2667 switch (class) 2667 switch (class)
2668 { 2668 {
2669 case NFA_CLASS_ALNUM: 2669 case NFA_CLASS_ALNUM:
2670 if (isalnum(c)) 2670 if (c >= 1 && c <= 255 && isalnum(c))
2671 return OK; 2671 return OK;
2672 break; 2672 break;
2673 case NFA_CLASS_ALPHA: 2673 case NFA_CLASS_ALPHA:
2674 if (isalpha(c)) 2674 if (c >= 1 && c <= 255 && isalpha(c))
2675 return OK; 2675 return OK;
2676 break; 2676 break;
2677 case NFA_CLASS_BLANK: 2677 case NFA_CLASS_BLANK:
2678 if (c == ' ' || c == '\t') 2678 if (c == ' ' || c == '\t')
2679 return OK; 2679 return OK;
2680 break; 2680 break;
2681 case NFA_CLASS_CNTRL: 2681 case NFA_CLASS_CNTRL:
2682 if (iscntrl(c)) 2682 if (c >= 1 && c <= 255 && iscntrl(c))
2683 return OK; 2683 return OK;
2684 break; 2684 break;
2685 case NFA_CLASS_DIGIT: 2685 case NFA_CLASS_DIGIT:
2686 if (VIM_ISDIGIT(c)) 2686 if (VIM_ISDIGIT(c))
2687 return OK; 2687 return OK;
2688 break; 2688 break;
2689 case NFA_CLASS_GRAPH: 2689 case NFA_CLASS_GRAPH:
2690 if (isgraph(c)) 2690 if (c >= 1 && c <= 255 && isgraph(c))
2691 return OK; 2691 return OK;
2692 break; 2692 break;
2693 case NFA_CLASS_LOWER: 2693 case NFA_CLASS_LOWER:
2694 if (MB_ISLOWER(c)) 2694 if (MB_ISLOWER(c))
2695 return OK; 2695 return OK;
2697 case NFA_CLASS_PRINT: 2697 case NFA_CLASS_PRINT:
2698 if (vim_isprintc(c)) 2698 if (vim_isprintc(c))
2699 return OK; 2699 return OK;
2700 break; 2700 break;
2701 case NFA_CLASS_PUNCT: 2701 case NFA_CLASS_PUNCT:
2702 if (ispunct(c)) 2702 if (c >= 1 && c <= 255 && ispunct(c))
2703 return OK; 2703 return OK;
2704 break; 2704 break;
2705 case NFA_CLASS_SPACE: 2705 case NFA_CLASS_SPACE:
2706 if ((c >=9 && c <= 13) || (c == ' ')) 2706 if ((c >=9 && c <= 13) || (c == ' '))
2707 return OK; 2707 return OK;