The following commit has been merged in the master branch:
commit eedb20c17071efd92112edf60f74f9f637b4aaed
Author: Guillem Jover <[email protected]>
Date:   Sat Jan 29 06:19:28 2011 +0100

    libdpkg: Change new_pkg to be a pointer in parsedb()
    
    This way all variables are handled the same.

diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index e3da127..fae3531 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -300,7 +300,8 @@ int parsedb(const char *filename, enum parsedbflags flags,
             struct pkginfo **donep)
 {
   static int fd;
-  struct pkginfo new_pkg, *db_pkg;
+  struct pkginfo tmp_pkg;
+  struct pkginfo *new_pkg, *db_pkg;
   struct pkgbin *new_pkgbin, *db_pkgbin;
   int pdone;
   char *data, *dataptr, *endptr;
@@ -314,10 +315,11 @@ int parsedb(const char *filename, enum parsedbflags flags,
 
   memset(&fs, 0, sizeof(fs));
 
+  new_pkg = &tmp_pkg;
   if (flags & pdb_recordavailable)
-    new_pkgbin = &new_pkg.available;
+    new_pkgbin = &new_pkg->available;
   else
-    new_pkgbin = &new_pkg.installed;
+    new_pkgbin = &new_pkg->installed;
 
   fd= open(filename, O_RDONLY);
   if (fd == -1) ohshite(_("failed to open package info file `%.255s' for 
reading"),filename);
@@ -354,7 +356,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
     int c;
 
     memset(fs.fieldencountered, 0, sizeof(fs.fieldencountered));
-    pkg_blank(&new_pkg);
+    pkg_blank(new_pkg);
 
     /* Skip adjacent new lines. */
     while(!EOF_mmap(dataptr, endptr)) {
@@ -371,17 +373,17 @@ int parsedb(const char *filename, enum parsedbflags flags,
       fs.fieldlen = dataptr - fs.fieldstart - 1;
       while (!EOF_mmap(dataptr, endptr) && c != '\n' && isspace(c)) c= 
getc_mmap(dataptr);
       if (EOF_mmap(dataptr, endptr))
-        parse_error(&ps, &new_pkg,
+        parse_error(&ps, new_pkg,
                     _("EOF after field name `%.*s'"), fs.fieldlen, 
fs.fieldstart);
       if (c == '\n')
-        parse_error(&ps, &new_pkg,
+        parse_error(&ps, new_pkg,
                     _("newline in field name `%.*s'"), fs.fieldlen, 
fs.fieldstart);
       if (c == MSDOS_EOF_CHAR)
-        parse_error(&ps, &new_pkg,
+        parse_error(&ps, new_pkg,
                     _("MSDOS EOF (^Z) in field name `%.*s'"),
                     fs.fieldlen, fs.fieldstart);
       if (c != ':')
-        parse_error(&ps, &new_pkg,
+        parse_error(&ps, new_pkg,
                     _("field name `%.*s' must be followed by colon"),
                     fs.fieldlen, fs.fieldstart);
       /* Skip space after ‘:’ but before value and EOL. */
@@ -390,11 +392,11 @@ int parsedb(const char *filename, enum parsedbflags flags,
         if (c == '\n' || !isspace(c)) break;
       }
       if (EOF_mmap(dataptr, endptr))
-        parse_error(&ps, &new_pkg,
+        parse_error(&ps, new_pkg,
                     _("EOF before value of field `%.*s' (missing final 
newline)"),
                     fs.fieldlen, fs.fieldstart);
       if (c == MSDOS_EOF_CHAR)
-        parse_error(&ps, &new_pkg,
+        parse_error(&ps, new_pkg,
                     _("MSDOS EOF char in value of field `%.*s' (missing 
newline?)"),
                     fs.fieldlen, fs.fieldstart);
       fs.valuestart = dataptr - 1;
@@ -408,7 +410,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
           ungetc_mmap(c,dataptr, data);
           c= '\n';
         } else if (EOF_mmap(dataptr, endptr)) {
-          parse_error(&ps, &new_pkg,
+          parse_error(&ps, new_pkg,
                       _("EOF during value of field `%.*s' (missing final 
newline)"),
                       fs.fieldlen, fs.fieldstart);
         }
@@ -419,18 +421,18 @@ int parsedb(const char *filename, enum parsedbflags flags,
       while (fs.valuelen && isspace(*(fs.valuestart + fs.valuelen - 1)))
         fs.valuelen--;
 
-      pkg_parse_field(&ps, &fs, &new_pkg, new_pkgbin);
+      pkg_parse_field(&ps, &fs, new_pkg, new_pkgbin);
 
       if (EOF_mmap(dataptr, endptr) || c == '\n' || c == MSDOS_EOF_CHAR) break;
     } /* Loop per field. */
 
     if (pdone && donep)
-      parse_error(&ps, &new_pkg,
+      parse_error(&ps, new_pkg,
                   _("several package info entries found, only one allowed"));
 
-    pkg_parse_verify(&ps, &new_pkg, new_pkgbin);
+    pkg_parse_verify(&ps, new_pkg, new_pkgbin);
 
-    db_pkg = pkg_db_find(new_pkg.name);
+    db_pkg = pkg_db_find(new_pkg->name);
     if (flags & pdb_recordavailable)
       db_pkgbin = &db_pkg->available;
     else
@@ -440,7 +442,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
         versioncompare(&new_pkgbin->version, &db_pkgbin->version) < 0)
       continue;
 
-    pkg_parse_copy(&ps, db_pkg, db_pkgbin, &new_pkg, new_pkgbin);
+    pkg_parse_copy(&ps, db_pkg, db_pkgbin, new_pkg, new_pkgbin);
 
     if (donep)
       *donep = db_pkg;

-- 
dpkg's main repository


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

Reply via email to