This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=3a017177110da9f54668b614f78aeb98bf73796d

commit 3a017177110da9f54668b614f78aeb98bf73796d
Author: Guillem Jover <[email protected]>
AuthorDate: Sat Feb 23 04:56:14 2019 +0100

    libdpkg: Merge nicknames table into fieldinfos
    
    The current code first does a lookup to see if the fieldname is in the
    nicknames table, if found fixes up the fieldname to the new alias, and
    then always does a lookup for the normalized name in fieldinfos table.
    
    This penalizes the common case (i.e. non-obsolete fieldnames)
    substantially. Also moving the nicknames into the fieldinfos table will
    allow to print correct fieldnames on error as those are not mangled any
    more, and to provide new wrapper parse functions that print warnings for
    the obsolete fieldnames.
---
 debian/changelog     |  2 ++
 lib/dpkg/parse.c     | 29 +++++++----------------------
 lib/dpkg/parsedump.h |  8 --------
 3 files changed, 9 insertions(+), 30 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 670266e9a..a33d3c7b2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -29,6 +29,8 @@ dpkg (1.19.5) UNRELEASED; urgency=medium
   * libdpkg: Optimize error handling. Move the error reporting outside the
     involved functions so that we do not need to call gettext if there is no
     error, which has a significant performance cost.
+  * libdpkg: Merge nicknames table into fieldinfos, to stop penalizing the
+    lookup of non-obsolete fieldnames.
   * Perl modules:
     - Dpkg::Vendor::Debian: Add support for merged-usr-via-symlinks tainted
       tag. Suggested by Alexander E. Patrakov <[email protected]>.
diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index 2a96e7e46..b5e8a37c7 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -64,7 +64,6 @@ const struct fieldinfo fieldinfos[]= {
   { FIELD("Multi-Arch"),       f_multiarch,       w_multiarch,      
PKGIFPOFF(multiarch)     },
   { FIELD("Source"),           f_charfield,       w_charfield,      
PKGIFPOFF(source)        },
   { FIELD("Version"),          f_version,         w_version,        
PKGIFPOFF(version)       },
-  { FIELD("Revision"),         f_revision,        w_null                       
              },
   { FIELD("Config-Version"),   f_configversion,   w_configversion              
              },
   { FIELD("Replaces"),         f_dependency,      w_dependency,     
dep_replaces             },
   { FIELD("Provides"),         f_dependency,      w_dependency,     
dep_provides             },
@@ -84,17 +83,13 @@ const struct fieldinfo fieldinfos[]= {
   { FIELD("Triggers-Pending"), f_trigpend,        w_trigpend                   
              },
   { FIELD("Triggers-Awaited"), f_trigaw,          w_trigaw                     
              },
   /* Note that aliases are added to the nicknames table. */
-  {  NULL                                                                      
       }
-};
-
-static const struct nickname nicknames[] = {
-  /* Note: Capitalization of these strings is important. */
-  { NICK("Recommended"),      .canon = "Recommends" },
-  { NICK("Optional"),         .canon = "Suggests" },
-  { NICK("Class"),            .canon = "Priority" },
-  { NICK("Package-Revision"), .canon = "Revision" },
-  { NICK("Package_Revision"), .canon = "Revision" },
-  { .nick = NULL }
+  { FIELD("Revision"),         f_revision,        w_null                       
              },
+  { FIELD("Recommended"),      f_dependency,      w_null                       
              },
+  { FIELD("Optional"),         f_dependency,      w_null                       
              },
+  { FIELD("Class"),            f_priority,        w_null                       
              },
+  { FIELD("Package-Revision"), f_revision,        w_null                       
              },
+  { FIELD("Package_Revision"), f_revision,        w_null                       
              },
+  { NULL                                                                       
              }
 };
 
 /**
@@ -116,19 +111,9 @@ pkg_parse_field(struct parsedb_state *ps, struct 
field_state *fs,
                 void *parse_obj)
 {
   struct pkg_parse_object *pkg_obj = parse_obj;
-  const struct nickname *nick;
   const struct fieldinfo *fip;
   int *ip;
 
-  for (nick = nicknames; nick->nick; nick++)
-    if (nick->nicklen == (size_t)fs->fieldlen &&
-        strncasecmp(nick->nick, fs->fieldstart, fs->fieldlen) == 0)
-      break;
-  if (nick->nick) {
-    fs->fieldstart = nick->canon;
-    fs->fieldlen = strlen(fs->fieldstart);
-  }
-
   for (fip = fieldinfos, ip = fs->fieldencountered; fip->name; fip++, ip++)
     if (fip->namelen == (size_t)fs->fieldlen &&
         strncasecmp(fip->name, fs->fieldstart, fs->fieldlen) == 0)
diff --git a/lib/dpkg/parsedump.h b/lib/dpkg/parsedump.h
index 8e9a71056..ea29ff317 100644
--- a/lib/dpkg/parsedump.h
+++ b/lib/dpkg/parsedump.h
@@ -158,14 +158,6 @@ void parse_ensure_have_field(struct parsedb_state *ps,
 
 #define MSDOS_EOF_CHAR '\032' /* ^Z */
 
-#define NICK(name) .nick = name, .nicklen = sizeof(name) - 1
-
-struct nickname {
-  const char *nick;
-  const char *canon;
-  size_t nicklen;
-};
-
 extern const struct fieldinfo fieldinfos[];
 
 /** @} */

-- 
Dpkg.Org's dpkg

Reply via email to