From b36acd10bfa182cba577104eade6a7d31546d904 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 7 Apr 2007 12:08:57 +0200 Subject: [PATCH] evalue_convert: add verbose argument and return 1 if something was printed This allows the use of conversions that only print something (--list) without specifying --verbose. --- barvinok_enumerate.cc | 7 ++++--- barvinok_enumerate_e.cc | 7 ++++--- evalue_convert.cc | 13 +++++++++---- evalue_convert.h | 4 ++-- maximize.cc | 2 +- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/barvinok_enumerate.cc b/barvinok_enumerate.cc index d0a7d80..69db7b5 100644 --- a/barvinok_enumerate.cc +++ b/barvinok_enumerate.cc @@ -509,12 +509,13 @@ int main(int argc, char **argv) } } else { EP = barvinok_enumerate_with_options(A, C, bv_options); - evalue_convert(EP, &options.convert, C->Dimension, - options.verbose ? param_name : NULL); + if (evalue_convert(EP, &options.convert, options.verbose, C->Dimension, + param_name)) + print_solution = 0; if (options.size) printf("\nSize: %d\n", evalue_size(EP)); } - if (print_solution && !options.verbose) + if (print_solution) print_evalue(stdout, EP, param_name); if (options.verify.verify) { diff --git a/barvinok_enumerate_e.cc b/barvinok_enumerate_e.cc index 051b2a1..8155c11 100644 --- a/barvinok_enumerate_e.cc +++ b/barvinok_enumerate_e.cc @@ -184,9 +184,10 @@ int main(int argc, char **argv) else EP = barvinok_enumerate_e_with_options(A, exist, nparam, options); reduce_evalue(EP); - evalue_convert(EP, &arguments.convert, nparam, - arguments.verbose ? param_name : NULL); - if (print_solution && !arguments.verbose) + if (evalue_convert(EP, &arguments.convert, arguments.verbose, nparam, + param_name)) + print_solution = 0; + if (print_solution) print_evalue(stdout, EP, param_name); if (arguments.verify.verify) { arguments.verify.params = param_name; diff --git a/evalue_convert.cc b/evalue_convert.cc index 098059f..26db98d 100644 --- a/evalue_convert.cc +++ b/evalue_convert.cc @@ -202,15 +202,18 @@ static void evalue_print_list(FILE *out, evalue *e, int nparam, char **params) } } -void evalue_convert(evalue *EP, struct convert_options *options, unsigned nparam, - char **params) +int evalue_convert(evalue *EP, struct convert_options *options, + int verbose, unsigned nparam, char **params) { + int printed = 0; if (options->combine) evalue_combine(EP); if (options->range) evalue_range_reduction(EP); - if (params) + if (verbose) { print_evalue(stdout, EP, params); + printed = 1; + } if (options->floor) { fprintf(stderr, "WARNING: floor conversion not supported\n"); evalue_frac2floor2(EP, 0); @@ -218,9 +221,11 @@ void evalue_convert(evalue *EP, struct convert_options *options, unsigned nparam print_evalue(stdout, EP, params); } else if (options->list && params) { evalue_print_list(stdout, EP, nparam, params); + printed = 1; } else if (options->convert) { evalue_mod2table(EP, nparam); - if (params) + if (verbose) print_evalue(stdout, EP, params); } + return printed; } diff --git a/evalue_convert.h b/evalue_convert.h index be2528e..ea82d77 100644 --- a/evalue_convert.h +++ b/evalue_convert.h @@ -16,8 +16,8 @@ struct convert_options { int list; }; -void evalue_convert(evalue *EP, struct convert_options *options, unsigned nparam, - char **params); +int evalue_convert(evalue *EP, struct convert_options *options, + int verbose, unsigned nparam, char **params); extern struct argp convert_argp; diff --git a/maximize.cc b/maximize.cc index d21ce0b..7931748 100644 --- a/maximize.cc +++ b/maximize.cc @@ -1160,7 +1160,7 @@ int main(int argc, char **argv) if (options.split) evalue_split_periods(EP, options.split, bv_options->MaxRays); - evalue_convert(EP, &options.convert, nparam, options.verbose ? all_vars : NULL); + evalue_convert(EP, &options.convert, options.verbose, nparam, all_vars); if (EVALUE_IS_ZERO(*EP)) print_evalue(stdout, EP, all_vars); -- 2.11.4.GIT