The following commit has been merged in the master branch:
commit 9f8a2e2b6a21a9b9360e7b29f24d17d64331152b
Author: Guillem Jover <[email protected]>
Date:   Wed Nov 21 23:28:54 2012 +0100

    libdpkg: Refactor PKGPFIELD and FILEFFIELD into new STRUCTFIELD

diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c
index fd1eb65..da0df11 100644
--- a/lib/dpkg/dump.c
+++ b/lib/dpkg/dump.c
@@ -121,7 +121,7 @@ w_charfield(struct varbuf *vb,
             const struct pkginfo *pkg, const struct pkgbin *pkgbin,
             enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  const char *value = PKGPFIELD(pkgbin, fip->integer, const char *);
+  const char *value = STRUCTFIELD(pkgbin, fip->integer, const char *);
 
   if (str_is_unset(value))
     return;
@@ -144,7 +144,8 @@ w_filecharf(struct varbuf *vb,
   if (pkgbin != &pkg->available)
     return;
   fdp = pkg->files;
-  if (!fdp || !FILEFFIELD(fdp,fip->integer,const char*)) return;
+  if (!fdp || !STRUCTFIELD(fdp, fip->integer, const char *))
+    return;
 
   if (flags&fw_printheader) {
     varbuf_add_str(vb, fip->name);
@@ -153,7 +154,7 @@ w_filecharf(struct varbuf *vb,
 
   while (fdp) {
     varbuf_add_char(vb, ' ');
-    varbuf_add_str(vb, FILEFFIELD(fdp, fip->integer, const char *));
+    varbuf_add_str(vb, STRUCTFIELD(fdp, fip->integer, const char *));
     fdp= fdp->next;
   }
 
@@ -166,7 +167,7 @@ w_booleandefno(struct varbuf *vb,
                const struct pkginfo *pkg, const struct pkgbin *pkgbin,
                enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  bool value = PKGPFIELD(pkgbin, fip->integer, bool);
+  bool value = STRUCTFIELD(pkgbin, fip->integer, bool);
 
   if ((flags & fw_printheader) && !value)
     return;
@@ -187,7 +188,7 @@ w_multiarch(struct varbuf *vb,
             const struct pkginfo *pkg, const struct pkgbin *pkgbin,
             enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  int value = PKGPFIELD(pkgbin, fip->integer, int);
+  int value = STRUCTFIELD(pkgbin, fip->integer, int);
 
   if ((flags & fw_printheader) && !value)
     return;
diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index 07091d2..c595484 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -129,7 +129,7 @@ f_filecharf(struct pkginfo *pkg, struct pkgbin *pkgbin,
       fdp->name= fdp->msdosname= fdp->size= fdp->md5sum= NULL;
       *fdpp= fdp;
     }
-    FILEFFIELD(fdp,fip->integer,const char*)= cpos;
+    STRUCTFIELD(fdp, fip->integer, const char *) = cpos;
     fdpp= &fdp->next;
     while (*space && isspace(*space)) space++;
     cpos= space;
@@ -146,7 +146,7 @@ f_charfield(struct pkginfo *pkg, struct pkgbin *pkgbin,
             const char *value, const struct fieldinfo *fip)
 {
   if (*value)
-    PKGPFIELD(pkgbin, fip->integer, char *) = nfstrsave(value);
+    STRUCTFIELD(pkgbin, fip->integer, char *) = nfstrsave(value);
 }
 
 void
@@ -161,7 +161,7 @@ f_boolean(struct pkginfo *pkg, struct pkgbin *pkgbin,
 
   boolean = parse_nv_last(ps, _("yes/no in boolean field"),
                           booleaninfos, value);
-  PKGPFIELD(pkgbin, fip->integer, bool) = boolean;
+  STRUCTFIELD(pkgbin, fip->integer, bool) = boolean;
 }
 
 void
@@ -176,7 +176,7 @@ f_multiarch(struct pkginfo *pkg, struct pkgbin *pkgbin,
 
   multiarch = parse_nv_last(ps, _("foreign/allowed/same/no in quadstate 
field"),
                             multiarchinfos, value);
-  PKGPFIELD(pkgbin, fip->integer, int) = multiarch;
+  STRUCTFIELD(pkgbin, fip->integer, int) = multiarch;
 }
 
 void
diff --git a/lib/dpkg/parsedump.h b/lib/dpkg/parsedump.h
index f39071e..4074bf4 100644
--- a/lib/dpkg/parsedump.h
+++ b/lib/dpkg/parsedump.h
@@ -76,11 +76,10 @@ typedef void parse_field_func(struct parsedb_state *ps, 
struct field_state *fs,
 bool parse_stanza(struct parsedb_state *ps, struct field_state *fs,
                   parse_field_func *parse_field, void *parse_obj);
 
-#define PKGIFPOFF(f) (offsetof(struct pkgbin, f))
-#define PKGPFIELD(pkgbin, of, type) (*(type *)((char *)(pkgbin) + (of)))
+#define STRUCTFIELD(klass, off, type) (*(type *)((char *)(klass) + (off)))
 
+#define PKGIFPOFF(f) (offsetof(struct pkgbin, f))
 #define FILEFOFF(f) (offsetof(struct filedetails, f))
-#define FILEFFIELD(filedetail,of,type) (*(type*)((char*)(filedetail)+(of)))
 
 typedef void freadfunction(struct pkginfo *pkg, struct pkgbin *pkgbin,
                            struct parsedb_state *ps,

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to