X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=libopkg%2Fpkg_parse.c;h=d6fe54611cba286f4c495fd4d80d3ec54d216ea8;hb=c6caf07212150f5ec3b0c5f895c496452f9b1e21;hp=7017a06b6f10af45d562fcae68225f0bc21bb3c9;hpb=271d485c10f2070573b25e740b93839945dbcd9d;p=project%2Fopkg-lede.git diff --git a/libopkg/pkg_parse.c b/libopkg/pkg_parse.c index 7017a06..d6fe546 100644 --- a/libopkg/pkg_parse.c +++ b/libopkg/pkg_parse.c @@ -112,7 +112,7 @@ static char *parse_architecture(pkg_t *pkg, const char *str) return pkg_set_architecture(pkg, s, e - s); } -int pkg_parse_line(void *ptr, const char *line, uint mask) +int pkg_parse_line(void *ptr, char *line, uint mask) { pkg_t *pkg = (pkg_t *) ptr; abstract_pkg_t *ab_pkg = NULL; @@ -121,7 +121,6 @@ int pkg_parse_line(void *ptr, const char *line, uint mask) /* these flags are a bit hackish... */ static int reading_conffiles = 0, reading_description = 0; static char *description = NULL; - char *s; int ret = 0; /* Exclude globally masked fields. */ @@ -207,7 +206,7 @@ int pkg_parse_line(void *ptr, const char *line, uint mask) if (ab_pkg && (ab_pkg->state_flag & SF_NEED_DETAIL)) { if (!(pkg->state_flag & SF_NEED_DETAIL)) { - opkg_msg(DEPEND, "propagating abpkg flag to pkg %s\n", pkg->name); + opkg_msg(DEBUG, "propagating abpkg flag to pkg %s\n", pkg->name); pkg->state_flag |= SF_NEED_DETAIL; } } @@ -255,18 +254,16 @@ int pkg_parse_line(void *ptr, const char *line, uint mask) case ' ': if ((mask & PFM_DESCRIPTION) && reading_description) { - if (isatty(1)) { - description = xrealloc(description, - strlen(description) - + 1 + strlen(line) + - 1); + size_t len = (description ? strlen(description) : 0) + + (isatty(1) ? 1 : 0) + strlen(line) + 1; + + description = description ? xrealloc(description, len) + : xcalloc(len, 1); + + if (isatty(1)) strcat(description, "\n"); - } else { - description = xrealloc(description, - strlen(description) - + 1 + strlen(line)); - } - strcat(description, (line)); + + strcat(description, line); goto dont_reset_flags; } else if ((mask & PFM_CONFFILES) && reading_conffiles) { parse_conffiles(pkg, line);