diff options
author | Guillem Jover <guillem@debian.org> | 2014-05-23 07:01:32 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2014-05-23 07:01:32 +0200 |
commit | 07255ee8bfbef08b76f41842c63f9bd3f6dd9788 (patch) | |
tree | e97db7cf89147899efae8969b8448d495844f63e /src | |
parent | 25d6273c1ac34c2a63cb23358983fa2462a4f152 (diff) | |
download | dpkg-07255ee8bfbef08b76f41842c63f9bd3f6dd9788.tar.gz |
libdpkg: Refactor dpkg_options_parse_pkgname()
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 8 | ||||
-rw-r--r-- | src/packages.c | 8 | ||||
-rw-r--r-- | src/querycmd.c | 30 | ||||
-rw-r--r-- | src/verify.c | 11 |
4 files changed, 9 insertions, 48 deletions
diff --git a/src/main.c b/src/main.c index 7d1b77f09..82dd64d9f 100644 --- a/src/main.c +++ b/src/main.c @@ -48,7 +48,6 @@ #include <dpkg/arch.h> #include <dpkg/subproc.h> #include <dpkg/command.h> -#include <dpkg/pkg-spec.h> #include <dpkg/options.h> #include "main.h" @@ -370,14 +369,9 @@ set_ignore_depends(const struct cmdinfo *cip, const char *value) } p= copy; while (*p) { - struct dpkg_error err; struct pkginfo *pkg; - pkg = pkg_spec_parse_pkg(p, &err); - if (pkg == NULL) - badusage(_("--%s needs a valid package name but '%.250s' is not: %s"), - cip->olong, p, err.str); - + pkg = dpkg_options_parse_pkgname(cip, p); pkg_list_prepend(&ignoredependss, pkg); p+= strlen(p)+1; diff --git a/src/packages.c b/src/packages.c index 1485dae7c..829f22173 100644 --- a/src/packages.c +++ b/src/packages.c @@ -41,7 +41,6 @@ #include <dpkg/dpkg-db.h> #include <dpkg/pkg-list.h> #include <dpkg/pkg-queue.h> -#include <dpkg/pkg-spec.h> #include <dpkg/string.h> #include <dpkg/options.h> @@ -108,14 +107,9 @@ enqueue_specified(const char *const *argv) const char *thisarg; while ((thisarg = *argv++) != NULL) { - struct dpkg_error err; struct pkginfo *pkg; - pkg = pkg_spec_parse_pkg(thisarg, &err); - if (pkg == NULL) - badusage(_("--%s needs a valid package name but '%.250s' is not: %s"), - cipaction->olong, thisarg, err.str); - + pkg = dpkg_options_parse_pkgname(cipaction, thisarg); if (pkg->status == stat_notinstalled && str_match_end(pkg->set->name, DEBEXT)) { badusage(_("you must specify packages by their own names, " diff --git a/src/querycmd.c b/src/querycmd.c index 22bbdaf42..65c393bc3 100644 --- a/src/querycmd.c +++ b/src/querycmd.c @@ -4,7 +4,7 @@ * * Copyright © 1995,1996 Ian Jackson <ian@chiark.greenend.org.uk> * Copyright © 2000,2001 Wichert Akkerman <wakkerma@debian.org> - * Copyright © 2006-2012 Guillem Jover <guillem@debian.org> + * Copyright © 2006-2014 Guillem Jover <guillem@debian.org> * Copyright © 2011 Linaro Limited * Copyright © 2011 Raphaël Hertzog <hertzog@debian.org> * @@ -456,12 +456,7 @@ enqperpackage(const char *const *argv) modstatdb_open(msdbrw_readonly); while ((thisarg = *argv++) != NULL) { - struct dpkg_error err; - - pkg = pkg_spec_parse_pkg(thisarg, &err); - if (pkg == NULL) - badusage(_("--%s needs a valid package name but '%.250s' is not: %s"), - cipaction->olong, thisarg, err.str); + pkg = dpkg_options_parse_pkgname(cipaction, thisarg); switch (cipaction->arg_int) { case act_status: @@ -684,7 +679,6 @@ control_path_file(struct pkginfo *pkg, const char *control_file) static int control_path(const char *const *argv) { - struct dpkg_error err; struct pkginfo *pkg; const char *pkgname; const char *control_file; @@ -703,11 +697,7 @@ control_path(const char *const *argv) modstatdb_open(msdbrw_readonly); - pkg = pkg_spec_parse_pkg(pkgname, &err); - if (pkg == NULL) - badusage(_("--%s needs a valid package name but '%.250s' is not: %s"), - cipaction->olong, pkgname, err.str); - + pkg = dpkg_options_parse_pkgname(cipaction, pkgname); if (pkg->status == stat_notinstalled) ohshit(_("package '%s' is not installed"), pkg_name(pkg, pnaw_nonambig)); @@ -725,7 +715,6 @@ control_path(const char *const *argv) static int control_list(const char *const *argv) { - struct dpkg_error err; struct pkginfo *pkg; const char *pkgname; @@ -735,11 +724,7 @@ control_list(const char *const *argv) modstatdb_open(msdbrw_readonly); - pkg = pkg_spec_parse_pkg(pkgname, &err); - if (pkg == NULL) - badusage(_("--%s needs a valid package name but '%.250s' is not: %s"), - cipaction->olong, pkgname, err.str); - + pkg = dpkg_options_parse_pkgname(cipaction, pkgname); if (pkg->status == stat_notinstalled) ohshit(_("package '%s' is not installed"), pkg_name(pkg, pnaw_nonambig)); @@ -753,7 +738,6 @@ control_list(const char *const *argv) static int control_show(const char *const *argv) { - struct dpkg_error err; struct pkginfo *pkg; const char *pkgname; const char *filename; @@ -772,11 +756,7 @@ control_show(const char *const *argv) modstatdb_open(msdbrw_readonly); - pkg = pkg_spec_parse_pkg(pkgname, &err); - if (pkg == NULL) - badusage(_("--%s needs a valid package name but '%.250s' is not: %s"), - cipaction->olong, pkgname, err.str); - + pkg = dpkg_options_parse_pkgname(cipaction, pkgname); if (pkg->status == stat_notinstalled) ohshit(_("package '%s' is not installed"), pkg_name(pkg, pnaw_nonambig)); diff --git a/src/verify.c b/src/verify.c index d9dcc7f16..1ce17154a 100644 --- a/src/verify.c +++ b/src/verify.c @@ -2,7 +2,7 @@ * dpkg - main program for package management * verify.c - verify package integrity * - * Copyright © 2012 Guillem Jover <guillem@debian.org> + * Copyright © 2012-2014 Guillem Jover <guillem@debian.org> * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +28,6 @@ #include <dpkg/i18n.h> #include <dpkg/dpkg.h> #include <dpkg/dpkg-db.h> -#include <dpkg/pkg-spec.h> #include <dpkg/options.h> #include "filesdb.h" @@ -150,13 +149,7 @@ verify(const char *const *argv) const char *thisarg; while ((thisarg = *argv++)) { - struct dpkg_error err; - - pkg = pkg_spec_parse_pkg(thisarg, &err); - if (pkg == NULL) - badusage(_("--%s needs a valid package name but '%.250s' is not: %s"), - cipaction->olong, thisarg, err.str); - + pkg = dpkg_options_parse_pkgname(cipaction, thisarg); if (pkg->status == stat_notinstalled) { notice(_("package '%s' is not installed"), pkg_name(pkg, pnaw_nonambig)); |