mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-11 03:54:59 -05:00
be_sync: make READ_NEXT() a no-arg macro
We passed in 'line', but not 'buf.line'. In addition, the macros building off of READ_NEXT() assume variable names anyway. Since we only use these macros in one function, might as well simplify them. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
cf1401a04d
commit
de8b9a85a5
@ -433,19 +433,19 @@ static int sync_db_populate(alpm_db_t *db)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define READ_NEXT(s) do { \
|
#define READ_NEXT() do { \
|
||||||
if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) goto error; \
|
if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) goto error; \
|
||||||
s = _alpm_strtrim(buf.line); \
|
line = _alpm_strtrim(buf.line); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define READ_AND_STORE(f) do { \
|
#define READ_AND_STORE(f) do { \
|
||||||
READ_NEXT(line); \
|
READ_NEXT(); \
|
||||||
STRDUP(f, line, goto error); \
|
STRDUP(f, line, goto error); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define READ_AND_STORE_ALL(f) do { \
|
#define READ_AND_STORE_ALL(f) do { \
|
||||||
char *linedup; \
|
char *linedup; \
|
||||||
READ_NEXT(line); \
|
READ_NEXT(); \
|
||||||
if(strlen(line) == 0) break; \
|
if(strlen(line) == 0) break; \
|
||||||
STRDUP(linedup, line, goto error); \
|
STRDUP(linedup, line, goto error); \
|
||||||
f = alpm_list_add(f, linedup); \
|
f = alpm_list_add(f, linedup); \
|
||||||
@ -488,13 +488,13 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
|
|||||||
char *line = _alpm_strtrim(buf.line);
|
char *line = _alpm_strtrim(buf.line);
|
||||||
|
|
||||||
if(strcmp(line, "%NAME%") == 0) {
|
if(strcmp(line, "%NAME%") == 0) {
|
||||||
READ_NEXT(line);
|
READ_NEXT();
|
||||||
if(strcmp(line, pkg->name) != 0) {
|
if(strcmp(line, pkg->name) != 0) {
|
||||||
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: name "
|
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: name "
|
||||||
"mismatch on package %s\n"), db->treename, pkg->name);
|
"mismatch on package %s\n"), db->treename, pkg->name);
|
||||||
}
|
}
|
||||||
} else if(strcmp(line, "%VERSION%") == 0) {
|
} else if(strcmp(line, "%VERSION%") == 0) {
|
||||||
READ_NEXT(line);
|
READ_NEXT();
|
||||||
if(strcmp(line, pkg->version) != 0) {
|
if(strcmp(line, pkg->version) != 0) {
|
||||||
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: version "
|
_alpm_log(db->handle, PM_LOG_ERROR, _("%s database is inconsistent: version "
|
||||||
"mismatch on package %s\n"), db->treename, pkg->name);
|
"mismatch on package %s\n"), db->treename, pkg->name);
|
||||||
@ -512,7 +512,7 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
|
|||||||
} else if(strcmp(line, "%ARCH%") == 0) {
|
} else if(strcmp(line, "%ARCH%") == 0) {
|
||||||
READ_AND_STORE(pkg->arch);
|
READ_AND_STORE(pkg->arch);
|
||||||
} else if(strcmp(line, "%BUILDDATE%") == 0) {
|
} else if(strcmp(line, "%BUILDDATE%") == 0) {
|
||||||
READ_NEXT(line);
|
READ_NEXT();
|
||||||
pkg->builddate = _alpm_parsedate(line);
|
pkg->builddate = _alpm_parsedate(line);
|
||||||
} else if(strcmp(line, "%PACKAGER%") == 0) {
|
} else if(strcmp(line, "%PACKAGER%") == 0) {
|
||||||
READ_AND_STORE(pkg->packager);
|
READ_AND_STORE(pkg->packager);
|
||||||
@ -521,20 +521,20 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
|
|||||||
* pkginfo_t struct. This can be done b/c CSIZE is currently only used
|
* pkginfo_t struct. This can be done b/c CSIZE is currently only used
|
||||||
* in sync databases, and SIZE is only used in local databases.
|
* in sync databases, and SIZE is only used in local databases.
|
||||||
*/
|
*/
|
||||||
READ_NEXT(line);
|
READ_NEXT();
|
||||||
pkg->size = atol(line);
|
pkg->size = atol(line);
|
||||||
/* also store this value to isize if isize is unset */
|
/* also store this value to isize if isize is unset */
|
||||||
if(pkg->isize == 0) {
|
if(pkg->isize == 0) {
|
||||||
pkg->isize = pkg->size;
|
pkg->isize = pkg->size;
|
||||||
}
|
}
|
||||||
} else if(strcmp(line, "%ISIZE%") == 0) {
|
} else if(strcmp(line, "%ISIZE%") == 0) {
|
||||||
READ_NEXT(line);
|
READ_NEXT();
|
||||||
pkg->isize = atol(line);
|
pkg->isize = atol(line);
|
||||||
} else if(strcmp(line, "%MD5SUM%") == 0) {
|
} else if(strcmp(line, "%MD5SUM%") == 0) {
|
||||||
READ_AND_STORE(pkg->md5sum);
|
READ_AND_STORE(pkg->md5sum);
|
||||||
} else if(strcmp(line, "%SHA256SUM%") == 0) {
|
} else if(strcmp(line, "%SHA256SUM%") == 0) {
|
||||||
/* we don't do anything with this value right now */
|
/* we don't do anything with this value right now */
|
||||||
READ_NEXT(line);
|
READ_NEXT();
|
||||||
} else if(strcmp(line, "%PGPSIG%") == 0) {
|
} else if(strcmp(line, "%PGPSIG%") == 0) {
|
||||||
READ_AND_STORE(pkg->base64_sig);
|
READ_AND_STORE(pkg->base64_sig);
|
||||||
} else if(strcmp(line, "%REPLACES%") == 0) {
|
} else if(strcmp(line, "%REPLACES%") == 0) {
|
||||||
@ -542,7 +542,7 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
|
|||||||
} else if(strcmp(line, "%DEPENDS%") == 0) {
|
} else if(strcmp(line, "%DEPENDS%") == 0) {
|
||||||
/* Different than the rest because of the _alpm_splitdep call. */
|
/* Different than the rest because of the _alpm_splitdep call. */
|
||||||
while(1) {
|
while(1) {
|
||||||
READ_NEXT(line);
|
READ_NEXT();
|
||||||
if(strlen(line) == 0) break;
|
if(strlen(line) == 0) break;
|
||||||
pkg->depends = alpm_list_add(pkg->depends, _alpm_splitdep(line));
|
pkg->depends = alpm_list_add(pkg->depends, _alpm_splitdep(line));
|
||||||
}
|
}
|
||||||
@ -555,7 +555,7 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
|
|||||||
} else if(strcmp(line, "%DELTAS%") == 0) {
|
} else if(strcmp(line, "%DELTAS%") == 0) {
|
||||||
/* Different than the rest because of the _alpm_delta_parse call. */
|
/* Different than the rest because of the _alpm_delta_parse call. */
|
||||||
while(1) {
|
while(1) {
|
||||||
READ_NEXT(line);
|
READ_NEXT();
|
||||||
if(strlen(line) == 0) break;
|
if(strlen(line) == 0) break;
|
||||||
pkg->deltas = alpm_list_add(pkg->deltas, _alpm_delta_parse(line));
|
pkg->deltas = alpm_list_add(pkg->deltas, _alpm_delta_parse(line));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user