Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 May 2000 19:00:05 -0500 (CDT)
From:      Steve Price <sprice@hiwaay.net>
To:        jkh@freebsd.org
Cc:        current@freebsd.org
Subject:   'pkg_delete m4-1.1/' hangs
Message-ID:  <Pine.OSF.4.21.0005071850280.3613-100000@fly.HiWAAY.net>

next in thread | raw e-mail | index | archive | help
Jordan,

I've been experiencing a problem with 'pkg_delete m4-1.1/'
hanging.  Attached is a patch that fixes this problem, cleans
the code up a bit (IMHO), and still covers all the corner
cases like 'pkg_delete /var/db/pkg/m4-1.1//./..///' like the
old code did. :)

BTW, it appears pkg_info had a similar affliction so I fixed
it too while I was here.

-steve

Index: delete/main.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/delete/main.c,v
retrieving revision 1.17
diff -u -r1.17 main.c
--- delete/main.c	2000/02/18 07:00:01	1.17
+++ delete/main.c	2000/05/07 23:45:05
@@ -83,24 +83,19 @@
 
     /* Get all the remaining package names, if any */
     while (*argv) {
-        if ((pkgs_split = rindex(*argv, (int)'/')) != NULL) {
-            while (!isalpha(*(pkgs_split + 1))) {
-                *pkgs_split = '\0';
-                if ((pkgs_split = rindex(*argv, (int) '/')) == NULL)
-                    pkgs_split = *argv;
-            }
-            if (pkgs_split != NULL) {
-                if (*pkgs_split == '/')
-                    pkgs_split++;
-                *pkgs = pkgs_split;
-                pkgs++;
-            }
-        }
-        else {
-            *pkgs = *argv;
-            pkgs++;
-        }
-        argv++;
+	while ((pkgs_split = rindex(*argv, (int)'/')) != NULL) {
+	    *pkgs_split++ = '\0';
+	    /*
+	     * If character after the '/' is alphanumeric, then we've found the
+	     * package name.  Otherwise we've come across a trailing '/' and
+	     * need to continue our quest.
+	     */
+	    if (isalpha(*pkgs_split)) {
+		*argv = pkgs_split;
+		break;
+	    }
+	}
+	*pkgs++ = *argv++;
     }
 
     /* If no packages, yelp */
Index: info/main.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/main.c,v
retrieving revision 1.22
diff -u -r1.22 main.c
--- info/main.c	2000/01/18 01:45:54	1.22
+++ info/main.c	2000/05/07 23:46:31
@@ -144,30 +144,20 @@
 	Flags = SHOW_COMMENT | SHOW_DESC | SHOW_REQBY;
 
     /* Get all the remaining package names, if any */
-    while (*argv)
-    {
-        if( (pkgs_split = rindex(*argv, (int) '/')) != NULL )
-        {
-            while( !isalpha(*(pkgs_split+1)) )
-            {
-                *pkgs_split = '\0';
-                if ( (pkgs_split = rindex(*argv, (int) '/')) == NULL)
-                    pkgs_split = *argv;
-            }
-            if(pkgs_split != NULL)
-            {
-                if (*pkgs_split == '/')
-                    pkgs_split++;
-                *pkgs = pkgs_split;
-                pkgs++;
-            }
-        }
-        else
-        {
-            *pkgs = *argv;
-            pkgs++;
-        }
-        argv++;
+    while (*argv) {
+	while ((pkgs_split = rindex(*argv, (int)'/')) != NULL) {
+	    *pkgs_split++ = '\0';
+	    /*
+	     * If character after the '/' is alphanumeric, then we've found the
+	     * package name.  Otherwise we've come across a trailing '/' and
+	     * need to continue our quest.
+	     */
+	    if (isalpha(*pkgs_split)) {
+		*argv = pkgs_split;
+		break;
+	    }
+	}
+	*pkgs++ = *argv++;
     }
 
     /* If no packages, yelp */



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.OSF.4.21.0005071850280.3613-100000>