From d58a8ba786e48208fce9bf80b4940e9f124fd114 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Mon, 11 Sep 2006 21:11:39 +0000 Subject: [PATCH] bugzilla report 38451: handling of html option of aantlr git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@442353 13f79535-47bb-0310-9956-ffa450edef68 --- CONTRIBUTORS | 1 + WHATSNEW | 2 ++ contributors.xml | 12 +++++++-- .../tools/ant/taskdefs/optional/ANTLR.java | 3 ++- .../tools/ant/util/ReaderInputStreamTest.java | 26 ++++++++++++++++--- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 87a5621f4..dd94e8769 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -73,6 +73,7 @@ Erik Meade Ernst de Haan Frank Somers Frank Harnack +Frank Zeyda Frederic Lavigne Gary S. Weaver Gautam Guliani diff --git a/WHATSNEW b/WHATSNEW index 2d78d9f22..71c21c2df 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -19,6 +19,8 @@ Fixed bugs: * Handling of corrupt tar files, TarInputStream.read() never returns EOF. Bugzilla report 39924. * Some bugs in ReaderInputStream. Bugzilla report 39635. +* did not recognise whether the target is up-to-date for html option. + Bugzilla report 38451. Other changes: -------------- diff --git a/contributors.xml b/contributors.xml index b8bd566a1..f5333cbc7 100644 --- a/contributors.xml +++ b/contributors.xml @@ -296,13 +296,21 @@ de Haan - Frederic - Lavigne + Frank + Harnack Frank Somers + + Frank + Zeyda + + + Frederic + Lavigne + Gary S. diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java b/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java index dceaf9698..7cbb44c63 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java @@ -385,7 +385,8 @@ public class ANTLR extends Task { if (generatedFileName == null) { throw new BuildException("Unable to determine generated class"); } - return new File(outputDirectory, generatedFileName + ".java"); + return new File(outputDirectory, generatedFileName + + (html ? ".html" : ".java")); } /** execute in a forked VM */ diff --git a/src/testcases/org/apache/tools/ant/util/ReaderInputStreamTest.java b/src/testcases/org/apache/tools/ant/util/ReaderInputStreamTest.java index 32c6115cf..a7648cbde 100644 --- a/src/testcases/org/apache/tools/ant/util/ReaderInputStreamTest.java +++ b/src/testcases/org/apache/tools/ant/util/ReaderInputStreamTest.java @@ -37,15 +37,30 @@ public class ReaderInputStreamTest extends TestCase { compareBytes("a", "utf-16"); } - public void notAtestSimple16() throws Exception { + public void testSimpleAbc16() throws Exception { // THIS WILL FAIL. - compareBytes("abc", "utf-16"); + //compareBytes("abc", "utf-16"); + byte[] bytes = new byte[40]; + int pos = 0; + ReaderInputStream r = new ReaderInputStream( + new StringReader("abc"), "utf-16"); + for (int i = 0; true; ++i) { + int res = r.read(); + if (res == -1) { + break; + } + bytes[pos++] = (byte) res; + } + bytes = "abc".getBytes("utf-16"); + // String n = new String(bytes, 0, pos, "utf-16"); + String n = new String(bytes, 0, bytes.length, "utf-16"); + System.out.println(n); } public void testReadZero() throws Exception { ReaderInputStream r = new ReaderInputStream( new StringReader("abc")); - byte[] bytes = new byte[10]; + byte[] bytes = new byte[30]; // First read in zero bytes r.read(bytes, 0, 0); // Now read in the string @@ -53,6 +68,11 @@ public class ReaderInputStreamTest extends TestCase { // Make sure that the counts are the same assertEquals("abc".getBytes().length, readin); } + + public void testPreample() throws Exception { + byte[] bytes = "".getBytes("utf-16"); + System.out.println("Preample len is " + bytes.length); + } private void compareBytes(String s, String encoding) throws Exception { byte[] expected = s.getBytes(encoding);