Explorar o código

libdpkg: Move field matching into for (;;) bodies in pkg_parse_field()

The current code is performing the field matching in the for (;;)
conditional, which implies and empty for (;;) body and needs inverted
logic to work. Move the matching into the body as that's the more
natural place for it to be and easier to read.
Guillem Jover %!s(int64=15) %!d(string=hai) anos
pai
achega
5f2b4a4632
Modificáronse 1 ficheiros con 7 adicións e 6 borrados
  1. 7 6
      lib/dpkg/parse.c

+ 7 - 6
lib/dpkg/parse.c

@@ -103,17 +103,18 @@ pkg_parse_field(struct parsedb_state *ps, struct field_state *fs,
   const struct fieldinfo *fip;
   const struct fieldinfo *fip;
   int *ip;
   int *ip;
 
 
-  for (nick = nicknames;
-       nick->nick && (strncasecmp(nick->nick, fs->fieldstart, fs->fieldlen) ||
-                      nick->nick[fs->fieldlen] != '\0'); nick++) ;
+  for (nick = nicknames; nick->nick; nick++)
+    if (strncasecmp(nick->nick, fs->fieldstart, fs->fieldlen) == 0 &&
+        nick->nick[fs->fieldlen] == '\0')
+      break;
   if (nick->nick) {
   if (nick->nick) {
     fs->fieldstart = nick->canon;
     fs->fieldstart = nick->canon;
     fs->fieldlen = strlen(fs->fieldstart);
     fs->fieldlen = strlen(fs->fieldstart);
   }
   }
 
 
-  for (fip = fieldinfos, ip = fs->fieldencountered;
-       fip->name && strncasecmp(fs->fieldstart, fip->name, fs->fieldlen);
-       fip++, ip++) ;
+  for (fip = fieldinfos, ip = fs->fieldencountered; fip->name; fip++, ip++)
+    if (strncasecmp(fip->name, fs->fieldstart, fs->fieldlen) == 0)
+      break;
   if (fip->name) {
   if (fip->name) {
     if ((*ip)++)
     if ((*ip)++)
       parse_error(ps, pkg,
       parse_error(ps, pkg,