[sword-devel] Bug with TOP (duplicate keys)

sword-devel@crosswire.org sword-devel@crosswire.org
Mon, 15 Jul 2002 21:37:26 +0600


I create module test:

[test]
DataPath=./modules/lexdict/rawld/test/test
ModDrv=RawLD
Description=Test LD
Encoding=UTF-8
About=I use this module for testing my GTK+ LD editor.

$ addld -c test
$ addld -a test a
aaa
$ addld -a test b
bbb
$ addld -a test c
ccc

Now the following program gives wrong output (with duplicated A):

Key: A
Key: A
Key: B
Key: C

Program:

#include <cstdlib>
#include <iostream>
#include <swmgr.h>
#include <swld.h>

int main()
{
    SWMgr mgr;
    SWModule *mod = 0;
    for(ModMap::iterator it = mgr.Modules.begin();
	 it != mgr.Modules.end(); it++)
    {
	mod = it->second;
	if(!strcmp(mod->Name(), "test"))
	    break;
    }
    if(!mod) {
	std::cerr << "Cannot find the module" << std::endl;
	exit(EXIT_FAILURE);
    }
    for(*mod=TOP; !mod->Error(); (*mod)++) {
	mod->getRawEntry();
	std::cout << "Key: " << mod->KeyText() << std::endl;
    }
}

-- 
Victor Porton (porton@ex-code.com)