From: Finn B. <bc...@us...> - 2001-11-27 19:07:25
|
Update of /cvsroot/jython/jython/org/python/modules/sre In directory usw-pr-cvs1:/tmp/cvs-serv31804/modules/sre Modified Files: MatchObject.java PatternObject.java SRE_STATE.java Log Message: Long line normalization. Index: MatchObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/MatchObject.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MatchObject.java 2001/11/27 13:51:37 1.5 --- MatchObject.java 2001/11/27 19:07:22 1.6 *************** *** 128,132 **** PyTuple _pair(int i1, int i2) { ! return new PyTuple(new PyObject[] { Py.newInteger(i1), Py.newInteger(i2) }); } --- 128,134 ---- PyTuple _pair(int i1, int i2) { ! return new PyTuple(new PyObject[] { ! Py.newInteger(i1), Py.newInteger(i2) ! }); } *************** *** 158,162 **** int end = mark[index+1]; ! //System.out.println("group:" + index + " " + start + " " + end + " l:" + string.length()); if (string == null || start < 0) --- 160,165 ---- int end = mark[index+1]; ! //System.out.println("group:" + index + " " + start + " " + ! // end + " l:" + string.length()); if (string == null || start < 0) Index: PatternObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/PatternObject.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PatternObject.java 2001/11/27 13:51:37 1.6 --- PatternObject.java 2001/11/27 19:07:22 1.7 *************** *** 61,65 **** public MatchObject search(PyObject[] args, String[] kws) { ! ArgParser ap = new ArgParser("search", args, kws, "pattern", "pos", "endpos"); String string = ap.getString(0); int start = ap.getInt(1, 0); --- 61,66 ---- public MatchObject search(PyObject[] args, String[] kws) { ! ArgParser ap = new ArgParser("search", args, kws, ! "pattern", "pos", "endpos"); String string = ap.getString(0); int start = ap.getInt(1, 0); *************** *** 75,79 **** public PyObject sub(PyObject[] args, String[] kws) { ! ArgParser ap = new ArgParser("sub", args, kws, "repl", "string", "count"); PyObject template = ap.getPyObject(0); String string = ap.getString(1); --- 76,81 ---- public PyObject sub(PyObject[] args, String[] kws) { ! ArgParser ap = new ArgParser("sub", args, kws, ! "repl", "string", "count"); PyObject template = ap.getPyObject(0); String string = ap.getString(1); *************** *** 89,93 **** public PyObject subn(PyObject[] args, String[] kws) { ! ArgParser ap = new ArgParser("subn", args, kws, "repl", "string", "count"); PyObject template = ap.getPyObject(0); String string = ap.getString(1); --- 91,96 ---- public PyObject subn(PyObject[] args, String[] kws) { ! ArgParser ap = new ArgParser("subn", args, kws, ! "repl", "string", "count"); PyObject template = ap.getPyObject(0); String string = ap.getString(1); *************** *** 103,107 **** public PyObject split(PyObject[] args, String[] kws) { ! ArgParser ap = new ArgParser("split", args, kws, "source", "maxsplit"); String string = ap.getString(0); int count = ap.getInt(1, 0); --- 106,111 ---- public PyObject split(PyObject[] args, String[] kws) { ! ArgParser ap = new ArgParser("split", args, kws, ! "source", "maxsplit"); String string = ap.getString(0); int count = ap.getInt(1, 0); *************** *** 121,125 **** public PyObject findall(PyObject[] args, String[] kws) { ! ArgParser ap = new ArgParser("findall", args, kws, "source", "pos", "endpos"); String string = ap.getString(0); int start = ap.getInt(1, 0); --- 125,130 ---- public PyObject findall(PyObject[] args, String[] kws) { ! ArgParser ap = new ArgParser("findall", args, kws, ! "source", "pos", "endpos"); String string = ap.getString(0); int start = ap.getInt(1, 0); *************** *** 140,144 **** switch (groups) { case 0: ! item = Py.newString(string.substring(state.start, state.ptr)); break; case 1: --- 145,150 ---- switch (groups) { case 0: ! item = Py.newString( ! string.substring(state.start, state.ptr)); break; case 1: *************** *** 196,204 **** ! MatchObject _pattern_new_match(SRE_STATE state, String string, int status) { ! /* create match object (from state object) */ - //System.out.println("status = " + status + " " + string); --- 202,210 ---- ! MatchObject _pattern_new_match(SRE_STATE state, String string, ! int status) ! { /* create match object (from state object) */ //System.out.println("status = " + status + " " + string); *************** *** 220,224 **** int i, j; for (i = j = 0; i < groups; i++, j+=2) { ! if (j+1 <= state.lastmark && state.mark[j] != -1 && state.mark[j+1] != -1) { match.mark[j+2] = state.mark[j] - base; match.mark[j+3] = state.mark[j+1] - base; --- 226,231 ---- int i, j; for (i = j = 0; i < groups; i++, j+=2) { ! if (j+1 <= state.lastmark && state.mark[j] != -1 && ! state.mark[j+1] != -1) { match.mark[j+2] = state.mark[j] - base; match.mark[j+3] = state.mark[j+1] - base; Index: SRE_STATE.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/SRE_STATE.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SRE_STATE.java 2001/11/27 13:51:37 1.6 --- SRE_STATE.java 2001/11/27 19:07:22 1.7 *************** *** 21,28 **** public class SRE_STATE { ! public static final int SRE_ERROR_ILLEGAL = -1; /* illegal opcode */ ! public static final int SRE_ERROR_STATE = -2; /* illegal state */ ! public static final int SRE_ERROR_RECURSION_LIMIT = -3; /* runaway recursion */ public static final int SRE_OP_FAILURE = 0; public static final int SRE_OP_SUCCESS = 1; --- 21,33 ---- public class SRE_STATE { ! /* illegal opcode */ ! public static final int SRE_ERROR_ILLEGAL = -1; ! ! /* illegal state */ ! public static final int SRE_ERROR_STATE = -2; + /* runaway recursion */ + public static final int SRE_ERROR_RECURSION_LIMIT = -3; + public static final int SRE_OP_FAILURE = 0; public static final int SRE_OP_SUCCESS = 1; *************** *** 120,124 **** int lastindex; int lastmark; ! int[] mark = new int[200]; /* FIXME: <fl> should be dynamically allocated! */ /* dynamically allocated stuff */ --- 125,131 ---- int lastindex; int lastmark; ! ! /* FIXME: <fl> should be dynamically allocated! */ ! int[] mark = new int[200]; /* dynamically allocated stuff */ *************** *** 316,320 **** case SRE_OP_CHARSET: /* <CHARSET> <bitmap> (16 bits per code word) */ ! if (ch < 256 && (set[setidx + (ch >> 4)] & (1 << (ch & 15))) != 0) return ok; setidx += 16; --- 323,328 ---- case SRE_OP_CHARSET: /* <CHARSET> <bitmap> (16 bits per code word) */ ! if (ch < 256 && ! (set[setidx + (ch >> 4)] & (1 << (ch & 15))) != 0) return ok; setidx += 16; *************** *** 591,595 **** case SRE_OP_IN_IGNORE: //TRACE(pidx, ptr, "IN_IGNORE"); ! if (ptr >= end || !SRE_CHARSET(pattern, pidx + 1, lower(str[ptr]))) return 0; pidx += (int)pattern[pidx]; --- 599,604 ---- case SRE_OP_IN_IGNORE: //TRACE(pidx, ptr, "IN_IGNORE"); ! if (ptr >= end || ! !SRE_CHARSET(pattern, pidx + 1, lower(str[ptr]))) return 0; pidx += (int)pattern[pidx]; *************** *** 656,661 **** (ptr >= end || str[ptr] != pattern[pidx+2])) continue; ! if (pattern[pidx+1] == SRE_OP_IN && ! (ptr >= end || !SRE_CHARSET(pattern, pidx + 3, str[ptr]))) continue; this.ptr = ptr; --- 665,670 ---- (ptr >= end || str[ptr] != pattern[pidx+2])) continue; ! if (pattern[pidx+1] == SRE_OP_IN && (ptr >= end || ! !SRE_CHARSET(pattern, pidx + 3, str[ptr]))) continue; this.ptr = ptr; *************** *** 687,691 **** this.ptr = ptr; ! count = SRE_COUNT(pattern, pidx + 3, pattern[pidx+2], level + 1); if (count < 0) return count; --- 696,701 ---- this.ptr = ptr; ! count = SRE_COUNT(pattern, pidx + 3, pattern[pidx+2], ! level + 1); if (count < 0) return count; *************** *** 719,723 **** break; this.ptr = ptr; ! i = SRE_MATCH(pattern, pidx + pattern[pidx], level + 1); if (i != 0) return 1; --- 729,734 ---- break; this.ptr = ptr; ! i = SRE_MATCH(pattern, pidx + pattern[pidx], ! level + 1); if (i != 0) return 1; *************** *** 731,735 **** while (count >= mincount) { this.ptr = ptr; ! i = SRE_MATCH(pattern, pidx + pattern[pidx], level + 1); if (i != 0) return i; --- 742,747 ---- while (count >= mincount) { this.ptr = ptr; ! i = SRE_MATCH(pattern, pidx + pattern[pidx], ! level + 1); if (i != 0) return i; *************** *** 792,796 **** } ! if (count < pattern[rp.pidx+2] || pattern[rp.pidx+2] == 65535) { /* we may have enough matches, but if we can match another item, do so */ --- 804,809 ---- } ! if (count < pattern[rp.pidx+2] || ! pattern[rp.pidx+2] == 65535) { /* we may have enough matches, but if we can match another item, do so */ *************** *** 862,866 **** this.repeat = rp; ! if (count >= pattern[rp.pidx+2] && pattern[rp.pidx+2] != 65535) return 0; --- 875,880 ---- this.repeat = rp; ! if (count >= pattern[rp.pidx+2] && ! pattern[rp.pidx+2] != 65535) return 0; *************** *** 949,953 **** if ((flags & SRE_INFO_LITERAL) != 0) return 1; /* we got all of it */ ! status = SRE_MATCH(pattern, pidx + 2*prefix_skip, 1); if (status != 0) return status; --- 963,968 ---- if ((flags & SRE_INFO_LITERAL) != 0) return 1; /* we got all of it */ ! status = SRE_MATCH(pattern, ! pidx + 2*prefix_skip, 1); if (status != 0) return status; *************** *** 1079,1083 **** static final int SRE_WORD_MASK = 16; ! static byte[] sre_char_info = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, --- 1094,1099 ---- static final int SRE_WORD_MASK = 16; ! static byte[] sre_char_info = new byte[] { ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, *************** *** 1087,1091 **** 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0 }; ! static byte[] sre_char_lower = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, --- 1103,1108 ---- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0 }; ! static byte[] sre_char_lower = new byte[] { ! 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, *************** *** 1098,1110 **** final boolean SRE_IS_DIGIT(char ch) { ! return ((ch) < 128 ? (sre_char_info[(ch)] & SRE_DIGIT_MASK) != 0 : false); } final boolean SRE_IS_SPACE(char ch) { ! return ((ch) < 128 ? (sre_char_info[(ch)] & SRE_SPACE_MASK) != 0 : false); } final boolean SRE_IS_WORD(char ch) { ! return ((ch) < 128 ? (sre_char_info[(ch)] & SRE_WORD_MASK) != 0 : false); } --- 1115,1130 ---- final boolean SRE_IS_DIGIT(char ch) { ! return ((ch) < 128 ? ! (sre_char_info[(ch)] & SRE_DIGIT_MASK) != 0 : false); } final boolean SRE_IS_SPACE(char ch) { ! return ((ch) < 128 ? ! (sre_char_info[(ch)] & SRE_SPACE_MASK) != 0 : false); } final boolean SRE_IS_WORD(char ch) { ! return ((ch) < 128 ? ! (sre_char_info[(ch)] & SRE_WORD_MASK) != 0 : false); } |