The following commit has been merged in the master branch:
commit 684e7d7c345652c723103598232957a695050c2e
Author: Guillem Jover <[email protected]>
Date:   Wed Dec 21 03:50:16 2011 +0100

    libdpkg: Refactor field info find into a new function

diff --git a/lib/dpkg/pkg-format.c b/lib/dpkg/pkg-format.c
index da688a9..f4ab20f 100644
--- a/lib/dpkg/pkg-format.c
+++ b/lib/dpkg/pkg-format.c
@@ -3,6 +3,7 @@
  * pkg-format.c - customizable package formatting
  *
  * Copyright © 2001 Wichert Akkerman <[email protected]>
+ * Copyright © 2008-2011 Guillem Jover <[email protected]>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -200,6 +201,19 @@ pkg_format_parse(const char *fmt)
        return head;
 }
 
+static const struct fieldinfo *
+find_field_info(const struct fieldinfo *fields_head,
+                const struct pkg_format_node *fmt_node)
+{
+       const struct fieldinfo *fip;
+
+       for (fip = fields_head; fip->name; fip++)
+               if (strcasecmp(fmt_node->data, fip->name) == 0)
+                       break;
+
+       return fip;
+}
+
 void
 pkg_format_show(const struct pkg_format_node *head,
                 struct pkginfo *pkg, struct pkgbin *pif)
@@ -224,9 +238,7 @@ pkg_format_show(const struct pkg_format_node *head,
                } else if (head->type == field) {
                        const struct fieldinfo *fip;
 
-                       for (fip = fieldinfos; fip->name; fip++)
-                               if (strcasecmp(head->data, fip->name) == 0)
-                                       break;
+                       fip = find_field_info(fieldinfos, head);
 
                        if (fip->name) {
                                fip->wcall(&wb, pkg, pif, 0, fip);

-- 
dpkg's main repository


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

Reply via email to