summaryrefslogtreecommitdiffstats
path: root/libopkg
diff options
context:
space:
mode:
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-11-12 00:02:46 (EST)
committer graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-11-12 00:02:46 (EST)
commit7be28022d09b3a4923db82bae66187ceafa5a53c (patch)
treea20bcd206eb664e8929808b7193d352215ba8b3e /libopkg
parent332947f2518b71342ebe3719899e83405a79c15d (diff)
Fix parsing of Conffiles lines in status files.
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
Diffstat (limited to 'libopkg')
-rw-r--r--libopkg/pkg.c2
-rw-r--r--libopkg/pkg_parse.c26
2 files changed, 10 insertions, 18 deletions
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index bb3da1e..9ba44e8 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -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);
}
diff --git a/libopkg/pkg_parse.c b/libopkg/pkg_parse.c
index a8aa231..4f7fcf2 100644
--- a/libopkg/pkg_parse.c
+++ b/libopkg/pkg_parse.c
@@ -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;