Subject: Re: pkg/23583: pkg_delete doesn't strip pathsep from the name of deleted package
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: David H.Gutteridge <dhgutteridge@sympatico.ca>
List: pkgsrc-bugs
Date: 05/29/2006 03:20:02
The following reply was made to PR pkg/23583; it has been noted by GNATS.

From: David H.Gutteridge <dhgutteridge@sympatico.ca>
To: <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: pkg/23583: pkg_delete doesn't strip pathsep from the name of deleted package
Date: Sun, 28 May 2006 21:56:02 -0400

 Concerning PR 23583, the fix for this bug seems trivial.  Revision 1.27 of
 main.c for pkg_delete added support for specifying directory names for
 packages, but it missed this particular usage scenario.
 
 This was PRed as a change request, but I'd term it a bug, given the intent
 noted above to support this functionality.  I got bit by it a couple of times
 before I got around to figuring it out.
 
 I've supplied a patch below, I hope it's satisfactory.  (It worked for me.)
 
 Regards,
 
 Dave
 
 --- main.c~	2006-05-28 19:44:44.000000000 -0400
 +++ main.c	2006-05-28 19:46:35.000000000 -0400
 @@ -172,9 +172,9 @@
  			dbdir = _pkgdb_getPKGDB_DIR();
  			if (**argv == '/' && strncmp(*argv, dbdir, strlen(dbdir)) == 0) {
  				*argv += strlen(dbdir) + 1;
 -				if ((*argv)[strlen(*argv) - 1] == '/') {
 -					(*argv)[strlen(*argv) - 1] = 0;
 -				}
 +			}
 +			if ((*argv)[strlen(*argv) - 1] == '/') {
 +				(*argv)[strlen(*argv) - 1] = 0;
  			}
  			lpp = alloc_lpkg(*argv);
  			TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);