* need to revalidate start in any case to be exact.
authorWilfried Goesgens <dothebart@citadel.org>
Mon, 25 Oct 2010 14:49:04 +0000 (16:49 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Mon, 25 Oct 2010 14:49:04 +0000 (16:49 +0200)
libcitadel/lib/hash.c
libcitadel/tests/hashlist_test.c

index f6adc2a9b43b649e6740505f47e1d642b4559068..29f145894218e6b8b5d85713db4ea7bdbba6df27 100644 (file)
@@ -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;
 }
index e7b929b6bad4afca10e57448865d4deb41147d6c..d7a1e19996e1c504c05b1149d866e33613de5ce1 100644 (file)
@@ -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
                        {