From 06647a4f761e1169b7e3502e9fdeb8ad5d40babd Mon Sep 17 00:00:00 2001 From: Dan Moschuk Date: Sat, 15 Jan 2000 01:15:37 +0000 Subject: [PATCH] Teach pkg_delete and pkg_info how to deal with full pathnames (/var/db/pkg/foo-1.0, instead of just foo-1.0). Submitted by: Matthew D. Fuller --- usr.sbin/pkg_install/delete/main.c | 25 +++++++++++++++++++++++-- usr.sbin/pkg_install/info/main.c | 24 +++++++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c index 6956f7048e41..7567286caa31 100644 --- a/usr.sbin/pkg_install/delete/main.c +++ b/usr.sbin/pkg_install/delete/main.c @@ -41,6 +41,7 @@ main(int argc, char **argv) { int ch, error; char **pkgs, **start; + char *pkgs_split; pkgs = start = argv; while ((ch = getopt(argc, argv, Options)) != -1) @@ -80,10 +81,30 @@ main(int argc, char **argv) argc -= optind; argv += optind; - /* Get all the remaining package names, if any */ /* Get all the remaining package names, if any */ while (*argv) - *pkgs++ = *argv++; + { + if( (pkgs_split = rindex(*argv, (int) '/')) != NULL ) + { + while( !isalpha(*(pkgs_split+1)) ) + { + *pkgs_split = '\0'; + pkgs_split = rindex(*argv, (int) '/'); + } + if(pkgs_split != NULL) + { + pkgs_split++; + *pkgs = pkgs_split; + pkgs++; + } + } + else + { + *pkgs = *argv; + pkgs++; + } + argv++; + } /* If no packages, yelp */ if (pkgs == start) diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c index 83f6ef4e0b29..9a8a3dbf48cb 100644 --- a/usr.sbin/pkg_install/info/main.c +++ b/usr.sbin/pkg_install/info/main.c @@ -44,6 +44,7 @@ main(int argc, char **argv) { int ch; char **pkgs, **start; + char *pkgs_split; pkgs = start = argv; if (argc == 1) { @@ -144,7 +145,28 @@ main(int argc, char **argv) /* Get all the remaining package names, if any */ while (*argv) - *pkgs++ = *argv++; + { + if( (pkgs_split = rindex(*argv, (int) '/')) != NULL ) + { + while( !isalpha(*(pkgs_split+1)) ) + { + *pkgs_split = '\0'; + pkgs_split = rindex(*argv, (int) '/'); + } + if(pkgs_split != NULL) + { + pkgs_split++; + *pkgs = pkgs_split; + pkgs++; + } + } + else + { + *pkgs = *argv; + pkgs++; + } + argv++; + } /* If no packages, yelp */ if (pkgs == start && !AllInstalled && !CheckPkg)