[sword-devel] osis2mod problem
DM Smith
dmsmith at crosswire.org
Tue Mar 17 13:24:44 MST 2009
Gregory Hellings wrote:
>
>
>
>
> On Mar 17, 2009, at 14:08, DM Smith <dmsmith at crosswire.org> wrote:
>
>> Can someone help me fix a bug in osis2mod?
>>
>> The following code works in 1.5.11 to detect whether a verse is in or
>> out of the KJV v11n. This was present before my time, so I don't know
>> whether it was ever proper or whether it is expected to still work.
>>
>> bool isKJVRef(const char *buf) {
>> VerseKey vk, test;
>> vk.AutoNormalize(0);
>> vk.Headings(1); // turn on mod/testmnt/book/chap headings
>> vk.Persist(1);
>> // lets do some tests on the verse --------------
>> vk = buf;
>> test = buf; if (vk.Testament() && vk.Book() && vk.Chapter() &&
>> vk.Verse()) { // if we're not a heading
>> #ifdef DEBUG
>> cout << (const char*)vk << " == " << (const char*)test << endl;
>> #endif
>> return (vk == test);
>> }
>> else return true; // no check if we're a heading... Probably bad.
>> }
>>
>> I've have changed it to use
>> VerseKey *vk = (VerseKey*) module->CreateKey();
>> to create verse keys, but has the same problem.
>
> I'm boy sure you specified exactly what the problem is. Perhaps
> VerseKey could be given the ability to throw an exception on an
> invalid key or have a Boolean test like isValid() or something like
> that to simplify this test for both you and other applications?
Yes, it would be great to have module->isValid("Matt 7:30").
My concern is what other code is depending on the "old" behavior.
Regarding exceptions, the SWORD engine does not throw exceptions.
If I set DEBUG on, with "Matt 7:30" as the input, the output would have
been:
Matt 7:29 == Matt 7:30
(I might have these backward as I am doing it from memory.)
With the current engine it is:
Matt 7:29 == Matt 7:29
More information about the sword-devel
mailing list