vgritsenko 2003/09/05 18:45:51 Modified: . build.xml docs changes.html src/java/org/apache/regexp RE.java RETest.java xdocs changes.xml Log: Starting 1.4-dev. Fixing bug #22928. Adding test for bug #22928. Revision Changes Path 1.5 +2 -1 jakarta-regexp/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-regexp/build.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- build.xml 2 Sep 2003 16:30:39 -0000 1.4 +++ build.xml 6 Sep 2003 01:45:51 -0000 1.5 @@ -22,7 +22,7 @@ <property name="ant.home" value="."/> <property name="Name" value="Jakarta-Regexp"/> <property name="year" value="2001-2003"/> - <property name="version" value="1.3"/> + <property name="version" value="1.4-dev"/> <property name="project" value="jakarta-regexp"/> <property name="build.dir" value="build"/> @@ -84,6 +84,7 @@ <!-- Compiles the source directory --> <!-- =================================================================== --> <target name="compile" depends="prepare"> + <echo message="Compiling with Java ${ant.java.version}, debug ${debug}, optimize ${optimize}, deprecation ${deprecation}"/> <javac srcdir="${build.src}" destdir="${build.dest}" excludes="**/package.html" 1.13 +6 -0 jakarta-regexp/docs/changes.html Index: changes.html =================================================================== RCS file: /home/cvs/jakarta-regexp/docs/changes.html,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- changes.html 2 Sep 2003 16:30:39 -0000 1.12 +++ changes.html 6 Sep 2003 01:45:51 -0000 1.13 @@ -80,6 +80,12 @@ This document reflects the changes between releases for the Jakarta Regexp package. </p> + <h3>Version 1.4-dev</h3> + <ul> +<li>Fixed Bug + <a href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22928">22928</a>: + subst() with REPLACE_BACKREFERENCES cuts first 2 characters (VG)</li> +</ul> <h3>Version 1.3</h3> <ul> <li>Fixed Bug 1.14 +14 -3 jakarta-regexp/src/java/org/apache/regexp/RE.java Index: RE.java =================================================================== RCS file: /home/cvs/jakarta-regexp/src/java/org/apache/regexp/RE.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- RE.java 2 Jun 2003 02:18:41 -0000 1.13 +++ RE.java 6 Sep 2003 01:45:51 -0000 1.14 @@ -1733,6 +1733,7 @@ int lCurrentPosition = 0; int lLastPosition = 0; int lLength = substitution.length(); + boolean bAddedPrefix = false; while ((lCurrentPosition = substitution.indexOf("$", lCurrentPosition)) >= 0) { @@ -1742,8 +1743,18 @@ char c = substitution.charAt(lCurrentPosition + 1); if (c >= '0' && c <= '9') { - // Append everything between the last and the current $ sign - ret.append(substitution.substring(lLastPosition+2, lCurrentPosition)); + if (bAddedPrefix == false) + { + // Append everything between the beginning of the + // substitution string and the current $ sign + ret.append(substitution.substring(0, lCurrentPosition)); + bAddedPrefix = true; + } + else + { + // Append everything between the last and the current $ sign + ret.append(substitution.substring(lLastPosition + 2, lCurrentPosition)); + } // Append the parenthesized expression // Note: if a parenthesized expression of the requested 1.6 +30 -12 jakarta-regexp/src/java/org/apache/regexp/RETest.java Index: RETest.java =================================================================== RCS file: /home/cvs/jakarta-regexp/src/java/org/apache/regexp/RETest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- RETest.java 2 May 2003 01:03:47 -0000 1.5 +++ RETest.java 6 Sep 2003 01:45:51 -0000 1.6 @@ -325,12 +325,12 @@ s = r.grep(s); for (int i = 0; i < s.length; i++) { - System.out.println ("s[" + i + "] = " + s[i]); + say("s[" + i + "] = " + s[i]); } r = new RE("a*b"); String s1 = r.subst("aaaabfooaaabgarplyaaabwackyb", "-"); - System.out.println ("s = " + s1); + say("s = " + s1); // Some unit tests runAutomatedTests(); @@ -362,7 +362,7 @@ } if (!number.equals("")) { - System.out.println ("Script error. Line = " + number); + say("Script error. Line = " + number); System.exit(0); } } @@ -528,10 +528,13 @@ } // Show match time - System.out.println( NEW_LINE + NEW_LINE + "Match time = " + (System.currentTimeMillis() - ms) + " ms."); + say(NEW_LINE + NEW_LINE + "Match time = " + (System.currentTimeMillis() - ms) + " ms."); // Print final results - System.out.println( NEW_LINE + "Tests complete. " + n + " tests, " + failures + " failure(s)."); + if (failures > 0) { + say("*************** THERE ARE FAILURES! *******************"); + } + say("Tests complete. " + n + " tests, " + failures + " failure(s)."); } /** @@ -547,7 +550,8 @@ new ObjectOutputStream(out).writeObject(r); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); r = (RE)new ObjectInputStream(in).readObject(); - if (!r.match("aaab")) { + if (!r.match("aaab")) + { fail("Did not match 'aaab' with deserialized RE."); } say("aaaab = true"); @@ -559,10 +563,12 @@ new ObjectOutputStream(out).writeObject(r); in = new ByteArrayInputStream(out.toByteArray()); r = (RE)new ObjectInputStream(in).readObject(); - if (r.getParenCount() != 0) { + if (r.getParenCount() != 0) + { fail("Has parens after deserialization."); } - if (!r.match("aaab")) { + if (!r.match("aaab")) + { fail("Did not match 'aaab' with deserialized RE."); } say("aaaab = true"); @@ -573,22 +579,34 @@ say("MATCH_CASEINDEPENDENT abc(\\w*)"); r.setMatchFlags(RE.MATCH_CASEINDEPENDENT); say("abc(d*)"); - if (!r.match("abcddd")) { + if (!r.match("abcddd")) + { fail("Did not match 'abcddd'."); } say("abcddd = true"); showParens(r); - if (!r.match("aBcDDdd")) { + if (!r.match("aBcDDdd")) + { fail("Did not match 'aBcDDdd'."); } say("aBcDDdd = true"); showParens(r); - if (!r.match("ABCDDDDD")) { + if (!r.match("ABCDDDDD")) + { fail("Did not match 'ABCDDDDD'."); } say("ABCDDDDD = true"); showParens(r); + + // Test subst() with backreferences + r = new RE("http://[\\.\\w\\-\\?/~_@&=%]+"); + String s = r.subst("visit us: http://www.apache.org!", + "1234<a href=\"$0\">$0</a>", RE.REPLACE_BACKREFERENCES); + if (!s.equals("visit us: 1234<a href=\"http://www.apache.org\">http://www.apache.org</a>!")) + { + fail("Wrong subst() result: " + s); + } } } 1.14 +7 -0 jakarta-regexp/xdocs/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/jakarta-regexp/xdocs/changes.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- changes.xml 2 Sep 2003 16:30:39 -0000 1.13 +++ changes.xml 6 Sep 2003 01:45:51 -0000 1.14 @@ -15,6 +15,13 @@ package. </p> +<h3>Version 1.4-dev</h3> +<ul> +<li>Fixed Bug + <a href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22928">22928</a>: + subst() with REPLACE_BACKREFERENCES cuts first 2 characters (VG)</li> +</ul> + <h3>Version 1.3</h3> <ul> <li>Fixed Bug
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]