Author: bodewig
Date: Fri Oct 10 09:20:54 2008
New Revision: 703516
URL: http://svn.apache.org/viewvc?rev=703516&view=rev
Log:
javadoc fails if bottom/gead contain line breaks. PR 43342. Based on patch by
Robert Streich.
Added:
ant/core/trunk/src/tests/antunit/taskdefs/javadoc-test.xml (with props)
Modified:
ant/core/trunk/CONTRIBUTORS
ant/core/trunk/WHATSNEW
ant/core/trunk/contributors.xml
ant/core/trunk/docs/manual/CoreTasks/javadoc.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
Modified: ant/core/trunk/CONTRIBUTORS
URL:
http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=703516&r1=703515&r2=703516&view=diff
==============================================================================
Binary files - no diff available.
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=703516&r1=703515&r2=703516&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Oct 10 09:20:54 2008
@@ -236,6 +236,10 @@
find the corresponding source files.
Bugzilla Report 45916.
+ * <javadoc> failed if the nested <bottom> or <head> contained line
+ breaks.
+ Bugzilla Report 43342.
+
Other changes:
--------------
Modified: ant/core/trunk/contributors.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=703516&r1=703515&r2=703516&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Fri Oct 10 09:20:54 2008
@@ -974,6 +974,10 @@
</name>
<name>
<first>Robert</first>
+ <last>Streich</last>
+ </name>
+ <name>
+ <first>Robert</first>
<last>Watkins</last>
</name>
<name>
Modified: ant/core/trunk/docs/manual/CoreTasks/javadoc.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/javadoc.html?rev=703516&r1=703515&r2=703516&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/javadoc.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/javadoc.html Fri Oct 10 09:20:54 2008
@@ -413,7 +413,7 @@
in srcfiles or as nested source elements should be written to a
temporary file to make the command line shorter. Also applies to
the package names specified via the packagenames attribute or
- nested package elements.<em>Since Ant 1.7.0</em>, also applies
+ nested package elements. <em>Since Ant 1.7.0</em>, also applies
to all the other command line options.
(<code>yes</code> | <code>no</code>). Default is no.</td>
<td align="center" valign="top">all</td>
@@ -571,6 +571,9 @@
<p>Same as the <code>doctitle</code> attribute, but you can nest text
inside the element this way.</p>
+<p>If the nested text contains line breaks, you must use the
+ useexternalfile attribute and set it to true.</p>
+
<h4>header</h4>
<p>Similar to <code><doctitle></code>.</p>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java?rev=703516&r1=703515&r2=703516&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java Fri Oct
10 09:20:54 2008
@@ -2243,30 +2243,46 @@
return false;
}
- private String quoteString(String str, final char delim) {
+ private String quoteString(final String str, final char delim) {
StringBuffer buf = new StringBuffer(str.length() * 2);
buf.append(delim);
- if (str.indexOf('\\') != -1) {
- str = replace(str, '\\', "\\\\");
- }
- if (str.indexOf(delim) != -1) {
- str = replace(str, delim, "\\" + delim);
- }
- buf.append(str);
- buf.append(delim);
- return buf.toString();
- }
-
- private String replace(String str, char fromChar, String toString) {
- StringBuffer buf = new StringBuffer(str.length() * 2);
- for (int i = 0; i < str.length(); ++i) {
- char ch = str.charAt(i);
- if (ch == fromChar) {
- buf.append(toString);
+ final int len = str.length();
+ boolean lastCharWasCR = false;
+ for (int i = 0; i < len; i++) {
+ char c = str.charAt(i);
+ if (c == delim) { // can't put the non-constant delim into a case
+ buf.append('\\').append(c);
+ lastCharWasCR = false;
} else {
- buf.append(ch);
+ switch (c) {
+ case '\\':
+ buf.append("\\\\");
+ lastCharWasCR = false;
+ break;
+ case '\r':
+ // insert a line continuation marker
+ buf.append("\\\r");
+ lastCharWasCR = true;
+ break;
+ case '\n':
+ // insert a line continuation marker unless this
+ // is a \r\n sequence in which case \r already has
+ // created the marker
+ if (!lastCharWasCR) {
+ buf.append("\\\n");
+ } else {
+ buf.append("\n");
+ }
+ lastCharWasCR = false;
+ break;
+ default:
+ buf.append(c);
+ lastCharWasCR = false;
+ break;
+ }
}
}
+ buf.append(delim);
return buf.toString();
}
Added: ant/core/trunk/src/tests/antunit/taskdefs/javadoc-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/javadoc-test.xml?rev=703516&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/javadoc-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/taskdefs/javadoc-test.xml Fri Oct 10
09:20:54 2008
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+ <import file="../antunit-base.xml" />
+
+ <target name="testBottomWithLineBreaksWithFile">
+ <mkdir dir="${input}/test"/>
+ <echo file="${input}/test/A.java"><![CDATA[
+package test;
+
+/**
+ * This is a test class.
+ */
+public class A {
+ /**
+ * With a test method.
+ */
+ public void foo(String bar) {}
+}
+]]></echo>
+ <javadoc destdir="${output}" useexternalfile="true">
+ <fileset dir="${input}"/>
+ <bottom><![CDATA[
+<hr/>
+Hello World
+]]></bottom>
+ </javadoc>
+ <au:assertFileExists file="${output}/test/A.html"/>
+ </target>
+</project>
Propchange: ant/core/trunk/src/tests/antunit/taskdefs/javadoc-test.xml
------------------------------------------------------------------------------
svn:eol-style = native