Explorar o código

libdpkg: Generalize f_boolean by not hardcoding to the essential member

Fix the function to use PKGPFIELD to assign to the correct struct
member instead of directly assigning to the essential member. This also
makes this function match its write counterpart w_booleandefno's generic
behaviour.
Guillem Jover %!s(int64=17) %!d(string=hai) anos
pai
achega
4b9da22956
Modificáronse 2 ficheiros con 11 adicións e 2 borrados
  1. 5 0
      ChangeLog
  2. 6 2
      lib/fields.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2009-02-27  Guillem Jover  <guillem@debian.org>
+
+	* lib/fields.c (f_boolean): Use PKGPFIELD to assign to the correct
+	member instead of hardcoding to the essential member.
+
 2009-02-27  Guillem Jover  <guillem@debian.org>
 
 	* lib/fields.c (f_boolean): Return if value is an empty string.

+ 6 - 2
lib/fields.c

@@ -130,10 +130,14 @@ void f_boolean(struct pkginfo *pigp, struct pkginfoperfile *pifp,
                enum parsedbflags flags,
                const char *filename, int lno, FILE *warnto, int *warncount,
                const char *value, const struct fieldinfo *fip) {
+  int boolean;
+
   if (!*value)
     return;
-  pifp->essential = convert_string(filename, lno, _("yes/no in boolean field"),
-                                   -1, pigp, value, booleaninfos, NULL);
+
+  boolean = convert_string(filename, lno, _("yes/no in boolean field"),
+                           -1, pigp, value, booleaninfos, NULL);
+  PKGPFIELD(pifp, fip->integer, int) = boolean;
 }
 
 void f_section(struct pkginfo *pigp, struct pkginfoperfile *pifp,