[sword-devel] Odd behavior in ListKey

DM Smith dmsmith at crosswire.org
Thu Jun 19 10:33:12 EDT 2025


Troy,
Thanks for your reply!
DM

> [dmsmith at host testsuite]$ ./runall.sh 
> gbs_basic: PASSED.
> greekaccents: PASSED.
> ldr12n: PASSED.
> listtest: PASSED.
> osis_basic: PASSED.
> osis_mod2zmod: PASSED.
> osis_osis2modcipher: PASSED.
> utf8basic: PASSED.
> versekeytest: PASSED.
> versemgrtest: PASSED.
> verseparsing: PASSED.
> verseparsing-utf8: PASSED.
> vs2osisref: PASSED.
> xmltag: PASSED.
> ALL PASSED!


> On Jun 19, 2025, at 7:44 AM, Troy A. Griffitts <scribe at crosswire.org> wrote:
> 
> DM,
> 
> Sorry for the late reply and thank you for tracking this down.  Yes!  This looks like a reasonable solution.  Please feel free to commit if all the sword/tests/testsuite/run-all.sh returns no problems with your change.
> 
> It's been a bit crazy these days and I haven't been able to keep up with all the great stuff going on here.
> 
> Troy
> 
> 
> 
> On 6/16/25 9:27 PM, DM Smith wrote:
>> Troy,
>> In VerseKey::checkBounds()
>> void VerseKey::checkBounds() {
>> 
>>         long i = getIndex();
>> 
>>         initBounds();
>>         if (i > upperBound) {
>>                 setIndex(upperBound);
>>                 i = getIndex();
>>                 error = KEYERR_OUTOFBOUNDS;
>>         }
>>         if (i < lowerBound) {
>>                 setIndex(lowerBound);
>>                 error = KEYERR_OUTOFBOUNDS;
>>         }
>> }
>> 
>> i, upperBound and lowerBound are all -1, when working with a chapter that is not in the book. This is good. The proc getIndex() can’t compute the index since the chapter is not known so it rightfully returns -1.
>> 
>> I think there should be a check in here like there is in VerseKey.setIndex(int iindex).
>> 
>> So
>> void VerseKey::checkBounds() {
>> 
>>         long i = getIndex();
>> 
>>         // assert we're sane
>>         if (i < 0) {
>>                 error = KEYERR_OUTOFBOUNDS;
>>                 return;
>>         }
>> 
>>         initBounds();
>>         if (i > upperBound) {
>>                 setIndex(upperBound);
>>                 i = getIndex();
>>                 error = KEYERR_OUTOFBOUNDS;
>>         }
>>         if (i < lowerBound) {
>>                 setIndex(lowerBound);
>>                 error = KEYERR_OUTOFBOUNDS;
>>         }
>> }
>> 
>> What do you think?
>> 
>> DM
>> 
>>> On Jun 15, 2025, at 8:11 AM, DM Smith <dmsmith at crosswire.org> <mailto:dmsmith at crosswire.org> wrote:
>>> 
>>> Troy,
>>> 
>>> I’ve narrowed it down to turning Auto Normalize off.
>>> 
>>> In examples/cmdline/parseverselist.cpp, add parser.setAutoNormalize(false) to see the error with Gen.51.1. Note Gen.50.99 (last chapter with bad verse number) works.
>>> 
>>> DM
>>> 
>>>> On Jun 12, 2025, at 7:03 PM, DM Smith <dmsmith at crosswire.org> <mailto:dmsmith at crosswire.org> wrote:
>>>> 
>>>> Troy,
>>>> 
>>>> I’m working on an infinite loop bug in osis2mod.
>>>> 
>>>> I’ve narrowed it down to ListKey containing a verse with a chapter which is beyond the end of a book.
>>>> 
>>>> When this happens list.increment(1) never sets an error.
>>>> 
>>>> Simplest test case (bit incomplete):
>>>> 
>>>> int i = 0;
>>>> ListKey list = new ListKey();
>>>> list.add(“Gen.51.1”);
>>>> for (list = TOP; !list.popError(); list.increment(1)) {
>>>> 	if (i++ > 5) break;
>>>> 	cout << i << list << endl;
>>>> }
>>>> 
>>>> If I change the verse reference to Gen.1.99 (valid chapter, invalid verse), it works as expected.
>>>> 
>>>> Can you figure out the problem?
>>>> 
>>>> I’ve got a work around but I’d rather not do that.
>>>> 
>>>> Thanks,
>>>> 	DM
>>>> 
>>>> _______________________________________________
>>>> sword-devel mailing list: sword-devel at crosswire.org <mailto:sword-devel at crosswire.org>
>>>> http://crosswire.org/mailman/listinfo/sword-devel
>>>> Instructions to unsubscribe/change your settings at above page
>>> 
>>> _______________________________________________
>>> sword-devel mailing list: sword-devel at crosswire.org <mailto:sword-devel at crosswire.org>
>>> http://crosswire.org/mailman/listinfo/sword-devel
>>> Instructions to unsubscribe/change your settings at above page
>> 
>> 
>> 
>> _______________________________________________
>> sword-devel mailing list: sword-devel at crosswire.org <mailto:sword-devel at crosswire.org>
>> http://crosswire.org/mailman/listinfo/sword-devel
>> Instructions to unsubscribe/change your settings at above page
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://crosswire.org/pipermail/sword-devel/attachments/20250619/0ba985c9/attachment-0001.htm>


More information about the sword-devel mailing list