diff options
| author | Steve Price <steve@FreeBSD.org> | 2000-05-14 19:54:04 +0000 |
|---|---|---|
| committer | Steve Price <steve@FreeBSD.org> | 2000-05-14 19:54:04 +0000 |
| commit | beb88613c3ae11f1db4ad88b02160f610653cda3 (patch) | |
| tree | 26fdef3caad90b71bfff7888d6849dafcfa5763c | |
| parent | 998b1e80fc2a39a01ba3030d36229ccbd86318b8 (diff) | |
Notes
| -rw-r--r-- | usr.sbin/pkg_install/delete/main.c | 31 | ||||
| -rw-r--r-- | usr.sbin/pkg_install/info/main.c | 38 |
2 files changed, 27 insertions, 42 deletions
diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c index 4a75d118a8ef..3150118a660c 100644 --- a/usr.sbin/pkg_install/delete/main.c +++ b/usr.sbin/pkg_install/delete/main.c @@ -87,24 +87,19 @@ main(int argc, char **argv) /* 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 */ diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c index c075dfb7d16d..8d1b451deec7 100644 --- a/usr.sbin/pkg_install/info/main.c +++ b/usr.sbin/pkg_install/info/main.c @@ -144,30 +144,20 @@ main(int argc, char **argv) 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 */ |
