ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johan.granst...@itec.se (Johan Granstrom)
Subject Simple fix for the javadoc task in ant, related to comments in source files.
Date Tue, 13 Jun 2000 16:51:24 GMT
Note, I don't have diff on my PC and diff on nada.kth.se does not have the
-u option. Sorry.

Line 567++ in org.apache.tools.ant.taskdefs.Javadoc, inside the inner class
JavaReader, reads (see bottom for full read method):

                    while (c != -1) {
                        c = in.read();
                        if (c == '*') {
                            c = in.read();
                            if (c == '/') {
                                c = read();
                                break;
                            }
                        }
                    }

This will parse comments ending in an even number of stars and then a slash
incorrectly since the slash never will be seen. For example, in

/**
 * A comment.
 **/
some.code;

/* An other comment. */

the line some.code; will never be seen.
A simple fix is to replace the code with:
                    do {
                        if (c == '*') {
                            c = in.read();
                            if (c == '/') {
                                c = read();
                                break;
                            } else if (c == '*') {
                                continue;
                            }
                        }
                        c = in.read();
                    } while(c != -1);





The full read() method from
org.apache.tools.ant.taskdefs.Javadoc.JavaReader:

        public int read() throws IOException {
            int c = in.read();
            if (c == '/') {
                c = in.read();
                if (c == '/') {
                    while (c != '\n' && c != -1) c = in.read();
                } else if (c == '*') {
                    while (c != -1) {
                        c = in.read();
                        if (c == '*') {
                            c = in.read();
                            if (c == '/') {
                                c = read();
                                break;
                            }
                        }
                    }
                }
            }
            if (c == '"') {
                while (c != -1) {
                    c = in.read();
                    if (c == '\\') {
                        c = in.read();
                    } else if (c == '"') {
                        c = read();
                        break;
                    }
                }
            }
            if (c == '\'') {
                c = in.read();
                if (c == '\\') c = in.read();
                c = in.read();
                c = read();
            }
            return c;
        }

Regards,

 - Johan Georg Granström


Mime
View raw message