changeset 1910:80e75aa6a707

8014636: TestLiteralCodeInPre fails on windows Reviewed-by: ksrini
author jjg
date Wed, 17 Jul 2013 18:18:45 -0700
parents e990e6bcecbe
children 1e533c1bfb01
files src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java test/com/sun/javadoc/testLeadingSpaces/LeadingSpaces.java test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java test/com/sun/javadoc/testLiteralCodeInPre/TestLiteralCodeInPre.java test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java
diffstat 8 files changed, 60 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Jul 17 10:40:53 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Jul 17 18:18:45 2013 -0700
@@ -1621,6 +1621,7 @@
                     text = removeNonInlineHtmlTags(text);
                 }
                 text = Util.replaceTabs(configuration, text);
+                text = Util.normalizeNewlines(text);
                 result.addContent(new RawHtml(text));
             }
         }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java	Wed Jul 17 10:40:53 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java	Wed Jul 17 18:18:45 2013 -0700
@@ -71,7 +71,7 @@
      * {@inheritDoc}
      */
     protected Content codeTagOutput(Tag tag) {
-        Content result = HtmlTree.CODE(new StringContent(tag.text()));
+        Content result = HtmlTree.CODE(new StringContent(Util.normalizeNewlines(tag.text())));
         return result;
     }
 
@@ -135,7 +135,7 @@
      * {@inheritDoc}
      */
     protected Content literalTagOutput(Tag tag) {
-        Content result = new StringContent(tag.text());
+        Content result = new StringContent(Util.normalizeNewlines(tag.text()));
         return result;
     }
 
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Wed Jul 17 10:40:53 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Wed Jul 17 18:18:45 2013 -0700
@@ -631,6 +631,32 @@
         return result.toString();
     }
 
+    public static String normalizeNewlines(String text) {
+        StringBuilder sb = new StringBuilder();
+        final int textLength = text.length();
+        final String NL = DocletConstants.NL;
+        int pos = 0;
+        for (int i = 0; i < textLength; i++) {
+            char ch = text.charAt(i);
+            switch (ch) {
+                case '\n':
+                    sb.append(text, pos, i);
+                    sb.append(NL);
+                    pos = i + 1;
+                    break;
+                case '\r':
+                    sb.append(text, pos, i);
+                    sb.append(NL);
+                    if (i + 1 < textLength && text.charAt(i + 1) == '\n')
+                        i++;
+                    pos = i + 1;
+                    break;
+            }
+        }
+        sb.append(text, pos, textLength);
+        return sb.toString();
+    }
+
     /**
      * The documentation for values() and valueOf() in Enums are set by the
      * doclet.
--- a/test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java	Wed Jul 17 10:40:53 2013 -0700
+++ b/test/com/sun/javadoc/testCRLineSeparator/TestCRLineSeparator.java	Wed Jul 17 18:18:45 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,7 @@
 public class TestCRLineSeparator extends JavadocTester {
 
     //Test information.
-    private static final String BUG_ID = "4979486";
+    private static final String BUG_ID = "4979486-8014636";
 
     //Javadoc arguments.
     private static final String[] ARGS = new String[] {
@@ -47,7 +47,7 @@
 
     //Input for string search tests.
     private static final String[][] TEST = {
-        {BUG_ID + FS + "pkg" + FS + "MyClass.html", "Line 1\n Line 2"}
+        {BUG_ID + FS + "pkg" + FS + "MyClass.html", "Line 1" + NL + " Line 2"}
     };
 
     private static final String[][] NEGATED_TEST = NO_TEST;
--- a/test/com/sun/javadoc/testLeadingSpaces/LeadingSpaces.java	Wed Jul 17 10:40:53 2013 -0700
+++ b/test/com/sun/javadoc/testLeadingSpaces/LeadingSpaces.java	Wed Jul 17 18:18:45 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,11 @@
 
 /*
  * @test
- * @bug 4232882
+ * @bug 4232882 8014636
  * @summary Javadoc strips all of the leading spaces when the comment
  *    does not begin with a star.  This RFE allows users to
  *    begin their comment without a leading star without leading
- *    spaces striped
+ *    spaces stripped
  * @author jamieh
  * @library ../lib/
  * @build JavadocTester
@@ -37,15 +37,15 @@
 
 public class LeadingSpaces extends JavadocTester {
 
-    private static final String BUG_ID = "4232882";
+    private static final String BUG_ID = "4232882-8014636";
     private static final String[][] TEST = {
         {BUG_ID + FS + "LeadingSpaces.html",
-"        1\n" +
-"          2\n" +
-"            3\n" +
-"              4\n" +
-"                5\n" +
-"                  6\n" +
+"        1" + NL +
+"          2" + NL +
+"            3" + NL +
+"              4" + NL +
+"                5" + NL +
+"                  6" + NL +
 "                    7"}
     };
     private static final String[][] NEGATED_TEST = NO_TEST;
--- a/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java	Wed Jul 17 10:40:53 2013 -0700
+++ b/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java	Wed Jul 17 18:18:45 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4732864 6280605 7064544
+ * @bug      4732864 6280605 7064544 8014636
  * @summary  Make sure that you can link from one member to another using
  *           non-qualified name, furthermore, ensure the right one is linked.
  * @author   jamieh
@@ -36,7 +36,7 @@
 public class TestLinkTaglet extends JavadocTester {
 
     //Test information.
-    private static final String BUG_ID = "4732864-6280605-7064544";
+    private static final String BUG_ID = "4732864-6280605-7064544-8014636";
 
     //Javadoc arguments.
     private static final String[] ARGS = new String[] {
@@ -46,16 +46,16 @@
     //Input for string search tests.
     private static final String[][] TEST = {
         {BUG_ID + FS + "pkg" + FS + "C.html",
-            "Qualified Link: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>\n" +
-            " Unqualified Link1: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>\n" +
-            " Unqualified Link2: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>\n" +
-            " Qualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(pkg.C.InnerC, pkg.C.InnerC2)</code></a>.<br/>\n" +
-            " Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(C.InnerC, C.InnerC2)</code></a>.<br/>\n" +
+            "Qualified Link: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>" + NL +
+            " Unqualified Link1: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>" + NL +
+            " Unqualified Link2: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>" + NL +
+            " Qualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(pkg.C.InnerC, pkg.C.InnerC2)</code></a>.<br/>" + NL +
+            " Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(C.InnerC, C.InnerC2)</code></a>.<br/>" + NL +
             " Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(InnerC, InnerC2)</code></a>.<br/>"
         },
         {BUG_ID + FS + "pkg" + FS + "C.InnerC.html",
-            "Link to member in outer class: <a href=\"../pkg/C.html#MEMBER\"><code>C.MEMBER</code></a> <br/>\n" +
-            " Link to member in inner class: <a href=\"../pkg/C.InnerC2.html#MEMBER2\"><code>C.InnerC2.MEMBER2</code></a> <br/>\n" +
+            "Link to member in outer class: <a href=\"../pkg/C.html#MEMBER\"><code>C.MEMBER</code></a> <br/>" + NL +
+            " Link to member in inner class: <a href=\"../pkg/C.InnerC2.html#MEMBER2\"><code>C.InnerC2.MEMBER2</code></a> <br/>" + NL +
             " Link to another inner class: <a href=\"../pkg/C.InnerC2.html\" title=\"class in pkg\"><code>C.InnerC2</code></a>"
         },
         {BUG_ID + FS + "pkg" + FS + "C.InnerC2.html",
--- a/test/com/sun/javadoc/testLiteralCodeInPre/TestLiteralCodeInPre.java	Wed Jul 17 10:40:53 2013 -0700
+++ b/test/com/sun/javadoc/testLiteralCodeInPre/TestLiteralCodeInPre.java	Wed Jul 17 18:18:45 2013 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      8002387
+ * @bug      8002387 8014636
  * @summary  Improve rendered HTML formatting for {@code}
  * @library  ../lib/
  * @build    JavadocTester TestLiteralCodeInPre
@@ -33,7 +33,7 @@
 public class TestLiteralCodeInPre extends JavadocTester {
 
     //Test information.
-    private static final String BUG_ID = "8002387";
+    private static final String BUG_ID = "8002387-8014636";
     private static final String OUTPUT_DIR = BUG_ID;
 
     //Javadoc arguments.
--- a/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java	Wed Jul 17 10:40:53 2013 -0700
+++ b/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java	Wed Jul 17 18:18:45 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,9 @@
 
 /*
  * @test
- * @bug      4460354
+ * @bug      4460354 8014636
  * @summary  Test to make sure that relative paths are redirected in the
  *           output so that they are not broken.
- *           NOTE: these tests have \\n instead of NL because they are user
- *           generated new lines, not Java generated.
  * @author   jamieh
  * @library  ../lib/
  * @build    JavadocTester
@@ -38,7 +36,7 @@
 public class TestRelativeLinks extends JavadocTester {
 
     //Test information.
-    private static final String BUG_ID = "4460354";
+    private static final String BUG_ID = "4460354-8014636";
 
     //Javadoc arguments.
     private static final String[] ARGS = new String[] {
@@ -58,7 +56,7 @@
         {BUG_ID + FS + "pkg" + FS + "package-summary.html",
             "<a href=\"relative-package-link.html\">relative package link</a>"},
         {BUG_ID + FS + "pkg" + FS + "C.html",
-            " <a\n" +
+            " <a" + NL +
             " href=\"relative-multi-line-link.html\">relative-multi-line-link</a>."},
 
         //These relative paths should be redirected because they are in different
@@ -74,7 +72,7 @@
         {BUG_ID + FS + "index-all.html",
             "<a href=\"./pkg/relative-package-link.html\">relative package link</a>"},
         {BUG_ID + FS + "index-all.html",
-            " <a\n" +
+            " <a" + NL +
             " href=\"./pkg/relative-multi-line-link.html\">relative-multi-line-link</a>."},
 
 
@@ -92,7 +90,7 @@
         {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "C.html",
             "<a href=\"../../pkg/relative-package-link.html\">relative package link</a>"},
         {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "C.html",
-            " <a\n" +
+            " <a" + NL +
             " href=\"../../pkg/relative-multi-line-link.html\">relative-multi-line-link</a>."},
 
         //PACKAGE OVERVIEW