The following commit has been merged in the master branch: commit d4570062746784dd192fcc332de242532073a837 Author: Guillem Jover <guil...@debian.org> Date: Mon Apr 16 06:16:01 2012 +0200
libdpkg: Simplify f_booleandefno() and f_multiarch() implementations This unifies the logic to match the rest of the dumping functions, by printing an optional field name, the value itself and an optional trailing newline. These two functions are somewhat special though, and the reason for the previous code layout, because they do not print the value if it is null and no field name has been requested. diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c index c53f166..e244773 100644 --- a/lib/dpkg/dump.c +++ b/lib/dpkg/dump.c @@ -162,14 +162,19 @@ w_booleandefno(struct varbuf *vb, enum fwriteflags flags, const struct fieldinfo *fip) { bool value = PKGPFIELD(pkgbin, fip->integer, bool); - if (!(flags&fw_printheader)) { - varbuf_add_str(vb, value ? "yes" : "no"); + + if ((flags & fw_printheader) && !value) return; + + if (flags & fw_printheader) { + varbuf_add_str(vb, fip->name); + varbuf_add_str(vb, ": "); } - if (!value) return; - assert(value == true); - varbuf_add_str(vb, fip->name); - varbuf_add_str(vb, ": yes\n"); + + varbuf_add_str(vb, value ? "yes" : "no"); + + if (flags & fw_printheader) + varbuf_add_char(vb, '\n'); } void @@ -179,17 +184,18 @@ w_multiarch(struct varbuf *vb, { int value = PKGPFIELD(pkgbin, fip->integer, int); - if (!(flags & fw_printheader)) { - varbuf_add_str(vb, multiarchinfos[value].name); + if ((flags & fw_printheader) && !value) return; + + if (flags & fw_printheader) { + varbuf_add_str(vb, fip->name); + varbuf_add_str(vb, ": "); } - if (!value) - return; - varbuf_add_str(vb, fip->name); - varbuf_add_str(vb, ": "); varbuf_add_str(vb, multiarchinfos[value].name); - varbuf_add_char(vb, '\n'); + + if (flags & fw_printheader) + varbuf_add_char(vb, '\n'); } void -- 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