From: Jo-Philipp Wich Date: Fri, 10 Feb 2017 09:14:02 +0000 (+0100) Subject: libopkg: line-wrap descriptions only on interactive terminals X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9d0d61cf8c85b815b90a3a3ae2e1da2b5dbf214c;p=oweals%2Fopkg-lede.git libopkg: line-wrap descriptions only on interactive terminals Various programs call opkg and extract information from its list and info commands. To simplify parsing the output, do not line-wrap long description lines if opkg is not talking to a tty. Signed-off-by: Jo-Philipp Wich --- diff --git a/libopkg/pkg_parse.c b/libopkg/pkg_parse.c index b54ad9a..5337f34 100644 --- a/libopkg/pkg_parse.c +++ b/libopkg/pkg_parse.c @@ -20,6 +20,7 @@ #include #include +#include #include "pkg.h" #include "opkg_utils.h" @@ -239,10 +240,16 @@ pkg_parse_line(void *ptr, const char *line, uint mask) case ' ': if ((mask & PFM_DESCRIPTION) && reading_description) { - pkg->description = xrealloc(pkg->description, - strlen(pkg->description) - + 1 + strlen(line) + 1); - strcat(pkg->description, "\n"); + if (isatty(1)) { + pkg->description = xrealloc(pkg->description, + strlen(pkg->description) + + 1 + strlen(line) + 1); + strcat(pkg->description, "\n"); + } else { + pkg->description = xrealloc(pkg->description, + strlen(pkg->description) + + 1 + strlen(line)); + } strcat(pkg->description, (line)); goto dont_reset_flags; } else if ((mask & PFM_CONFFILES) && reading_conffiles) {