portability: beware of max () with MSVC

Reported by Maarten De Braekeleer.
https://lists.gnu.org/r/bison-patches/2020-07/msg00080.html

We don't want to use gnulib's min and max macros, since we use
function calls in min/max arguments.

* src/location.c (max_int, min_int): Move to...
* src/system.h: here.
* src/counterexample.c, src/derivation.c: Use max_int instead of max.
This commit is contained in:
Akim Demaille
2020-08-01 19:56:34 +02:00
parent d975c2f76e
commit 977e19840d
4 changed files with 20 additions and 27 deletions

View File

@@ -113,11 +113,6 @@ free_counterexample (counterexample *cex)
free (cex);
}
static int max (int a, int b)
{
return a < b ? b : a;
}
static void
counterexample_print (const counterexample *cex, FILE *out, const char *prefix)
{
@@ -131,8 +126,8 @@ counterexample_print (const counterexample *cex, FILE *out, const char *prefix)
const char *deriv2_label
= cex->shift_reduce ? _("Reduce derivation") : _("Second reduce derivation");
const int width =
max (max (mbswidth (example1_label, 0), mbswidth (example2_label, 0)),
max (mbswidth (deriv1_label, 0), mbswidth (deriv2_label, 0)));
max_int (max_int (mbswidth (example1_label, 0), mbswidth (example2_label, 0)),
max_int (mbswidth (deriv1_label, 0), mbswidth (deriv2_label, 0)));
if (flat)
fprintf (out, " %s%s%*s ", prefix,
example1_label, width - mbswidth (example1_label, 0), "");