From: Finn B. <bc...@us...> - 2001-01-21 14:04:22
|
Update of /cvsroot/jython/jython/org/python/modules/sre In directory usw-pr-cvs1:/tmp/cvs-serv11778/sre Modified Files: PatternObject.java SRE_STATE.java Log Message: Updated with changes to _sre.c: 2.52. Index: PatternObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/PatternObject.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** PatternObject.java 2000/10/28 11:58:20 1.4 --- PatternObject.java 2001/01/21 14:04:32 1.5 *************** *** 14,17 **** --- 14,18 ---- */ + package org.python.modules.sre; *************** *** 132,135 **** --- 133,137 ---- while (state.start <= state.end) { + state.state_reset(); state.ptr = state.start; int status = state.SRE_SEARCH(code, 0); Index: SRE_STATE.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/SRE_STATE.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** SRE_STATE.java 2000/10/28 11:56:18 1.3 --- SRE_STATE.java 2001/01/21 14:04:32 1.4 *************** *** 14,17 **** --- 14,19 ---- */ + // Last updated to _sre.c: 2.52 + package org.python.modules.sre; *************** *** 55,62 **** public static final int SRE_AT_BEGINNING = 0; public static final int SRE_AT_BEGINNING_LINE = 1; ! public static final int SRE_AT_BOUNDARY = 2; ! public static final int SRE_AT_NON_BOUNDARY = 3; ! public static final int SRE_AT_END = 4; ! public static final int SRE_AT_END_LINE = 5; public static final int SRE_CATEGORY_DIGIT = 0; --- 57,66 ---- public static final int SRE_AT_BEGINNING = 0; public static final int SRE_AT_BEGINNING_LINE = 1; ! public static final int SRE_AT_BEGINNING_STRING = 2; ! public static final int SRE_AT_BOUNDARY = 3; ! public static final int SRE_AT_NON_BOUNDARY = 4; ! public static final int SRE_AT_END = 5; ! public static final int SRE_AT_END_LINE = 6; ! public static final int SRE_AT_END_STRING = 7; public static final int SRE_CATEGORY_DIGIT = 0; *************** *** 229,232 **** --- 233,237 ---- switch (at) { case SRE_AT_BEGINNING: + case SRE_AT_BEGINNING_STRING: return ptr == beginning; *************** *** 240,243 **** --- 245,251 ---- return ptr == end || SRE_IS_LINEBREAK(str[ptr]); + case SRE_AT_END_STRING: + return ptr == end; + case SRE_AT_BOUNDARY: /* word boundary */ *************** *** 609,619 **** //TRACE(pidx, ptr, "ASSERT_NOT " + (int) pattern[pidx]); this.ptr = ptr - pattern[pidx + 1]; ! if (this.ptr < this.beginning) ! return 0; ! i = SRE_MATCH(pattern, pidx + 2, level + 1); ! if (i < 0) ! return i; ! if (i != 0) ! return 0; pidx += pattern[pidx]; break; --- 617,627 ---- //TRACE(pidx, ptr, "ASSERT_NOT " + (int) pattern[pidx]); this.ptr = ptr - pattern[pidx + 1]; ! if (this.ptr >= this.beginning) { ! i = SRE_MATCH(pattern, pidx + 2, level + 1); ! if (i < 0) ! return i; ! if (i != 0) ! return 0; ! } pidx += pattern[pidx]; break; *************** *** 647,657 **** exactly one character wide, and we're not already collecting backtracking points. for other cases, ! use the MAX_REPEAT operator instead */ /* <REPEAT_ONE> <skip> <1=min> <2=max> item <SUCCESS> tail */ ! //TRACE(pidx, ptr, "REPEAT_ONE " + (int)pattern[pidx+1] + " " + (int)pattern[pidx+2]); ! if (ptr + pattern[pidx+1] > end) return 0; /* cannot match */ --- 655,666 ---- exactly one character wide, and we're not already collecting backtracking points. for other cases, ! use the MAX_REPEAT operator */ /* <REPEAT_ONE> <skip> <1=min> <2=max> item <SUCCESS> tail */ ! int mincount = pattern[pidx+1]; ! //TRACE(pidx, ptr, "REPEAT_ONE " + mincount + " " + (int)pattern[pidx+2]); ! if (ptr + mincount > end) return 0; /* cannot match */ *************** *** 669,673 **** and backtrack if not. */ ! if (count < pattern[pidx+1]) return 0; --- 678,682 ---- and backtrack if not. */ ! if (count < mincount) return 0; *************** *** 682,691 **** chr = pattern[pidx + pattern[pidx]+1]; for (;;) { ! while (count >= pattern[pidx+1] && (ptr >= end || str[ptr] != chr)) { ptr--; count--; } ! if (count < pattern[pidx+1]) break; this.ptr = ptr; --- 691,700 ---- chr = pattern[pidx + pattern[pidx]+1]; for (;;) { ! while (count >= mincount && (ptr >= end || str[ptr] != chr)) { ptr--; count--; } ! if (count < mincount) break; this.ptr = ptr; *************** *** 700,704 **** /* general case */ lastmark = this.lastmark; ! while (count >= pattern[pidx+1]) { this.ptr = ptr; i = SRE_MATCH(pattern, pidx + pattern[pidx], level + 1); --- 709,713 ---- /* general case */ lastmark = this.lastmark; ! while (count >= mincount) { this.ptr = ptr; i = SRE_MATCH(pattern, pidx + pattern[pidx], level + 1); *************** *** 716,720 **** case SRE_OP_REPEAT: /* create repeat context. all the hard work is done ! by the UNTIL operator */ /* <REPEAT> <skip> <1=min> <2=max> item <UNTIL> tail */ --- 725,729 ---- case SRE_OP_REPEAT: /* create repeat context. all the hard work is done ! by the UNTIL operator (MAX_UNTIL, MIN_UNTIL) */ /* <REPEAT> <skip> <1=min> <2=max> item <UNTIL> tail */ *************** *** 786,789 **** --- 795,799 ---- return i; this.repeat = rp; + this.ptr = ptr; return 0; *************** *** 798,802 **** count = rp.count + 1; ! //TRACE(pidx, ptr, "MIN_UNTIL " + count); this.ptr = ptr; --- 808,812 ---- count = rp.count + 1; ! //TRACE(pidx, ptr, "MIN_UNTIL " + count + " " + rp.pidx); this.ptr = ptr; *************** *** 816,823 **** /* see if the tail matches */ this.repeat = rp.prev; ! /* RECURSIVE */ ! i = SRE_MATCH(pattern, pidx, level + 1); if (i != 0) return i; this.repeat = rp; --- 826,843 ---- /* see if the tail matches */ this.repeat = rp.prev; ! if (pattern[rp.pidx + 2] == 65535) { ! /* unbounded repeat */ ! for (;;) { ! i = SRE_MATCH(pattern, pidx, level + 1); ! if (i != 0 || ptr >= end) ! break; ! this.ptr = ++ptr; ! } ! } else ! i = SRE_MATCH(pattern, pidx, level + 1); if (i != 0) return i; + + this.ptr = ptr; this.repeat = rp; *************** *** 826,833 **** --- 846,855 ---- rp.count = count; + /* RECURSIVE */ i = SRE_MATCH(pattern, rp.pidx + 3, level + 1); if (i != 0) return i; rp.count = count - 1; + this.ptr = ptr; return 0; |