Skip to content

Commit

Permalink
Fix multiple repo local read
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloudef committed Jun 6, 2012
1 parent 8802376 commit 3a755a2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/database.c
Expand Up @@ -233,6 +233,7 @@ int _pndman_db_get(pndman_repository *repo, pndman_device *device)
char appdata[PNDMAN_PATH];
char *ret;
int parse = 0;
pndman_repository *r, *rs;
assert(device);

/* find local db and read it first */
Expand Down Expand Up @@ -264,11 +265,19 @@ int _pndman_db_get(pndman_repository *repo, pndman_device *device)
goto fail;

/* read repository */
memset(s, 0, LINE_MAX);
rs = _pndman_repository_first(repo);
memset(s, 0, LINE_MAX);
snprintf(s2, LINE_MAX-1, "[%s]", repo->url);
while ((ret = fgets(s, LINE_MAX, f))) {
if (!parse && !(memcmp(s, s2, strlen(s2)))) parse = 1;
else if (parse && strlen(s)) fprintf(f2, "%s", s);
if (!parse && !memcmp(s, s2, strlen(s2))) parse = 1;
else if (parse && strlen(s)) {
for (r = rs; r && parse; r = r->next) {
snprintf(s2, LINE_MAX-1, "[%s]", r->url);
if (!memcmp(s, s2, strlen(s2))) parse = 0;
}
if (!parse) break;
fprintf(f2, "%s", s);
}
}

/* process and close */
Expand Down

0 comments on commit 3a755a2

Please sign in to comment.