[sword-devel] BibleTime indexing problem
Gary Holmlund
gary.holmlund at gmail.com
Thu Mar 1 22:30:00 MST 2012
On 02/28/2012 08:21 AM, Troy A. Griffitts wrote:
> So, a little background.
>
> SWORD keys handle versification + 4 special slots:
>
> chapter intro
> book intro
> testament intro
> module intro
>
> These are positioned respectively using, for example starting with
> John 3:16
>
> VerseKey k("John 3:16");
>
> k.setVerse(0); // chapter intro
> k.setChapter(0); // book intro
> k.setBook(0); // testament intro
> k.setTestament(0); module intro
>
> If you try to output the key when positioned to any of these 4 special
> locations, you will get:
>
> John 3:0
> John 0:0
> [ Testament 2 Heading ]
> [ Module Heading ]
>
>
> It is important for our verse parser to be able to parse anything
> which it outputs. Thus the special cases for the magic strings which
> you note below.
>
> I don't think the module having any special text/absence or presence
> of headers has anything to do with the problem; the key itself doesn't
> know about the module content.
>
>
> Can you show a simple snippet which fails that I might try to debug?
>
> I have created a small test program, and have added it to the examples
> folder, which tests the functionality and it seems to work for me, but
> I am using SVN HEAD. Maybe you could try this program in your
> environment:
>
> http://crosswire.org/svn/sword/trunk/examples/classes/verseposition.cpp
>
> Hope we can get this fixed for you,
>
> Troy
Troy
The closest program that does what BibleTime does at the beginning of
the indexing is this:
#include <iostream>
#include <swmgr.h>
#include <swmodule.h>
#include <versekey.h>
using namespace sword;
using namespace std;
int main(int argc, char **argv) {
const char *modName = "HunKar";
SWMgr library;
SWModule *book = library.getModule(modName);
if (!book) {
cerr << "Can't find module: " << modName << endl;
return -1;
}
book->setPosition(TOP);
return 0;
}
However, this program does not have the problem BibleTime is having. It
seems that some other condition about the module is different between
the two cases, but I have not been able to discover what it is.
I have debugged down into the setPosition function until I see a
difference. Perhaps if I explain that difference it will mean something
to you.
call stack
1 sword::zText::increment ztext.cpp 178 0xb7f001a5
2 sword::zText::decrement ztext.h 65 0xb7f004f1
3 sword::SWModule::operator-= swmodule.h 674 0x815299f
4 sword::SWModule::operator-- swmodule.h 674 0x81529ff
5 sword::SWModule::setPosition swmodule.cpp 368 0xb7ea81c9
6 CSwordModuleInfo::buildIndex cswordmoduleinfo.cpp 262 0x813aa07
I get down to the increment function when I see the difference. The
function begins like this:
void zText::increment(int steps) {
long start;
unsigned short size;
unsigned long buffnum;
VerseKey *tmpkey = &getVerseKey();
The values for tmpkey are different and in BibleTime we hit the error
condition a little farther into the function:
if ((error = key->Error())) {
*key = lastgood;
break;
For the test program tmpkey looks like this:
thisKey sword::VerseKey
sword::SWKey sword::SWKey
BMAX @0x8116e24 int [2]
autonorm 1 char
book 1 signed char
chapter 1 int
headings 0 '\0' char
internalListKey sword::ListKey
lowerBound 0 long
lowerBoundComponents
sword::VerseKey::VerseComponents
refSys @0x806a7fc sword::VerseMgr::System
suffix 0 '\0' signed char
testament 1 signed char
tmpClone @0x8129db8 sword::VerseKey
upperBound 32359 long
upperBoundComponents
sword::VerseKey::VerseComponents
verse 2 int
For BibleTime tmpkey looks like this:
tmpkey @0x843cc40 sword::VerseKey
sword::SWKey sword::SWKey
BMAX @0x843cce4 int [2]
autonorm 1 char
book 0 '\0' signed char
chapter 0 int
headings 1 char
internalListKey sword::ListKey
lowerBound 0 long
lowerBoundComponents
sword::VerseKey::VerseComponents
refSys @0x843c08c sword::VerseMgr::System
suffix 0 '\0' signed char
testament 1 signed char
tmpClone @0x863a790 sword::VerseKey
upperBound 32359 long
upperBoundComponents
sword::VerseKey::VerseComponents
verse 0 int
I suspect that the book, chapter, and headings values being different
are causing the problem. Do you have any thoughts on this?
Gary
More information about the sword-devel
mailing list