From b3c0a5d86dde8d813afe115ea7cd517e236be4fa Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Mon, 14 Jun 2021 05:47:27 +0200 Subject: [PATCH] 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 c31332611f..4652d8cb9f 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 1ca227c289..cab7d44927 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