mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 23:03:04 +00:00
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:
@@ -135,12 +135,6 @@ derivation_size (const derivation *deriv)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
max (int a, int b)
|
||||
{
|
||||
return a < b ? b : a;
|
||||
}
|
||||
|
||||
// Longest distance from root to leaf.
|
||||
static int
|
||||
derivation_depth (const derivation *deriv)
|
||||
@@ -154,7 +148,7 @@ derivation_depth (const derivation *deriv)
|
||||
for (gl_list_iterator_t it = gl_list_iterator (deriv->children);
|
||||
derivation_list_next (&it, &child);
|
||||
)
|
||||
res = max (res, derivation_depth (child));
|
||||
res = max_int (res, derivation_depth (child));
|
||||
return res + 1;
|
||||
}
|
||||
else
|
||||
@@ -237,7 +231,7 @@ derivation_width (const derivation *deriv)
|
||||
// No separator at the beginning.
|
||||
children_width -= derivation_separator_width;
|
||||
}
|
||||
return max (self_width, children_width);
|
||||
return max_int (self_width, children_width);
|
||||
}
|
||||
else if (deriv == &d_dot)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user