[sword-devel] Feature Complete Perl Interface

Troy A. Griffitts sword-devel@crosswire.org
Sat, 21 Jul 2001 16:54:38 -0700


> Oh, while we're at it, I think I've found a bug (though I could be just
> doing something wrong.  The software does not seem to be able to compare
> verses from books 32 and above (Jonah and above in the Old Testament).
> Specifically, given the following code:
> 
> int VerseIterator::_verse_greater(char * verse1, char * verse2) {
>         if(module->SetKey(verse1)) {
>                 return -1;
>         }
>         SWKey key1 = module->Key();
>         if(module->SetKey(verse2)) {
>                 return -1;
>         }
>         SWKey key2 = module->Key();
>         return key1 > key2;
> }
> 
> The following results occur:
> 
> _verse_greater("James 3:4", "Malachi 4:5"); FALSE
> _verse_greater("James 3:4", "Obadiah 12:21"); TRUE
> _verse_greater("James 3:4", "Jonah 1:1"); FALSE
> 

John,
	This may sound weird, but you may be doing something illegal.  The
module->SetKey method sets the module's key to a new internal VerseKey
(assuming it's a Bible text).  You then grab a reference to the
modules's key.  After this you, again, reset the module's key to a new
value.  What your initial reference is pointing to is undefined.  It may
be deallocated.  It may be the same internal key reset to the new value.

Am I making sense?  You may:

SWKey *key1 = module->Key().clone();


or:

SWKey *key1 = module->CreateKey();
*key1 = verse1;

either way, you'll need to delete key1 before you return from the
method.

	Hope this helps,
		-Troy.

PS.  Please let us know if there is still a comparison bug.