[Webfunds-commits] java/webfunds/utils VersionNumbers.java

Ian Grigg iang@cypherpunks.ai
Sun, 19 Nov 2000 06:21:23 -0400 (AST)


iang        00/11/19 06:21:22

  Modified:    webfunds/utils VersionNumbers.java
  Log:
  handle a.b.c. as well

Revision  Changes    Path
1.6       +14 -8     java/webfunds/utils/VersionNumbers.java

Index: VersionNumbers.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/utils/VersionNumbers.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- VersionNumbers.java	2000/10/07 01:17:05	1.5
+++ VersionNumbers.java	2000/11/19 10:21:22	1.6
@@ -1,5 +1,5 @@
 /*
- * $Id: VersionNumbers.java,v 1.5 2000/10/07 01:17:05 iang Exp $
+ * $Id: VersionNumbers.java,v 1.6 2000/11/19 10:21:22 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -120,7 +120,7 @@
 
             if (!pugDir.isDirectory())
                 continue ;
-logmsg(" dir " + product);
+//logmsg(" dir " + product);
 
             //
             //  There is a directory per version within each plugin.
@@ -172,13 +172,13 @@
         }
 
         int siz = victor.size();
-logmsg(" found " + siz + "!");
+//logmsg(" found " + siz + "!");
         String[] found = new String[siz];
         Enumeration e = victor.elements();
         for (int k = 0;  k < siz;  k++)
-{
+//{
             found[k] = (String)e.nextElement();
-logmsg("adding ... " + found[k]);}
+//logmsg("adding ... " + found[k]);}
         if (e.hasMoreElements())
             throw new RuntimeException("more elements in vector");
 
@@ -222,7 +222,10 @@
     }
 
     /**
-     * @return list of ints that correspond to this version
+     *  Looks for the first dash '-' and then looks for a triplet
+     *  of numbers after that, something like 1.2.3 or 3-2-1.
+     *
+     *  @return list of ints that correspond to this version
      */
     public static int[] getVersionsFromString(String versionString)
         throws NumberFormatException
@@ -234,7 +237,8 @@
 //logmsg("    len == " + len);
         while (i < len)
         {
-            if (versionString.regionMatches(i, "-", 0, 1))
+            if (versionString.regionMatches(i, "-", 0, 1) ||
+                versionString.regionMatches(i, ".", 0, 1))
             {
 //logmsg("    skipping dash");
                 i++;
@@ -242,7 +246,9 @@
                 continue ;
             }
 
-            int end = versionString.indexOf("-", i);
+            int end = versionString.indexOf("-", i);  // dash separated or dot
+            if (end < 0)
+                end = versionString.indexOf(".", i);  // might not work on M$
             if (end < 0)
                 end = len;
             String num = versionString.substring(i, end);