Return-Path: Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 99813 invoked by uid 500); 30 Jun 2000 11:33:05 -0000 Delivered-To: apmail-jakarta-ant-cvs@apache.org Received: (qmail 99806 invoked by uid 1142); 30 Jun 2000 11:33:05 -0000 Date: 30 Jun 2000 11:33:05 -0000 Message-ID: <20000630113305.99805.qmail@locus.apache.org> From: conor@locus.apache.org To: jakarta-ant-cvs@apache.org Subject: cvs commit: jakarta-ant/src/main/org/apache/tools/ant PathTokenizer.java conor 00/06/30 04:33:05 Modified: src/main/org/apache/tools/ant PathTokenizer.java Log: Fixes from Stefan Revision Changes Path 1.2 +22 -24 jakarta-ant/src/main/org/apache/tools/ant/PathTokenizer.java Index: PathTokenizer.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/PathTokenizer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PathTokenizer.java 2000/06/29 15:32:37 1.1 +++ PathTokenizer.java 2000/06/30 11:33:03 1.2 @@ -70,12 +70,12 @@ /** * A tokenizer to break the string up based on the ':' or ';' separators. */ - StringTokenizer tokenizer; + private StringTokenizer tokenizer; /** * A String which stores any path components which have been read ahead. */ - String lookahead = null; + private String lookahead = null; public PathTokenizer(String path) { tokenizer = new StringTokenizer(path, ":;", false); @@ -90,35 +90,33 @@ } public String nextToken() throws NoSuchElementException { + String token = null; if (lookahead != null) { - String token = lookahead; + token = lookahead; lookahead = null; - - return token; } else { - String token = tokenizer.nextToken().trim(); - + token = tokenizer.nextToken().trim(); + } - if (token.length() == 1 && Character.isLetter(token.charAt(0)) - && File.pathSeparator.equals(";") - && tokenizer.hasMoreTokens()) { - // we are on a dos style system so this path could be a drive - // spec. We look at the next token - String nextToken = tokenizer.nextToken().trim(); - if (nextToken.startsWith("\\") || nextToken.startsWith("/")) { - // we know we are on a DOS style platform and the next path starts with a - // slash or backslash, so we know this is a drive spec - token += ":" + nextToken; - } - else { - // store the token just read for next time - lookahead = nextToken; - } + if (token.length() == 1 && Character.isLetter(token.charAt(0)) + && File.pathSeparator.equals(";") + && tokenizer.hasMoreTokens()) { + // we are on a dos style system so this path could be a drive + // spec. We look at the next token + String nextToken = tokenizer.nextToken().trim(); + if (nextToken.startsWith("\\") || nextToken.startsWith("/")) { + // we know we are on a DOS style platform and the next path starts with a + // slash or backslash, so we know this is a drive spec + token += ":" + nextToken; } - - return token; + else { + // store the token just read for next time + lookahead = nextToken; + } } + + return token; } }