From owner-freebsd-current Sun May 7 17: 0:12 2000 Delivered-To: freebsd-current@freebsd.org Received: from mail.hiwaay.net (fly.HiWAAY.net [208.147.154.56]) by hub.freebsd.org (Postfix) with ESMTP id D850837B818; Sun, 7 May 2000 17:00:07 -0700 (PDT) (envelope-from sprice@hiwaay.net) Received: from localhost (sprice@localhost) by mail.hiwaay.net (8.10.1/8.10.1) with ESMTP id e48005717317; Sun, 7 May 2000 19:00:06 -0500 (CDT) Date: Sun, 7 May 2000 19:00:05 -0500 (CDT) From: Steve Price To: jkh@freebsd.org Cc: current@freebsd.org Subject: 'pkg_delete m4-1.1/' hangs Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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