[sword-devel] Personal Commentary module
DM Smith
dmsmith555 at yahoo.com
Mon Jan 19 09:34:28 MST 2009
On Jan 19, 2009, at 8:56 AM, Karl Kleinpaste wrote:
> DM Smith <dmsmith555 at yahoo.com> writes:
>> on what basis that a module is deemed a Personal Commentary
>
> "ModDrv=RawFiles"
I'm curious about this module type (which JSword does not implement
correctly).
RawFiles is stored as a RawText or RawCom module, but rather than
storing text for a verse reference it stores a number. The number is
sequentially created starting at 0 and is stored in a file name
incfile. Each written verse reference gets the next available number
and creates a file by that number. That is if Exodus 2:3 is the first
written it is given a number of 1. Then if the next is Matt 5:5, it is
given a number of 2. And so forth. Each of these numbers becomes a
file named by that number and the content of the file is the content
for that verse reference. If the verse reference is being rewritten,
it just replaces the content of the file.
(As an aside, I first thought this was strange and that one should
just use RawCom or RawText, but then I realized that re-writing either
of these causes the module to grow via appending replacement text, but
this implementation does not.)
I think there is a *tiny* bug in the code that would never be noticed
by an individual user but when GnomeSword and BibleTime are run on
different CPUs for the same module it might.
In modules/comments/rawfiles/rawfiles.cpp it has the method:
char *RawFiles::getNextFilename() {
static char incfile[255];
long number;
FileDesc *datafile;
sprintf(incfile, "%s/incfile", path);
datafile = FileMgr::getSystemFileMgr()->open(incfile,
FileMgr::RDONLY);
if (datafile->read(&number, 4) != 4)
number = 0;
number++;
FileMgr::getSystemFileMgr()->close(datafile);
datafile = FileMgr::getSystemFileMgr()->open(incfile,
FileMgr::CREAT|FileMgr::WRONLY|FileMgr::TRUNC);
datafile->write(&number, 4);
FileMgr::getSystemFileMgr()->close(datafile);
sprintf(incfile, "%.7ld", number-1);
return incfile;
}
The lines:
datafile->read(&number, 4);
datafile->write(&number, 4);
are suspect to me.
Do they account for the endianness of the CPU-s architecture?
That is, if a GnomeSword user on a non-Intel box migrates their
personal commentary to an Intel architecture, will GnomeSword still be
able to use the module? (Same goes for BibleTime).
In Him,
DM
More information about the sword-devel
mailing list