From 034d3591b3508793d6a06a283335091e81c7e62a Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Wed, 20 Jan 2016 13:41:13 +0100 Subject: [PATCH] xbps-query: generate -o output from a single printf. Else parts written by multiple threads can become mixed up. --- NEWS | 3 +++ bin/xbps-query/ownedby.c | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 08a35a64..530e7ff1 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ xbps-0.52 (???): + * xbps-query(1): fix a bug where the output of -o became mixed up + when running on multiple cores. + xbps-0.51 (2015-12-12): * zsh completion: added -U/--unpack-only support for xbps-install(1). diff --git a/bin/xbps-query/ownedby.c b/bin/xbps-query/ownedby.c index 40e0e69c..fc8684dc 100644 --- a/bin/xbps-query/ownedby.c +++ b/bin/xbps-query/ownedby.c @@ -76,17 +76,19 @@ match_files_by_pattern(xbps_dictionary_t pkg_filesd, xbps_dictionary_get_cstring_nocopy(obj, "target", &tgt); if (ffd->rematch) { if (regexec(&ffd->regex, filestr, 0, 0, 0) == 0) { - printf("%s: %s ", pkgver, filestr); - if (tgt) - printf("-> %s ", tgt); - printf("(%s)\n", typestr); + printf("%s: %s%s%s (%s)\n", + pkgver, filestr, + tgt ? " -> " : "", + tgt ? tgt : "", + typestr); } } else { if ((fnmatch(ffd->pat, filestr, FNM_PERIOD)) == 0) { - printf("%s: %s ", pkgver, filestr); - if (tgt) - printf("-> %s ", tgt); - printf("(%s)\n", typestr); + printf("%s: %s%s%s (%s)\n", + pkgver, filestr, + tgt ? " -> " : "", + tgt ? tgt : "", + typestr); } } }