Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/usr.sbin/pkg_install/lib Pull up revision 1.40 (request...



details:   https://anonhg.NetBSD.org/src/rev/9c7669a8e138
branches:  netbsd-1-6
changeset: 529537:9c7669a8e138
user:      tron <tron%NetBSD.org@localhost>
date:      Sun Nov 24 22:37:01 2002 +0000

description:
Pull up revision 1.40 (requested by jschauma in ticket #1011):
In addition to the existing "rc" modifier for a package version, add
support for "alpha" and "beta" versions, which sort before "rc".  Move
to table-based modifier recognition.

diffstat:

 usr.sbin/pkg_install/lib/str.c |  35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)

diffs (90 lines):

diff -r 926411f2806f -r 9c7669a8e138 usr.sbin/pkg_install/lib/str.c
--- a/usr.sbin/pkg_install/lib/str.c    Sun Nov 24 22:36:37 2002 +0000
+++ b/usr.sbin/pkg_install/lib/str.c    Sun Nov 24 22:37:01 2002 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: str.c,v 1.33.2.3 2002/07/23 11:03:21 lukem Exp $       */
+/*     $NetBSD: str.c,v 1.33.2.4 2002/11/24 22:37:01 tron Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "Id: str.c,v 1.5 1997/10/08 07:48:21 charnier Exp";
 #else
-__RCSID("$NetBSD: str.c,v 1.33.2.3 2002/07/23 11:03:21 lukem Exp $");
+__RCSID("$NetBSD: str.c,v 1.33.2.4 2002/11/24 22:37:01 tron Exp $");
 #endif
 #endif
 
@@ -106,6 +106,8 @@
 
 /* do not modify these values, or things will NOT work */
 enum {
+        Alpha = -3,
+        Beta = -2,
         RC = -1,
         Dot = 0,
         Patch = 1
@@ -146,6 +148,16 @@
         {      NULL,   0,      0       }
 };
 
+static const test_t    modifiers[] = {
+       {       "alpha",        5,      Alpha   },
+       {       "beta",         4,      Beta    },
+       {       "rc",           2,      RC      },
+       {       "pl",           2,      Dot     },
+       {       ".",            1,      Dot     },
+        {      NULL,           0,      0       }
+};
+
+
 
 /* locate the test in the tests array */
 static int
@@ -168,6 +180,8 @@
  * '.' encodes as Dot which is '0'
  * '_' encodes as 'patch level', or 'Dot', which is 0.
  * 'pl' encodes as 'patch level', or 'Dot', which is 0.
+ * 'alpha' encodes as 'alpha version', or Alpha, which is -3.
+ * 'beta' encodes as 'beta version', or Beta, which is -2.
  * 'rc' encodes as 'release candidate', or RC, which is -1.
  * 'nb' encodes as 'netbsd version', which is used after all other tests
  */
@@ -175,6 +189,7 @@
 mkcomponent(arr_t *ap, char *num)
 {
        static const char       alphas[] = "abcdefghijklmnopqrstuvwxyz";
+       const test_t           *modp;
        int64_t                 n;
        char                   *cp;
 
@@ -196,13 +211,11 @@
                ap->v[ap->c++] = n;
                return (int)(num - cp);
        }
-       if (strncasecmp(num, "rc", 2) == 0) {
-               ap->v[ap->c++] = RC;
-               return 2;
-       }
-       if (strncasecmp(num, "pl", 2) == 0) {
-               ap->v[ap->c++] = Dot;
-               return 2;
+       for (modp = modifiers ; modp->s ; modp++) {
+               if (strncasecmp(num, modp->s, modp->len) == 0) {
+                       ap->v[ap->c++] = modp->t;
+                       return modp->len;
+               }
        }
        if (strncasecmp(num, "nb", 2) == 0) {
                for (cp = num, num += 2, n = 0 ; isdigit(*num) ; num++) {
@@ -211,10 +224,6 @@
                ap->netbsd = n;
                return (int)(num - cp);
        }
-       if (*num == '.') {
-               ap->v[ap->c++] = Dot;
-               return 1;
-       }
        if (isalpha(*num)) {
                ap->v[ap->c++] = Dot;
                cp = strchr(alphas, tolower(*num));



Home | Main Index | Thread Index | Old Index