From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/, /
Date: Sat, 26 Nov 2016 23:17:33 +0000 (UTC) [thread overview]
Message-ID: <1480202122.b1558916d2ca76d7cd4c81248d5b220aaa46a728.vapier@gentoo> (raw)
commit: b1558916d2ca76d7cd4c81248d5b220aaa46a728
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 26 23:15:22 2016 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 26 23:15:22 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b1558916
--quiet: do not suppress fatal error messages
Rework how we write to stderr so that --quiet will automatically
suppress warnings but not any fatal error messages.
URL: https://bugs.gentoo.org/585248
Reported-by: Ulrich Müller <ulm <AT> gentoo.org>
libq/libq.h | 4 +++-
main.c | 34 +++++++++++++++++-----------------
qdepends.c | 2 +-
3 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/libq/libq.h b/libq/libq.h
index 5cc3689..6a74a48 100644
--- a/libq/libq.h
+++ b/libq/libq.h
@@ -1,9 +1,10 @@
/* we need the space before the last comma or we trigger a bug in gcc-2 :( */
+FILE *warnout;
#if defined OPTIMIZE_FOR_SIZE && (OPTIMIZE_FOR_SIZE > 1)
#define warn(fmt, args...)
#else
#define warn(fmt, args...) \
- fprintf(stderr, _("%s%s%s: " fmt "\n"), RED, argv0, NORM , ## args)
+ fprintf(warnout, _("%s%s%s: " fmt "\n"), RED, argv0, NORM , ## args)
#endif
#define warnf(fmt, args...) warn("%s%s()%s: " fmt, YELLOW, __func__, NORM , ## args)
#define warnl(fmt, args...) warn("%s%i()%s: " fmt, YELLOW, __LINE__, NORM , ## args)
@@ -11,6 +12,7 @@
#define warnfp(fmt, args...) warnf(fmt ": %s" , ## args , strerror(errno))
#define _err(wfunc, fmt, args...) \
do { \
+ warnout = stderr; \
wfunc(fmt , ## args); \
exit(EXIT_FAILURE); \
} while (0)
diff --git a/main.c b/main.c
index 76e5bad..8e0e2ad 100644
--- a/main.c
+++ b/main.c
@@ -107,7 +107,7 @@ void no_colors(void)
#define COMMON_GETOPTS_CASES(applet) \
case 0x1: portroot = optarg; break; \
case 'v': ++verbose; break; \
- case 'q': ++quiet; if (freopen("/dev/null", "w", stderr)) { /* ignore errors */ } break; \
+ case 'q': ++quiet; warnout = fopen("/dev/null", "we"); break; \
case 'V': version_barf(); break; \
case 'h': applet ## _usage(EXIT_SUCCESS); break; \
case 'C': no_colors(); break; \
@@ -121,31 +121,31 @@ static void usage(int status, const char *flags, struct option const opts[],
const char a_arg[] = "<arg>";
size_t a_arg_len = strlen(a_arg) + 1;
size_t i, optlen;
+ FILE *fp = status == EXIT_SUCCESS ? stdout : warnout;
- if (status != EXIT_SUCCESS)
- dup2(STDERR_FILENO, STDOUT_FILENO);
if (blabber == 0) {
- printf("%sUsage:%s %sq%s %s<applet> <args>%s : %s"
+ fprintf(fp, "%sUsage:%s %sq%s %s<applet> <args>%s : %s"
"invoke a portage utility applet\n\n", GREEN,
NORM, YELLOW, NORM, DKBLUE, RED, NORM);
- printf("%sCurrently defined applets:%s\n", GREEN, NORM);
+ fprintf(fp, "%sCurrently defined applets:%s\n", GREEN, NORM);
for (i = 0; applets[i].desc; ++i)
if (applets[i].func)
- printf(" %s%8s%s %s%-16s%s%s:%s %s\n",
+ fprintf(fp, " %s%8s%s %s%-16s%s%s:%s %s\n",
YELLOW, applets[i].name, NORM,
DKBLUE, applets[i].opts, NORM,
RED, NORM, _(applets[i].desc));
} else if (blabber > 0) {
- printf("%sUsage:%s %s%s%s [opts] %s%s%s %s:%s %s\n",
+ fprintf(fp, "%sUsage:%s %s%s%s [opts] %s%s%s %s:%s %s\n",
GREEN, NORM,
YELLOW, applets[blabber].name, NORM,
DKBLUE, applets[blabber].opts, NORM,
RED, NORM, _(applets[blabber].desc));
if (desc)
- printf("\n%s\n", desc);
+ fprintf(fp, "\n%s\n", desc);
}
if (module_name != NULL)
- printf("%sLoaded module:%s\n%s%8s%s %s<args>%s\n", GREEN, NORM, YELLOW, module_name, NORM, DKBLUE, NORM);
+ fprintf(fp, "%sLoaded module:%s\n%s%8s%s %s<args>%s\n",
+ GREEN, NORM, YELLOW, module_name, NORM, DKBLUE, NORM);
/* Prescan the --long opt length to auto-align. */
optlen = 0;
@@ -156,23 +156,23 @@ static void usage(int status, const char *flags, struct option const opts[],
optlen = MAX(l, optlen);
}
- printf("\n%sOptions:%s -[%s]\n", GREEN, NORM, flags);
+ fprintf(fp, "\n%sOptions:%s -[%s]\n", GREEN, NORM, flags);
for (i = 0; opts[i].name; ++i) {
/* this assert is a life saver when adding new applets. */
assert(help[i] != NULL);
/* first output the short flag if it has one */
if (opts[i].val > '~' || opts[i].val < ' ')
- printf(" ");
+ fprintf(fp, " ");
else
- printf(" -%c, ", opts[i].val);
+ fprintf(fp, " -%c, ", opts[i].val);
/* then the long flag + help text */
if (opts[i].has_arg == no_argument)
- printf("--%-*s %s*%s %s\n", (int)optlen, opts[i].name,
+ fprintf(fp, "--%-*s %s*%s %s\n", (int)optlen, opts[i].name,
RED, NORM, _(help[i]));
else
- printf("--%s %s%s%s%*s %s*%s %s\n",
+ fprintf(fp, "--%s %s%s%s%*s %s*%s %s\n",
opts[i].name,
DKBLUE, (opts[i].has_arg == a_argument ? a_arg : opt_arg), NORM,
(int)(optlen - strlen(opts[i].name) - a_arg_len), "",
@@ -985,9 +985,8 @@ initialize_flat(const char *overlay, int cache_type, bool force)
return cache_file;
}
- if (!quiet)
- warn("Updating ebuild %scache in %s ... ",
- cache_type == CACHE_EBUILD ? "" : "meta", overlay);
+ warn("Updating ebuild %scache in %s ... ",
+ cache_type == CACHE_EBUILD ? "" : "meta", overlay);
count = frac = secs = 0;
@@ -1421,6 +1420,7 @@ void cleanup(void)
int main(int argc, char **argv)
{
struct stat st;
+ warnout = stderr;
IF_DEBUG(init_coredumps());
argv0 = argv[0];
diff --git a/qdepends.c b/qdepends.c
index 7337c61..3c90863 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -596,7 +596,7 @@ int qdepends_main(int argc, char **argv)
atom_implode(atom);
xarrayfree_int(atoms);
- if (!ret && !quiet)
+ if (!ret)
warn("no matches found for your query");
return ret ? EXIT_SUCCESS : EXIT_FAILURE;
}
next reply other threads:[~2016-11-26 23:17 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-26 23:17 Mike Frysinger [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-06-27 19:19 [gentoo-commits] proj/portage-utils:master commit in: libq/, / Fabian Groffen
2024-03-29 10:57 Fabian Groffen
2024-01-02 7:57 Fabian Groffen
2023-02-07 8:25 Fabian Groffen
2023-02-07 8:10 Fabian Groffen
2021-08-16 13:23 Fabian Groffen
2020-02-21 8:18 Fabian Groffen
2020-01-05 13:28 Fabian Groffen
2020-01-02 11:19 Fabian Groffen
2020-01-01 19:52 Fabian Groffen
2019-12-31 9:05 Fabian Groffen
2019-12-30 17:24 Fabian Groffen
2019-12-29 13:26 Fabian Groffen
2019-12-27 16:57 Fabian Groffen
2019-07-13 10:04 Fabian Groffen
2019-06-19 10:44 Fabian Groffen
2019-06-05 9:15 Fabian Groffen
2019-05-09 20:19 Fabian Groffen
2019-05-05 18:13 Fabian Groffen
2019-04-28 15:20 Fabian Groffen
2019-03-27 20:18 Fabian Groffen
2019-03-27 10:55 Fabian Groffen
2019-03-22 9:57 Fabian Groffen
2019-03-19 20:32 Fabian Groffen
2019-03-19 20:32 Fabian Groffen
2019-03-09 18:58 Fabian Groffen
2018-03-23 11:56 Fabian Groffen
2016-12-29 2:25 Mike Frysinger
2015-11-28 2:44 Mike Frysinger
2015-02-24 1:26 Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1480202122.b1558916d2ca76d7cd4c81248d5b220aaa46a728.vapier@gentoo \
--to=vapier@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox