main: add support for --silence-errors by redirecting stderr to /dev/null

feature/tap-sh
William Pitcock 2012-07-21 14:33:07 -05:00
parent 475719ec3a
commit f4d84620a1
2 changed files with 10 additions and 2 deletions

5
main.c
View File

@ -437,6 +437,7 @@ usage(void)
printf(" --atleast-pkgconfig-version check whether or not pkgconf is compatible\n");
printf(" with a specified pkg-config version\n");
printf(" --errors-to-stdout print all errors on stdout instead of stderr\n");
printf(" --silence-errors explicitly be silent about errors\n");
printf("\nchecking specific pkg-config database entries:\n\n");
@ -482,6 +483,7 @@ main(int argc, char *argv[])
pkg_queue_t *pkgq_head = NULL;
char *builddir;
int want_errors_on_stdout = 0;
int want_silence_errors = 1;
struct pkg_option options[] = {
{ "version", no_argument, &want_version, 1, },
@ -516,6 +518,7 @@ main(int argc, char *argv[])
{ "max-version", required_argument, NULL, 29, },
{ "ignore-conflicts", no_argument, &want_ignore_conflicts, 30, },
{ "errors-to-stdout", no_argument, &want_errors_on_stdout, 31, },
{ "silence-errors", no_argument, &want_silence_errors, 32, },
{ NULL, 0, NULL, 0 }
};
@ -568,6 +571,8 @@ main(int argc, char *argv[])
error_msgout = stderr;
if (want_errors_on_stdout)
error_msgout = stdout;
if (want_silence_errors)
error_msgout = fopen(PATH_DEV_NULL, "w");
if (want_ignore_conflicts || getenv("PKG_CONFIG_IGNORE_CONFLICTS") != NULL)
global_traverse_flags |= PKGF_SKIP_CONFLICTS;

View File

@ -28,6 +28,9 @@
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include <malloc.h>
# define PATH_DEV_NULL "nul"
#else
# define PATH_DEV_NULL "/dev/null"
#endif
#endif