The following commit has been merged in the master branch:
commit 28007d02c3f60d762cdb943e8886267333f1c2a1
Author: Guillem Jover <[email protected]>
Date: Sun Oct 24 03:49:47 2010 +0200
Use new namevalue_find_by_name function instead of ad-hoc code
diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index c6bf15d..fdc9f74 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -40,17 +40,13 @@ convert_string(struct parsedb_state *ps, const char *what,
int otherwise,
const char **endpp)
{
const char *ep;
- const struct namevalue *nvip = ivip;
+ const struct namevalue *nvip;
if (!*startp)
parse_error(ps, pigp, _("%s is missing"), what);
- while (nvip->name) {
- if (strncasecmp(nvip->name, startp, nvip->length))
- nvip++;
- else
- break;
- }
- if (!nvip->name) {
+
+ nvip = namevalue_find_by_name(ivip, startp);
+ if (nvip == NULL) {
if (otherwise != -1) return otherwise;
parse_error(ps, pigp, _("`%.*s' is not allowed for %s"),
(int)strnlen(startp, 50), startp, what);
diff --git a/src/select.c b/src/select.c
index c9bcad4..51496a8 100644
--- a/src/select.c
+++ b/src/select.c
@@ -127,8 +127,10 @@ void setselections(const char *const *argv) {
varbufaddc(&selvb,0);
e = pkg_name_is_illegal(namevb.buf, NULL);
if (e) ohshit(_("illegal package name at line %d: %.250s"),lno,e);
- for (nvp=wantinfos; nvp->name && strcmp(nvp->name,selvb.buf); nvp++);
- if (!nvp->name) ohshit(_("unknown wanted status at line %d:
%.250s"),lno,selvb.buf);
+
+ nvp = namevalue_find_by_name(wantinfos, selvb.buf);
+ if (nvp == NULL)
+ ohshit(_("unknown wanted status at line %d: %.250s"), lno, selvb.buf);
pkg = pkg_db_find(namevb.buf);
pkg->want= nvp->value;
if (c == EOF) break;
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]