From acc9f3b72a481f64f5362d862959f300eb2aa63b Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 6 Apr 2022 10:04:08 -0400 Subject: [PATCH] Move cfgParseOptionalFilterDepend() and add comment block. --- src/config/parse.c | 101 +++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 49 deletions(-) diff --git a/src/config/parse.c b/src/config/parse.c index db2160651..0a2063d96 100644 --- a/src/config/parse.c +++ b/src/config/parse.c @@ -734,55 +734,6 @@ typedef struct CfgParseOptionalRuleState bool required; } CfgParseOptionalRuleState; -static bool -cfgParseOptionalFilterDepend(PackRead *const filter, const Config *const config, const unsigned int optionListIdx) -{ - FUNCTION_TEST_BEGIN(); - FUNCTION_TEST_PARAM(PACK_READ, filter); - FUNCTION_TEST_PARAM_P(VOID, config); - FUNCTION_TEST_PARAM(UINT, optionListIdx); - FUNCTION_TEST_END(); - - // Get the depend option value - const ConfigOption dependId = (ConfigOption)pckReadU32P(filter); - ASSERT(config->option[dependId].index != NULL); - const ConfigOptionValue *const dependValue = &config->option[dependId].index[optionListIdx]; - - // Is the dependency resolved? - bool result = false; - - if (dependValue->set) - { - // If a depend list exists, make sure the value is in the list - if (pckReadNext(filter)) - { - do - { - switch (cfgParseOptionDataType(dependId)) - { - case cfgOptDataTypeBoolean: - result = pckReadBoolP(filter) == dependValue->value.boolean; - break; - - default: - { - ASSERT(cfgParseOptionDataType(dependId) == cfgOptDataTypeStringId); - - if (parseRuleValueStrId[pckReadU32P(filter)] == dependValue->value.stringId) - result = true; - break; - } - } - } - while (pckReadNext(filter)); - } - else - result = true; - } - - FUNCTION_TEST_RETURN(result); -} - static bool cfgParseOptionalRule( CfgParseOptionalRuleState *optionalRules, ParseRuleOptionalType optionalRuleType, ConfigCommand commandId, @@ -1008,6 +959,58 @@ cfgParseOptionalRule( FUNCTION_TEST_RETURN(result); } +/*********************************************************************************************************************************** +Resolve an option dependency +***********************************************************************************************************************************/ +static bool +cfgParseOptionalFilterDepend(PackRead *const filter, const Config *const config, const unsigned int optionListIdx) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(PACK_READ, filter); + FUNCTION_TEST_PARAM_P(VOID, config); + FUNCTION_TEST_PARAM(UINT, optionListIdx); + FUNCTION_TEST_END(); + + // Get the depend option value + const ConfigOption dependId = (ConfigOption)pckReadU32P(filter); + ASSERT(config->option[dependId].index != NULL); + const ConfigOptionValue *const dependValue = &config->option[dependId].index[optionListIdx]; + + // Is the dependency resolved? + bool result = false; + + if (dependValue->set) + { + // If a depend list exists, make sure the value is in the list + if (pckReadNext(filter)) + { + do + { + switch (cfgParseOptionDataType(dependId)) + { + case cfgOptDataTypeBoolean: + result = pckReadBoolP(filter) == dependValue->value.boolean; + break; + + default: + { + ASSERT(cfgParseOptionDataType(dependId) == cfgOptDataTypeStringId); + + if (parseRuleValueStrId[pckReadU32P(filter)] == dependValue->value.stringId) + result = true; + break; + } + } + } + while (pckReadNext(filter)); + } + else + result = true; + } + + FUNCTION_TEST_RETURN(result); +} + /**********************************************************************************************************************************/ const String * cfgParseOptionDefault(ConfigCommand commandId, ConfigOption optionId)