The following commit has been merged in the master branch:
commit 926a204c1609d35de3a6500f8e96c9db0c315de4
Author: Guillem Jover <guil...@debian.org>
Date:   Thu Jul 14 03:58:45 2011 +0200

    libdpkg: Add pkg and pkgbin to struct parsedb_state
    
    We are passing these variables as arguments most of the time for
    parse_error() and parse_warn() calls which are not run-time frequent,
    this also unties somewhat the code from the package structures.

diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index b56dc1e..124d2d4 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -34,7 +34,7 @@
 #include <dpkg/triglib.h>
 
 static int
-parse_nv_next(struct parsedb_state *ps, const struct pkginfo *pigp,
+parse_nv_next(struct parsedb_state *ps,
               const char *what, const struct namevalue *nv_head,
               const char **strp)
 {
@@ -42,11 +42,11 @@ parse_nv_next(struct parsedb_state *ps, const struct 
pkginfo *pigp,
   const struct namevalue *nv;
 
   if (str_start[0] == '\0')
-    parse_error(ps, pigp, _("%s is missing"), what);
+    parse_error(ps, _("%s is missing"), what);
 
   nv = namevalue_find_by_name(nv_head, str_start);
   if (nv == NULL)
-    parse_error(ps, pigp, _("'%.50s' is not allowed for %s"), str_start, what);
+    parse_error(ps, _("'%.50s' is not allowed for %s"), str_start, what);
 
   /* We got the fallback value, skip further string validation. */
   if (nv->length == 0) {
@@ -62,15 +62,15 @@ parse_nv_next(struct parsedb_state *ps, const struct 
pkginfo *pigp,
 }
 
 static int
-parse_nv_last(struct parsedb_state *ps, const struct pkginfo *pkg,
+parse_nv_last(struct parsedb_state *ps,
               const char *what, const struct namevalue *nv_head,
               const char *str)
 {
   int value;
 
-  value = parse_nv_next(ps, pkg, what, nv_head, &str);
+  value = parse_nv_next(ps, what, nv_head, &str);
   if (str != NULL && str[0] != '\0')
-    parse_error(ps, pkg, _("junk after %s"), what);
+    parse_error(ps, _("junk after %s"), what);
 
   return value;
 }
@@ -84,7 +84,7 @@ f_name(struct pkginfo *pigp, struct pkgbin *pifp,
 
   e = pkg_name_is_illegal(value, NULL);
   if (e != NULL)
-    parse_error(ps, pigp, _("invalid package name (%.250s)"), e);
+    parse_error(ps, _("invalid package name (%.250s)"), e);
   /* We use the new name, as pkg_db_find() may have done a tolower for us. */
   pigp->name = pkg_db_find(value)->name;
 }
@@ -99,9 +99,9 @@ f_filecharf(struct pkginfo *pigp, struct pkgbin *pifp,
   int allowextend;
 
   if (!*value)
-    parse_error(ps, pigp, _("empty file details field `%s'"), fip->name);
+    parse_error(ps, _("empty file details field `%s'"), fip->name);
   if (!(ps->flags & pdb_recordavailable))
-    parse_error(ps, pigp,
+    parse_error(ps,
                 _("file details field `%s' not allowed in status file"),
                fip->name);
   allowextend= !pigp->files;
@@ -114,7 +114,7 @@ f_filecharf(struct pkginfo *pigp, struct pkgbin *pifp,
     fdp= *fdpp;
     if (!fdp) {
       if (!allowextend)
-        parse_error(ps, pigp,
+        parse_error(ps,
                     _("too many values in file details field `%s' "
                       "(compared to others)"), fip->name);
       fdp= nfmalloc(sizeof(struct filedetails));
@@ -128,7 +128,7 @@ f_filecharf(struct pkginfo *pigp, struct pkgbin *pifp,
     cpos= space;
   }
   if (*fdpp)
-    parse_error(ps, pigp,
+    parse_error(ps,
                 _("too few values in file details field `%s' "
                   "(compared to others)"), fip->name);
 }
@@ -151,7 +151,7 @@ f_boolean(struct pkginfo *pigp, struct pkgbin *pifp,
   if (!*value)
     return;
 
-  boolean = parse_nv_last(ps, pigp, _("yes/no in boolean field"),
+  boolean = parse_nv_last(ps, _("yes/no in boolean field"),
                           booleaninfos, value);
   PKGPFIELD(pifp, fip->integer, bool) = boolean;
 }
@@ -171,7 +171,7 @@ f_priority(struct pkginfo *pigp, struct pkgbin *pifp,
            const char *value, const struct fieldinfo *fip)
 {
   if (!*value) return;
-  pigp->priority = parse_nv_last(ps, pigp, _("word in `priority' field"),
+  pigp->priority = parse_nv_last(ps, _("word in `priority' field"),
                                  priorityinfos, value);
   if (pigp->priority == pri_other) pigp->otherpriority= nfstrsave(value);
 }
@@ -182,18 +182,18 @@ f_status(struct pkginfo *pigp, struct pkgbin *pifp,
          const char *value, const struct fieldinfo *fip)
 {
   if (ps->flags & pdb_rejectstatus)
-    parse_error(ps, pigp,
+    parse_error(ps,
                 _("value for `status' field not allowed in this context"));
   if (ps->flags & pdb_recordavailable)
     return;
 
-  pigp->want = parse_nv_next(ps, pigp,
+  pigp->want = parse_nv_next(ps,
                              _("first (want) word in `status' field"),
                              wantinfos, &value);
-  pigp->eflag = parse_nv_next(ps, pigp,
+  pigp->eflag = parse_nv_next(ps,
                               _("second (error) word in `status' field"),
                               eflaginfos, &value);
-  pigp->status = parse_nv_last(ps, pigp,
+  pigp->status = parse_nv_last(ps,
                                _("third (status) word in `status' field"),
                                statusinfos, value);
 }
@@ -203,7 +203,7 @@ f_version(struct pkginfo *pigp, struct pkgbin *pifp,
           struct parsedb_state *ps,
           const char *value, const struct fieldinfo *fip)
 {
-  parse_db_version(ps, pigp, &pifp->version, value,
+  parse_db_version(ps, &pifp->version, value,
                    _("error in Version string '%.250s'"), value);
 }
 
@@ -214,7 +214,7 @@ f_revision(struct pkginfo *pigp, struct pkgbin *pifp,
 {
   char *newversion;
 
-  parse_warn(ps, pigp,
+  parse_warn(ps,
              _("obsolete `Revision' or `Package-Revision' field used"));
   if (!*value) return;
   if (pifp->version.revision && *pifp->version.revision) {
@@ -231,12 +231,12 @@ f_configversion(struct pkginfo *pigp, struct pkgbin *pifp,
                 const char *value, const struct fieldinfo *fip)
 {
   if (ps->flags & pdb_rejectstatus)
-    parse_error(ps, pigp,
+    parse_error(ps,
                 _("value for `config-version' field not allowed in this 
context"));
   if (ps->flags & pdb_recordavailable)
     return;
 
-  parse_db_version(ps, pigp, &pigp->configversion, value,
+  parse_db_version(ps, &pigp->configversion, value,
                    _("error in Config-Version string '%.250s'"), value);
 
 }
@@ -248,8 +248,7 @@ static void conffvalue_lastword(const char *value, const 
char *from,
                                 const char *endent,
                                 const char **word_start_r, int *word_len_r,
                                 const char **new_from_r,
-                                struct parsedb_state *ps,
-                                struct pkginfo *pigp)
+                                struct parsedb_state *ps)
 {
   const char *lastspc;
 
@@ -263,7 +262,7 @@ static void conffvalue_lastword(const char *value, const 
char *from,
   return;
 
 malformed:
-  parse_error(ps, pigp,
+  parse_error(ps,
               _("value for `conffiles' has malformatted line `%.*s'"),
               (int)min(endent - value, 250), value);
 }
@@ -284,24 +283,24 @@ f_conffiles(struct pkginfo *pigp, struct pkgbin *pifp,
     c= *value++;
     if (c == '\n') continue;
     if (c != ' ')
-      parse_error(ps, pigp,
+      parse_error(ps,
                   _("value for `conffiles' has line starting with non-space 
`%c'"),
                   c);
     for (endent = value; (c = *endent) != '\0' && c != '\n'; endent++) ;
     conffvalue_lastword(value, endent, endent,
                        &hashstart, &hashlen, &endfn,
-                        ps, pigp);
+                        ps);
     obsolete= (hashlen == sizeof(obsolete_str)-1 &&
               !memcmp(hashstart, obsolete_str, hashlen));
     if (obsolete)
       conffvalue_lastword(value, endfn, endent,
                          &hashstart, &hashlen, &endfn,
-                         ps, pigp);
+                         ps);
     newlink= nfmalloc(sizeof(struct conffile));
     value = path_skip_slash_dotslash(value);
     namelen= (int)(endfn-value);
     if (namelen <= 0)
-      parse_error(ps, pigp,
+      parse_error(ps,
                   _("root or null directory is listed as a conffile"));
     newptr = nfmalloc(namelen+2);
     newptr[0]= '/';
@@ -362,12 +361,12 @@ f_dependency(struct pkginfo *pigp, struct pkgbin *pifp,
       varbuf_add_buf(&depname, depnamestart, depnamelength);
       varbuf_end_str(&depname);
       if (!depname.buf[0])
-        parse_error(ps, pigp,
+        parse_error(ps,
                     _("`%s' field, missing package name, or garbage where "
                       "package name expected"), fip->name);
       emsg = pkg_name_is_illegal(depname.buf, NULL);
       if (emsg)
-        parse_error(ps, pigp,
+        parse_error(ps,
                     _("`%s' field, invalid package name `%.255s': %s"),
                     fip->name, depname.buf, emsg);
       dop= nfmalloc(sizeof(struct deppossi));
@@ -403,13 +402,13 @@ f_dependency(struct pkginfo *pigp, struct pkgbin *pifp,
             dop->verrel |= (dvrf_strict | dvrf_builtup);
             p++;
           } else if (c2 == '<' || c2 == '>') {
-            parse_error(ps, pigp,
+            parse_error(ps,
                         _("`%s' field, reference to `%.255s':\n"
                           " bad version relationship %c%c"),
                         fip->name, depname.buf, c1, c2);
             dop->verrel= dvr_none;
           } else {
-            parse_warn(ps, pigp,
+            parse_warn(ps,
                        _("`%s' field, reference to `%.255s':\n"
                          " `%c' is obsolete, use `%c=' or `%c%c' instead"),
                        fip->name, depname.buf, c1, c1, c1, c1);
@@ -419,7 +418,7 @@ f_dependency(struct pkginfo *pigp, struct pkgbin *pifp,
           dop->verrel= dvr_exact;
           p++;
         } else {
-          parse_warn(ps, pigp,
+          parse_warn(ps,
                      _("`%s' field, reference to `%.255s':\n"
                        " implicit exact match on version number, "
                        "suggest using `=' instead"),
@@ -427,11 +426,11 @@ f_dependency(struct pkginfo *pigp, struct pkgbin *pifp,
           dop->verrel= dvr_exact;
         }
        if ((dop->verrel!=dvr_exact) && (fip->integer==dep_provides))
-          parse_warn(ps, pigp,
+          parse_warn(ps,
                      _("Only exact versions may be used for Provides"));
 
         if (!isspace(*p) && !isalnum(*p)) {
-          parse_warn(ps, pigp,
+          parse_warn(ps,
                      _("`%s' field, reference to `%.255s':\n"
                        " version value starts with non-alphanumeric, "
                        "suggest adding a space"),
@@ -448,21 +447,21 @@ f_dependency(struct pkginfo *pigp, struct pkgbin *pifp,
        versionlength= p - versionstart;
         while (isspace(*p)) p++;
         if (*p == '(')
-          parse_error(ps, pigp,
+          parse_error(ps,
                       _("`%s' field, reference to `%.255s': "
                         "version contains `%c'"), fip->name, depname.buf, ')');
         else if (*p != ')')
-          parse_error(ps, pigp,
+          parse_error(ps,
                       _("`%s' field, reference to `%.255s': "
                         "version contains `%c'"), fip->name, depname.buf, ' ');
         else if (*p == '\0')
-          parse_error(ps, pigp,
+          parse_error(ps,
                       _("`%s' field, reference to `%.255s': "
                         "version unterminated"), fip->name, depname.buf);
         varbuf_reset(&version);
         varbuf_add_buf(&version, versionstart, versionlength);
         varbuf_end_str(&version);
-        parse_db_version(ps, pigp, &dop->version, version.buf,
+        parse_db_version(ps, &dop->version, version.buf,
                          _("'%s' field, reference to '%.255s': "
                            "error in version"), fip->name, depname.buf);
         p++; while (isspace(*p)) p++;
@@ -472,14 +471,14 @@ f_dependency(struct pkginfo *pigp, struct pkgbin *pifp,
       }
       if (!*p || *p == ',') break;
       if (*p != '|')
-        parse_error(ps, pigp,
+        parse_error(ps,
                     _("`%s' field, syntax error after reference to package 
`%.255s'"),
                     fip->name, dop->ed->name);
       if (fip->integer == dep_conflicts ||
           fip->integer == dep_breaks ||
           fip->integer == dep_provides ||
           fip->integer == dep_replaces)
-        parse_error(ps, pigp,
+        parse_error(ps,
                     _("alternatives (`|') not allowed in %s field"), 
fip->name);
       p++; while (isspace(*p)) p++;
     }
@@ -533,18 +532,18 @@ f_trigpend(struct pkginfo *pend, struct pkgbin *pifp,
   const char *word, *emsg;
 
   if (ps->flags & pdb_rejectstatus)
-    parse_error(ps, pend,
+    parse_error(ps,
                 _("value for `triggers-pending' field not allowed in "
                   "this context"));
 
   while ((word = scan_word(&value))) {
     emsg = trig_name_is_illegal(word);
     if (emsg)
-      parse_error(ps, pend,
+      parse_error(ps,
                   _("illegal pending trigger name `%.255s': %s"), word, emsg);
 
     if (!trig_note_pend_core(pend, nfstrsave(word)))
-      parse_error(ps, pend,
+      parse_error(ps,
                   _("duplicate pending trigger `%.255s'"), word);
   }
 }
@@ -558,20 +557,20 @@ f_trigaw(struct pkginfo *aw, struct pkgbin *pifp,
   struct pkginfo *pend;
 
   if (ps->flags & pdb_rejectstatus)
-    parse_error(ps, aw,
+    parse_error(ps,
                 _("value for `triggers-awaited' field not allowed in "
                   "this context"));
 
   while ((word = scan_word(&value))) {
     emsg = pkg_name_is_illegal(word, NULL);
     if (emsg)
-      parse_error(ps, aw,
+      parse_error(ps,
                   _("illegal package name in awaited trigger `%.255s': %s"),
                   word, emsg);
     pend = pkg_db_find(word);
 
     if (!trig_note_aw(pend, aw))
-      parse_error(ps, aw,
+      parse_error(ps,
                   _("duplicate awaited trigger package `%.255s'"), word);
 
     trig_enqueue_awaited_pend(pend);
diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index 898f996..3b32572 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -127,7 +127,7 @@ pkg_parse_field(struct parsedb_state *ps, struct 
field_state *fs,
       break;
   if (fip->name) {
     if ((*ip)++)
-      parse_error(ps, pkg,
+      parse_error(ps,
                   _("duplicate value for `%s' field"), fip->name);
 
     varbuf_reset(&fs->value);
@@ -139,13 +139,13 @@ pkg_parse_field(struct parsedb_state *ps, struct 
field_state *fs,
     struct arbitraryfield *arp, **larpp;
 
     if (fs->fieldlen < 2)
-      parse_error(ps, pkg,
+      parse_error(ps,
                   _("user-defined field name `%.*s' too short"),
                   fs->fieldlen, fs->fieldstart);
     larpp = &pkgbin->arbs;
     while ((arp = *larpp) != NULL) {
       if (!strncasecmp(arp->name, fs->fieldstart, fs->fieldlen))
-        parse_error(ps, pkg,
+        parse_error(ps,
                    _("duplicate value for user-defined field `%.*s'"),
                    fs->fieldlen, fs->fieldstart);
       larpp = &arp->next;
@@ -165,7 +165,7 @@ static void
 pkg_parse_verify(struct parsedb_state *ps,
                  struct pkginfo *pkg, struct pkgbin *pkgbin)
 {
-  parse_must_have_field(ps, pkg, pkg->name, "package name");
+  parse_must_have_field(ps, pkg->name, "package name");
 
   /* XXX: We need to check for status != stat_halfinstalled as while
    * unpacking an unselected package, it will not have yet all data in
@@ -174,9 +174,9 @@ pkg_parse_verify(struct parsedb_state *ps,
   if ((ps->flags & pdb_recordavailable) ||
       (pkg->status != stat_notinstalled &&
        pkg->status != stat_halfinstalled)) {
-    parse_ensure_have_field(ps, pkg, &pkgbin->description, "description");
-    parse_ensure_have_field(ps, pkg, &pkgbin->maintainer, "maintainer");
-    parse_must_have_field(ps, pkg, pkgbin->version.version, "version");
+    parse_ensure_have_field(ps, &pkgbin->description, "description");
+    parse_ensure_have_field(ps, &pkgbin->maintainer, "maintainer");
+    parse_must_have_field(ps, pkgbin->version.version, "version");
   }
 
   /* XXX: Versions before dpkg 1.10.19 did not preserve the Architecture
@@ -187,7 +187,7 @@ pkg_parse_verify(struct parsedb_state *ps,
     /* We always want usable architecture information (as long as the package
      * is in such a state that it make sense), so that it can be used safely
      * on string comparisons and the like. */
-    parse_ensure_have_field(ps, pkg, &pkgbin->arch, "architecture");
+    parse_ensure_have_field(ps, &pkgbin->arch, "architecture");
   } else if (pkgbin->arch == NULL) {
     pkgbin->arch = "";
   }
@@ -200,7 +200,7 @@ pkg_parse_verify(struct parsedb_state *ps,
   if (!(ps->flags & pdb_recordavailable)) {
     if (pkg->configversion.version) {
       if (pkg->status == stat_installed || pkg->status == stat_notinstalled)
-        parse_error(ps, pkg,
+        parse_error(ps,
                     _("Configured-Version for package with inappropriate 
Status"));
     } else {
       if (pkg->status == stat_installed)
@@ -211,21 +211,21 @@ pkg_parse_verify(struct parsedb_state *ps,
   if (pkg->trigaw.head &&
       (pkg->status <= stat_configfiles ||
        pkg->status >= stat_triggerspending))
-    parse_error(ps, pkg,
+    parse_error(ps,
                 _("package has status %s but triggers are awaited"),
                 statusinfos[pkg->status].name);
   else if (pkg->status == stat_triggersawaited && !pkg->trigaw.head)
-    parse_error(ps, pkg,
+    parse_error(ps,
                 _("package has status triggers-awaited but no triggers 
awaited"));
 
   if (pkg->trigpend_head &&
       !(pkg->status == stat_triggerspending ||
         pkg->status == stat_triggersawaited))
-    parse_error(ps, pkg,
+    parse_error(ps,
                 _("package has status %s but triggers are pending"),
                 statusinfos[pkg->status].name);
   else if (pkg->status == stat_triggerspending && !pkg->trigpend_head)
-    parse_error(ps, pkg,
+    parse_error(ps,
                 _("package has status triggers-pending but no triggers "
                   "pending"));
 
@@ -235,7 +235,7 @@ pkg_parse_verify(struct parsedb_state *ps,
   if (!(ps->flags & pdb_recordavailable) &&
       pkg->status == stat_notinstalled &&
       pkgbin->conffiles) {
-    parse_warn(ps, pkg,
+    parse_warn(ps,
                _("Package which in state not-installed has conffiles, "
                  "forgetting them"));
     pkgbin->conffiles = NULL;
@@ -342,6 +342,9 @@ int parsedb(const char *filename, enum parsedbflags flags,
   else
     new_pkgbin = &new_pkg->installed;
 
+  ps.pkg = new_pkg;
+  ps.pkgbin = new_pkgbin;
+
   fd= open(filename, O_RDONLY);
   if (fd == -1) ohshite(_("failed to open package info file `%.255s' for 
reading"),filename);
 
@@ -396,17 +399,17 @@ int parsedb(const char *filename, enum parsedbflags flags,
       fs.fieldlen = dataptr - fs.fieldstart - 1;
       while (!EOF_mmap(dataptr, endptr) && c != '\n' && isspace(c)) c= 
getc_mmap(dataptr);
       if (EOF_mmap(dataptr, endptr))
-        parse_error(&ps, new_pkg,
+        parse_error(&ps,
                     _("EOF after field name `%.*s'"), fs.fieldlen, 
fs.fieldstart);
       if (c == '\n')
-        parse_error(&ps, new_pkg,
+        parse_error(&ps,
                     _("newline in field name `%.*s'"), fs.fieldlen, 
fs.fieldstart);
       if (c == MSDOS_EOF_CHAR)
-        parse_error(&ps, new_pkg,
+        parse_error(&ps,
                     _("MSDOS EOF (^Z) in field name `%.*s'"),
                     fs.fieldlen, fs.fieldstart);
       if (c != ':')
-        parse_error(&ps, new_pkg,
+        parse_error(&ps,
                     _("field name `%.*s' must be followed by colon"),
                     fs.fieldlen, fs.fieldstart);
       /* Skip space after ‘:’ but before value and EOL. */
@@ -415,11 +418,11 @@ int parsedb(const char *filename, enum parsedbflags flags,
         if (c == '\n' || !isspace(c)) break;
       }
       if (EOF_mmap(dataptr, endptr))
-        parse_error(&ps, new_pkg,
+        parse_error(&ps,
                     _("EOF before value of field `%.*s' (missing final 
newline)"),
                     fs.fieldlen, fs.fieldstart);
       if (c == MSDOS_EOF_CHAR)
-        parse_error(&ps, new_pkg,
+        parse_error(&ps,
                     _("MSDOS EOF char in value of field `%.*s' (missing 
newline?)"),
                     fs.fieldlen, fs.fieldstart);
 
@@ -429,7 +432,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
       for (;;) {
         if (c == '\n' || c == MSDOS_EOF_CHAR) {
           if (blank_line)
-            parse_error(&ps, new_pkg,
+            parse_error(&ps,
                         _("blank line in value of field '%.*s'"),
                         fs.fieldlen, fs.fieldstart);
           ps.lno++;
@@ -445,7 +448,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
         }
 
         if (EOF_mmap(dataptr, endptr))
-          parse_error(&ps, new_pkg,
+          parse_error(&ps,
                       _("EOF during value of field `%.*s' (missing final 
newline)"),
                       fs.fieldlen, fs.fieldstart);
 
@@ -462,7 +465,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
     } /* Loop per field. */
 
     if (pdone && donep)
-      parse_error(&ps, new_pkg,
+      parse_error(&ps,
                   _("several package info entries found, only one allowed"));
 
     pkg_parse_verify(&ps, new_pkg, new_pkgbin);
diff --git a/lib/dpkg/parsedump.h b/lib/dpkg/parsedump.h
index 3ac9adb..bf8759e 100644
--- a/lib/dpkg/parsedump.h
+++ b/lib/dpkg/parsedump.h
@@ -26,6 +26,8 @@ struct fieldinfo;
 
 struct parsedb_state {
        enum parsedbflags flags;
+       struct pkginfo *pkg;
+       struct pkgbin *pkgbin;
        const char *filename;
        int lno;
 };
@@ -64,19 +66,17 @@ struct fieldinfo {
   size_t integer;
 };
 
-void parse_db_version(struct parsedb_state *ps, const struct pkginfo *pkg,
+void parse_db_version(struct parsedb_state *ps,
                       struct versionrevision *version, const char *value,
-                      const char *fmt, ...) DPKG_ATTR_PRINTF(5);
+                      const char *fmt, ...) DPKG_ATTR_PRINTF(4);
 
-void parse_error(struct parsedb_state *ps, const struct pkginfo *pigp,
-                 const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(3);
-void parse_warn(struct parsedb_state *ps, const struct pkginfo *pigp,
-                const char *fmt, ...) DPKG_ATTR_PRINTF(3);
+void parse_error(struct parsedb_state *ps, const char *fmt, ...)
+       DPKG_ATTR_NORET DPKG_ATTR_PRINTF(2);
+void parse_warn(struct parsedb_state *ps, const char *fmt, ...)
+       DPKG_ATTR_PRINTF(2);
 void parse_must_have_field(struct parsedb_state *ps,
-                           const struct pkginfo *pigp,
                            const char *value, const char *what);
 void parse_ensure_have_field(struct parsedb_state *ps,
-                             const struct pkginfo *pigp,
                              const char **value, const char *what);
 
 #define MSDOS_EOF_CHAR '\032' /* ^Z */
diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
index 2b001fe..5121da6 100644
--- a/lib/dpkg/parsehelp.c
+++ b/lib/dpkg/parsehelp.c
@@ -33,17 +33,16 @@
 #include <dpkg/parsedump.h>
 
 static const char *
-parse_error_msg(struct parsedb_state *ps, const struct pkginfo *pigp,
-                const char *fmt)
+parse_error_msg(struct parsedb_state *ps, const char *fmt)
 {
   static char msg[1024];
   char filename[256];
 
   str_escape_fmt(filename, ps->filename, sizeof(filename));
 
-  if (pigp && pigp->name)
+  if (ps->pkg && ps->pkg->name)
     sprintf(msg, _("parsing file '%.255s' near line %d package '%.255s':\n"
-                   " %.255s"), filename, ps->lno, pigp->name, fmt);
+                   " %.255s"), filename, ps->lno, ps->pkg->name, fmt);
   else
     sprintf(msg, _("parsing file '%.255s' near line %d:\n"
                    " %.255s"), filename, ps->lno, fmt);
@@ -52,23 +51,21 @@ parse_error_msg(struct parsedb_state *ps, const struct 
pkginfo *pigp,
 }
 
 void
-parse_error(struct parsedb_state *ps,
-            const struct pkginfo *pigp, const char *fmt, ...)
+parse_error(struct parsedb_state *ps, const char *fmt, ...)
 {
   va_list args;
 
   va_start(args, fmt);
-  ohshitv(parse_error_msg(ps, pigp, fmt), args);
+  ohshitv(parse_error_msg(ps, fmt), args);
 }
 
 void
-parse_warn(struct parsedb_state *ps,
-           const struct pkginfo *pigp, const char *fmt, ...)
+parse_warn(struct parsedb_state *ps, const char *fmt, ...)
 {
   va_list args;
 
   va_start(args, fmt);
-  warningv(parse_error_msg(ps, pigp, fmt), args);
+  warningv(parse_error_msg(ps, fmt), args);
   va_end(args);
 }
 
@@ -279,15 +276,13 @@ parseversion(struct versionrevision *rversion, const char 
*string)
  * on the parse options.
  *
  * @param ps The parsedb state.
- * @param pkg The package being parsed.
  * @param version The version to parse into.
  * @param value The version string to parse from.
  * @param fmt The error format string.
  */
 void
-parse_db_version(struct parsedb_state *ps, const struct pkginfo *pkg,
-                 struct versionrevision *version, const char *value,
-                 const char *fmt, ...)
+parse_db_version(struct parsedb_state *ps, struct versionrevision *version,
+                 const char *value, const char *fmt, ...)
 {
   const char *msg;
   bool warn_msg = false;
@@ -308,34 +303,32 @@ parse_db_version(struct parsedb_state *ps, const struct 
pkginfo *pkg,
     va_end(args);
 
     if (warn_msg)
-      parse_warn(ps, pkg, "%s: %.250s", buf, msg);
+      parse_warn(ps, "%s: %.250s", buf, msg);
     else
-      parse_error(ps, pkg, "%s: %.250s", buf, msg);
+      parse_error(ps, "%s: %.250s", buf, msg);
   }
 }
 
 void
 parse_must_have_field(struct parsedb_state *ps,
-                      const struct pkginfo *pigp,
                       const char *value, const char *what)
 {
   if (!value)
-    parse_error(ps, pigp, _("missing %s"), what);
+    parse_error(ps, _("missing %s"), what);
   else if (!*value)
-    parse_error(ps, pigp, _("empty value for %s"), what);
+    parse_error(ps, _("empty value for %s"), what);
 }
 
 void
 parse_ensure_have_field(struct parsedb_state *ps,
-                        const struct pkginfo *pigp,
                         const char **value, const char *what)
 {
   static const char empty[] = "";
 
   if (!*value) {
-    parse_warn(ps, pigp, _("missing %s"), what);
+    parse_warn(ps, _("missing %s"), what);
     *value = empty;
   } else if (!**value) {
-    parse_warn(ps, pigp, _("empty value for %s"), what);
+    parse_warn(ps, _("empty value for %s"), what);
   }
 }

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to