From d50cb4b419375b1ed0ee1d482afec9dac1476783 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Mon, 14 Jun 2021 05:47:27 +0200 Subject: [PATCH 4/4] Introduce fc_tristate_or(). See osdn #42527 --- utility/shared.c | 16 ++++++++++++++++ utility/shared.h | 1 + 2 files changed, 17 insertions(+) diff --git a/utility/shared.c b/utility/shared.c index 51474820e3..de95190cf6 100644 --- a/utility/shared.c +++ b/utility/shared.c @@ -134,6 +134,22 @@ enum fc_tristate fc_tristate_and(enum fc_tristate one, enum fc_tristate two) return TRI_YES; } +/************************************************************************//** + An OR function for fc_tristate. +****************************************************************************/ +enum fc_tristate fc_tristate_or(enum fc_tristate one, enum fc_tristate two) +{ + if (TRI_YES == one || TRI_YES == two) { + return TRI_YES; + } + + if (TRI_MAYBE == one || TRI_MAYBE == two) { + return TRI_MAYBE; + } + + return TRI_NO; +} + /************************************************************************//** Returns a statically allocated string containing a nicely-formatted version of the given number according to the user's locale. (Only diff --git a/utility/shared.h b/utility/shared.h index 7ad51c5a19..90d13c74e9 100644 --- a/utility/shared.h +++ b/utility/shared.h @@ -48,6 +48,7 @@ enum fc_tristate { TRI_NO, TRI_YES, TRI_MAYBE }; enum fc_tristate fc_tristate_and(enum fc_tristate one, enum fc_tristate two); +enum fc_tristate fc_tristate_or(enum fc_tristate one, enum fc_tristate two); #ifndef MAX #define MAX(x,y) (((x)>(y))?(x):(y)) -- 2.30.2