From ea8649b108d8d60f9d84516e6a017d6710a835e1 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Mon, 25 Oct 2010 16:49:04 +0200 Subject: [PATCH] * need to revalidate start in any case to be exact. --- libcitadel/lib/hash.c | 6 ++++-- libcitadel/tests/hashlist_test.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libcitadel/lib/hash.c b/libcitadel/lib/hash.c index f6adc2a9b..29f145894 100644 --- a/libcitadel/lib/hash.c +++ b/libcitadel/lib/hash.c @@ -1054,6 +1054,7 @@ int IsInMSetList(MSet *MSetList, long MsgNo) HashList *Hash = (HashList*) MSetList; long HashAt; long EndAt; + long StartAt; if (Hash == NULL) return 0; @@ -1077,15 +1078,16 @@ int IsInMSetList(MSet *MSetList, long MsgNo) HashAt -=1; /* Fetch the actual data */ + StartAt = Hash->LookupTable[HashAt]->Key; MemberPosition = Hash->LookupTable[HashAt]->Position; EndAt = *(long*) Hash->Members[MemberPosition]->Data; - if (EndAt == LONG_MAX) + if ((MsgNo >= StartAt) && (EndAt == LONG_MAX)) return 1; /* no range? */ if (EndAt == 0) return 0; /* inside of range? */ - if (EndAt >= MsgNo) + if ((StartAt <= MsgNo) && (EndAt >= MsgNo)) return 1; return 0; } diff --git a/libcitadel/tests/hashlist_test.c b/libcitadel/tests/hashlist_test.c index e7b929b6b..d7a1e1999 100644 --- a/libcitadel/tests/hashlist_test.c +++ b/libcitadel/tests/hashlist_test.c @@ -176,6 +176,7 @@ Some samples from the original... const char *MSetStrings[] = { + "11:63", "65", "1,65,77", "1:65,77,80:*", @@ -184,8 +185,12 @@ const char *MSetStrings[] = { #define InMSet 0 #define NotInMSet 1 -const long MessageNumbers[4][2][10] = { +const long MessageNumbers[5][2][10] = { /* First MSet */ + { + {11, 59, 63, 0, 0, 0, 0, 0, 0, 0}, /* In */ + {2, 10, 64, 65, 0, 0, 0, 0, 0, 0} /* NotIn */ + }, { {65, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* In */ {1, 64, 66, 0, 0, 0, 0, 0, 0, 0} /* NotIn */ @@ -223,7 +228,7 @@ static void TestMSetHashlist (void) StrBufPlain(MSetStr, MSetStrings[nTest], -1); ParseMSet(&OneMSet, MSetStr); -#ifdef VERBOSE_TEST +//#ifdef VERBOSE_TEST printf("---%s---\n", ChrPtr(MSetStr)); { const char *HashKey; @@ -241,7 +246,7 @@ static void TestMSetHashlist (void) } DeleteHashPos(&at); } -#endif +//#endif j = 0; while (MessageNumbers[nTest][InMSet][j] != 0) @@ -252,6 +257,7 @@ static void TestMSetHashlist (void) ChrPtr(MSetStr), MessageNumbers[nTest][InMSet][j]); CU_FAIL(ChrPtr(Assert)); + printf(ChrPtr(Assert)); } else { @@ -271,6 +277,7 @@ static void TestMSetHashlist (void) ChrPtr(MSetStr), MessageNumbers[nTest][NotInMSet][j]); CU_FAIL(ChrPtr(Assert)); + printf(ChrPtr(Assert)); } else { -- 2.30.2