From cdd81bf1775a0ee569a9920cf0e79d4bb6751e6f Mon Sep 17 00:00:00 2001 From: Aurelien Foret Date: Sun, 24 Apr 2005 11:24:18 +0000 Subject: - fixed a cut'n'paste bug with %REASON% entry - factorized code between %SIZE% and %CSIZE% reading --- lib/libalpm/db.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 29547e20..70d5f8e1 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -330,14 +330,7 @@ int db_read(pmdb_t *db, char *name, unsigned int inforeq, pmpkg_t *info) } _alpm_strtrim(tmp); info->reason = atol(tmp); - } else if(!strcmp(line, "%SIZE%")) { - char tmp[32]; - if(fgets(tmp, sizeof(tmp), fp) == NULL) { - return(-1); - } - _alpm_strtrim(tmp); - info->size = atol(tmp); - } else if(!strcmp(line, "%CSIZE%")) { + } else if(!strcmp(line, "%SIZE%") || !strcmp(line, "%CSIZE%")) { /* NOTE: the CSIZE and SIZE fields both share the "size" field * in the pkginfo_t struct. This can be done b/c CSIZE * is currently only used in sync databases, and SIZE is @@ -490,7 +483,7 @@ int db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq) fputs("%SIZE%\n", fp); fprintf(fp, "%ld\n\n", info->size); fputs("%REASON%\n", fp); - fprintf(fp, "%ld\n\n", info->size); + fprintf(fp, "%ld\n\n", info->reason); fclose(fp); } -- cgit v1.2.3-54-g00ecf