From 1af1e04eefdc1cd751ef1286fb680420f6131d19 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Sun, 6 Feb 2000 19:28:54 +0000 Subject: [PATCH] Fixed javadoc so that it doesn't go into an infinite loop on lines such as: tmpExcludes.addElement("**/"+tok.nextToken().trim()+"/**"); (currently found in org.apache.tools.ant.taskdefs.Copydir) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267589 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/Javadoc.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index b44b17a8f..3241079e8 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -554,10 +554,11 @@ public class Javadoc extends Exec { } /** - * This is a java comment stripper reader that filters comments out - * for more significant java parsing. Since this class heavily relies on - * the single char read function, you are reccomended to make it work - * on top of a buffered reader. + * This is a java comment and string stripper reader that filters + * these lexical tokens out for purposes of simple Java parsing. + * (if you have more complex Java parsing needs, use a real lexer). + * Since this class heavily relies on the single char read function, + * you are reccomended to make it work on top of a buffered reader. */ class JavaReader extends FilterReader { @@ -569,19 +570,37 @@ public class Javadoc extends Exec { int c = in.read(); if (c == '/') { c = in.read(); - if (c == '*') { + if (c == '/') { + while (c != '\n') c = in.read(); + } else if (c == '*') { while (true) { c = in.read(); if (c == '*') { c = in.read(); if (c == '/') { - c = in.read(); + c = read(); break; } } } } } + if (c == '"') { + while (true) { + c = in.read(); + if (c == '\\') c = in.read(); + if (c == '"') { + c = read(); + break; + } + } + } + if (c == '\'') { + c = in.read(); + if (c == '\\') c = in.read(); + c = in.read(); + c = read(); + } return c; }