Fix parsing of Conffiles lines in status files.
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Thu, 12 Nov 2009 05:02:46 +0000 (05:02 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Thu, 12 Nov 2009 05:02:46 +0000 (05:02 +0000)
Also, add a leading space when writing out the status file such that the
parser can recognise these lines as conf file lines.

git-svn-id: http://opkg.googlecode.com/svn/trunk@287 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/pkg.c
libopkg/pkg_parse.c

index bb3da1e..9ba44e8 100644 (file)
@@ -557,7 +557,7 @@ void pkg_formatted_field(FILE *fp, pkg_t *pkg, const char *field)
                fprintf(fp, "Conffiles:\n");
               for (iter = nv_pair_list_first(&pkg->conffiles); iter; iter = nv_pair_list_next(&pkg->conffiles, iter)) {
                    if (((conffile_t *)iter->data)->name && ((conffile_t *)iter->data)->value) {
-                         fprintf(fp, "%s %s\n", 
+                         fprintf(fp, " %s %s\n", 
                                  ((conffile_t *)iter->data)->name, 
                                  ((conffile_t *)iter->data)->value);
                    }
index a8aa231..4f7fcf2 100644 (file)
@@ -82,26 +82,19 @@ static char ** parseDependsString(const char * raw, int * depends_count)
     return depends;
 }
 
-static void parseConffiles(pkg_t * pkg, const char * raw)
+static void
+parseConffiles(pkg_t *pkg, const char *cstr)
 {
-    char file_name[1048], md5sum[1048];  /* please tell me there aren't any longer that 1k */
+       char file_name[1024], md5sum[35];
 
-    if(!strncmp(raw, "Conffiles:", 10))
-       raw += strlen("Conffiles:");
+       if (sscanf(cstr, "%1023s %34s", file_name, md5sum) != 2) {
+               fprintf(stderr, "%s: failed to parse Conffiles line for %s\n",
+                               __FUNCTION__, pkg->name);
+               return;
+       }
 
-    while(*raw && (sscanf(raw, "%s%s", file_name, md5sum) == 2)){
        conffile_list_append(&pkg->conffiles, file_name, md5sum);
-       /*      fprintf(stderr, "%s %s ", file_name, md5sum);*/
-       while (*raw && isspace(*raw)) {
-           raw++;
-       }
-       raw += strlen(file_name);
-       while (*raw && isspace(*raw)) {
-           raw++;
-       }
-       raw += strlen(md5sum);
-    }
-}    
+}
 
 int
 parseVersion(pkg_t *pkg, const char *vstr)
@@ -158,7 +151,6 @@ pkg_parse_line(pkg_t *pkg, const char *line, uint mask)
 
        case 'C':
            if((mask & PFM_CONFFILES) && isGenericFieldType("Conffiles", line)){
-               parseConffiles(pkg, line);
                reading_conffiles = 1;
                reading_description = 0;
                goto dont_reset_flags;