Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 71036 invoked from network); 29 Aug 2006 01:52:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Aug 2006 01:52:11 -0000 Received: (qmail 59260 invoked by uid 500); 29 Aug 2006 01:52:10 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 58920 invoked by uid 500); 29 Aug 2006 01:52:09 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 58909 invoked by uid 500); 29 Aug 2006 01:52:09 -0000 Received: (qmail 58905 invoked by uid 99); 29 Aug 2006 01:52:09 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Aug 2006 18:52:09 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Aug 2006 18:52:08 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 752DB1A981A; Mon, 28 Aug 2006 18:51:48 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r437907 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java Date: Tue, 29 Aug 2006 01:51:48 -0000 To: ant-cvs@apache.org From: kevj@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060829015148.752DB1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: kevj Date: Mon Aug 28 18:51:47 2006 New Revision: 437907 URL: http://svn.apache.org/viewvc?rev=437907&view=rev Log: as requested a refactoring that doesn't use indexOf - test passes with 1.7.0Beta1 Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java?rev=437907&r1=437906&r2=437907&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java Mon Aug 28 18:51:47 2006 @@ -58,24 +58,36 @@ if (null == atLeast && null == exactly) { throw new BuildException("One of atleast or exactly must be set."); } + try { + if (atLeast != null) { + new DeweyDecimal(atLeast); + } else { + new DeweyDecimal(exactly); + } + } catch (NumberFormatException e) { + throw new BuildException("The argument is not a Dewey Decimal eg 1.1.0"); + } } - + private DeweyDecimal getVersion() { Project p = new Project(); p.init(); - String versionString = p.getProperty("ant.version"); - String v = versionString.substring(versionString.indexOf("Ant version")+12, - versionString.indexOf("Ant version")+17); - char[] cs = v.toCharArray(); - int end = cs.length; - for (int i = cs.length; i > 0; i--) { - if (!Character.isLetter(cs[i-1])) { - end = i; + char[] versionString = p.getProperty("ant.version").toCharArray(); + StringBuffer sb = new StringBuffer(); + boolean foundFirstDigit = false; + for (int i=0; i