|
@@ -300,7 +300,8 @@ int parsedb(const char *filename, enum parsedbflags flags,
|
|
|
struct pkginfo **donep)
|
|
struct pkginfo **donep)
|
|
|
{
|
|
{
|
|
|
static int fd;
|
|
static int fd;
|
|
|
- struct pkginfo new_pkg, *db_pkg;
|
|
|
|
|
|
|
+ struct pkginfo tmp_pkg;
|
|
|
|
|
+ struct pkginfo *new_pkg, *db_pkg;
|
|
|
struct pkgbin *new_pkgbin, *db_pkgbin;
|
|
struct pkgbin *new_pkgbin, *db_pkgbin;
|
|
|
int pdone;
|
|
int pdone;
|
|
|
char *data, *dataptr, *endptr;
|
|
char *data, *dataptr, *endptr;
|
|
@@ -314,10 +315,11 @@ int parsedb(const char *filename, enum parsedbflags flags,
|
|
|
|
|
|
|
|
memset(&fs, 0, sizeof(fs));
|
|
memset(&fs, 0, sizeof(fs));
|
|
|
|
|
|
|
|
|
|
+ new_pkg = &tmp_pkg;
|
|
|
if (flags & pdb_recordavailable)
|
|
if (flags & pdb_recordavailable)
|
|
|
- new_pkgbin = &new_pkg.available;
|
|
|
|
|
|
|
+ new_pkgbin = &new_pkg->available;
|
|
|
else
|
|
else
|
|
|
- new_pkgbin = &new_pkg.installed;
|
|
|
|
|
|
|
+ new_pkgbin = &new_pkg->installed;
|
|
|
|
|
|
|
|
fd= open(filename, O_RDONLY);
|
|
fd= open(filename, O_RDONLY);
|
|
|
if (fd == -1) ohshite(_("failed to open package info file `%.255s' for reading"),filename);
|
|
if (fd == -1) ohshite(_("failed to open package info file `%.255s' for reading"),filename);
|
|
@@ -354,7 +356,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
|
|
|
int c;
|
|
int c;
|
|
|
|
|
|
|
|
memset(fs.fieldencountered, 0, sizeof(fs.fieldencountered));
|
|
memset(fs.fieldencountered, 0, sizeof(fs.fieldencountered));
|
|
|
- pkg_blank(&new_pkg);
|
|
|
|
|
|
|
+ pkg_blank(new_pkg);
|
|
|
|
|
|
|
|
/* Skip adjacent new lines. */
|
|
/* Skip adjacent new lines. */
|
|
|
while(!EOF_mmap(dataptr, endptr)) {
|
|
while(!EOF_mmap(dataptr, endptr)) {
|
|
@@ -371,17 +373,17 @@ int parsedb(const char *filename, enum parsedbflags flags,
|
|
|
fs.fieldlen = dataptr - fs.fieldstart - 1;
|
|
fs.fieldlen = dataptr - fs.fieldstart - 1;
|
|
|
while (!EOF_mmap(dataptr, endptr) && c != '\n' && isspace(c)) c= getc_mmap(dataptr);
|
|
while (!EOF_mmap(dataptr, endptr) && c != '\n' && isspace(c)) c= getc_mmap(dataptr);
|
|
|
if (EOF_mmap(dataptr, endptr))
|
|
if (EOF_mmap(dataptr, endptr))
|
|
|
- parse_error(&ps, &new_pkg,
|
|
|
|
|
|
|
+ parse_error(&ps, new_pkg,
|
|
|
_("EOF after field name `%.*s'"), fs.fieldlen, fs.fieldstart);
|
|
_("EOF after field name `%.*s'"), fs.fieldlen, fs.fieldstart);
|
|
|
if (c == '\n')
|
|
if (c == '\n')
|
|
|
- parse_error(&ps, &new_pkg,
|
|
|
|
|
|
|
+ parse_error(&ps, new_pkg,
|
|
|
_("newline in field name `%.*s'"), fs.fieldlen, fs.fieldstart);
|
|
_("newline in field name `%.*s'"), fs.fieldlen, fs.fieldstart);
|
|
|
if (c == MSDOS_EOF_CHAR)
|
|
if (c == MSDOS_EOF_CHAR)
|
|
|
- parse_error(&ps, &new_pkg,
|
|
|
|
|
|
|
+ parse_error(&ps, new_pkg,
|
|
|
_("MSDOS EOF (^Z) in field name `%.*s'"),
|
|
_("MSDOS EOF (^Z) in field name `%.*s'"),
|
|
|
fs.fieldlen, fs.fieldstart);
|
|
fs.fieldlen, fs.fieldstart);
|
|
|
if (c != ':')
|
|
if (c != ':')
|
|
|
- parse_error(&ps, &new_pkg,
|
|
|
|
|
|
|
+ parse_error(&ps, new_pkg,
|
|
|
_("field name `%.*s' must be followed by colon"),
|
|
_("field name `%.*s' must be followed by colon"),
|
|
|
fs.fieldlen, fs.fieldstart);
|
|
fs.fieldlen, fs.fieldstart);
|
|
|
/* Skip space after ‘:’ but before value and EOL. */
|
|
/* Skip space after ‘:’ but before value and EOL. */
|
|
@@ -390,11 +392,11 @@ int parsedb(const char *filename, enum parsedbflags flags,
|
|
|
if (c == '\n' || !isspace(c)) break;
|
|
if (c == '\n' || !isspace(c)) break;
|
|
|
}
|
|
}
|
|
|
if (EOF_mmap(dataptr, endptr))
|
|
if (EOF_mmap(dataptr, endptr))
|
|
|
- parse_error(&ps, &new_pkg,
|
|
|
|
|
|
|
+ parse_error(&ps, new_pkg,
|
|
|
_("EOF before value of field `%.*s' (missing final newline)"),
|
|
_("EOF before value of field `%.*s' (missing final newline)"),
|
|
|
fs.fieldlen, fs.fieldstart);
|
|
fs.fieldlen, fs.fieldstart);
|
|
|
if (c == MSDOS_EOF_CHAR)
|
|
if (c == MSDOS_EOF_CHAR)
|
|
|
- parse_error(&ps, &new_pkg,
|
|
|
|
|
|
|
+ parse_error(&ps, new_pkg,
|
|
|
_("MSDOS EOF char in value of field `%.*s' (missing newline?)"),
|
|
_("MSDOS EOF char in value of field `%.*s' (missing newline?)"),
|
|
|
fs.fieldlen, fs.fieldstart);
|
|
fs.fieldlen, fs.fieldstart);
|
|
|
fs.valuestart = dataptr - 1;
|
|
fs.valuestart = dataptr - 1;
|
|
@@ -408,7 +410,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
|
|
|
ungetc_mmap(c,dataptr, data);
|
|
ungetc_mmap(c,dataptr, data);
|
|
|
c= '\n';
|
|
c= '\n';
|
|
|
} else if (EOF_mmap(dataptr, endptr)) {
|
|
} else if (EOF_mmap(dataptr, endptr)) {
|
|
|
- parse_error(&ps, &new_pkg,
|
|
|
|
|
|
|
+ parse_error(&ps, new_pkg,
|
|
|
_("EOF during value of field `%.*s' (missing final newline)"),
|
|
_("EOF during value of field `%.*s' (missing final newline)"),
|
|
|
fs.fieldlen, fs.fieldstart);
|
|
fs.fieldlen, fs.fieldstart);
|
|
|
}
|
|
}
|
|
@@ -419,18 +421,18 @@ int parsedb(const char *filename, enum parsedbflags flags,
|
|
|
while (fs.valuelen && isspace(*(fs.valuestart + fs.valuelen - 1)))
|
|
while (fs.valuelen && isspace(*(fs.valuestart + fs.valuelen - 1)))
|
|
|
fs.valuelen--;
|
|
fs.valuelen--;
|
|
|
|
|
|
|
|
- pkg_parse_field(&ps, &fs, &new_pkg, new_pkgbin);
|
|
|
|
|
|
|
+ pkg_parse_field(&ps, &fs, new_pkg, new_pkgbin);
|
|
|
|
|
|
|
|
if (EOF_mmap(dataptr, endptr) || c == '\n' || c == MSDOS_EOF_CHAR) break;
|
|
if (EOF_mmap(dataptr, endptr) || c == '\n' || c == MSDOS_EOF_CHAR) break;
|
|
|
} /* Loop per field. */
|
|
} /* Loop per field. */
|
|
|
|
|
|
|
|
if (pdone && donep)
|
|
if (pdone && donep)
|
|
|
- parse_error(&ps, &new_pkg,
|
|
|
|
|
|
|
+ parse_error(&ps, new_pkg,
|
|
|
_("several package info entries found, only one allowed"));
|
|
_("several package info entries found, only one allowed"));
|
|
|
|
|
|
|
|
- pkg_parse_verify(&ps, &new_pkg, new_pkgbin);
|
|
|
|
|
|
|
+ pkg_parse_verify(&ps, new_pkg, new_pkgbin);
|
|
|
|
|
|
|
|
- db_pkg = pkg_db_find(new_pkg.name);
|
|
|
|
|
|
|
+ db_pkg = pkg_db_find(new_pkg->name);
|
|
|
if (flags & pdb_recordavailable)
|
|
if (flags & pdb_recordavailable)
|
|
|
db_pkgbin = &db_pkg->available;
|
|
db_pkgbin = &db_pkg->available;
|
|
|
else
|
|
else
|
|
@@ -440,7 +442,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
|
|
|
versioncompare(&new_pkgbin->version, &db_pkgbin->version) < 0)
|
|
versioncompare(&new_pkgbin->version, &db_pkgbin->version) < 0)
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
|
- pkg_parse_copy(&ps, db_pkg, db_pkgbin, &new_pkg, new_pkgbin);
|
|
|
|
|
|
|
+ pkg_parse_copy(&ps, db_pkg, db_pkgbin, new_pkg, new_pkgbin);
|
|
|
|
|
|
|
|
if (donep)
|
|
if (donep)
|
|
|
*donep = db_pkg;
|
|
*donep = db_pkg;
|