From 7d5a540a2f24af44f3417c234a53e8d0bf87279b Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Tue, 29 Dec 2020 16:21:00 +0800 Subject: [PATCH] INI_FIND_ITEM just break instead of return --- HISTORY | 3 ++- src/ini_file_reader.c | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/HISTORY b/HISTORY index 3d23133..6359c1d 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,7 @@ -Version 1.46 2020-12-28 +Version 1.46 2020-12-29 * add function get_time_item_from_conf_ex + * INI_FIND_ITEM just break instead of return Version 1.45 2020-12-24 * add function uniq_skiplist_find_node_ex diff --git a/src/ini_file_reader.c b/src/ini_file_reader.c index a4afb84..1139e92 100644 --- a/src/ini_file_reader.c +++ b/src/ini_file_reader.c @@ -2781,8 +2781,8 @@ void iniFreeContext(IniContext *pContext) iniFreeDynamicContent(pContext); } -#define INI_FIND_ITEM(szSectionName, szItemName, pContext, pSection, \ - targetItem, pItem, return_val) \ +#define INI_FIND_ITEM(szSectionName, szItemName, \ + pContext, pSection, targetItem, pItem) \ do { \ if (szSectionName == NULL || *szSectionName == '\0') \ { \ @@ -2794,13 +2794,15 @@ do { \ szSectionName, strlen(szSectionName)); \ if (pSection == NULL) \ { \ - return return_val; \ + pItem = NULL; \ + break; \ } \ } \ \ if (pSection->count <= 0) \ { \ - return return_val; \ + pItem = NULL; \ + break; \ } \ \ snprintf(targetItem.name, sizeof(targetItem.name), "%s", szItemName); \ @@ -2818,15 +2820,15 @@ char *iniGetStrValueEx(const char *szSectionName, const char *szItemName, IniItem *pItem; IniItem *pItemEnd; - INI_FIND_ITEM(szSectionName, szItemName, pContext, pSection, - targetItem, pFound, NULL); + INI_FIND_ITEM(szSectionName, szItemName, pContext, + pSection, targetItem, pFound); if (pFound == NULL) { if (RETRY_FETCH_GLOBAL(szSectionName, bRetryGlobal)) { szSectionName = NULL; INI_FIND_ITEM(szSectionName, szItemName, pContext, - pSection, targetItem, pFound, NULL); + pSection, targetItem, pFound); if (pFound == NULL) { return NULL; @@ -3060,7 +3062,7 @@ int iniGetValues(const char *szSectionName, const char *szItemName, \ return count; } -IniItem *iniGetValuesEx(const char *szSectionName, const char *szItemName, \ +IniItem *iniGetValuesEx(const char *szSectionName, const char *szItemName, IniContext *pContext, int *nTargetCount) { IniItem targetItem; @@ -3071,8 +3073,8 @@ IniItem *iniGetValuesEx(const char *szSectionName, const char *szItemName, \ IniItem *pItemStart; *nTargetCount = 0; - INI_FIND_ITEM(szSectionName, szItemName, pContext, pSection, \ - targetItem, pFound, NULL); + INI_FIND_ITEM(szSectionName, szItemName, pContext, + pSection, targetItem, pFound); if (pFound == NULL) { return NULL;