[sword-devel] Use of SWBuf for config paths

Will Thimbleby sword-devel@crosswire.org
Sat, 6 Sep 2003 00:43:45 +0100


Hi,

I use modules in a funny way in MacSword, they can be placed anywhere 
on the disk. (Allows drag and drop installation and makes it easier for 
novices) And because of this I've run into problems in some of the 
sword lib code, namely that the library uses char[127] to store path 
names in the files listed below. My config paths exceed the 127 limit 
and MacSword crashes.

treekeyidx.cpp
rawstr.cpp
rawstr4.cpp
zstr.cpp
zverse.cpp

I reworked the code so that it used SWBuf instead.

Changing

> RawStr::RawStr(const char *ipath, int fileMode)
> {
> 	char	buf[127];
>
> 	...
> 	
> 	sprintf(buf, "%s.idx", path);
> 	idxfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);

into:

> RawStr::RawStr(const char *ipath, int fileMode)
> {
> 	SWBuf	buf;
>
> 	...
> 	
> 	buf = path;
> 	buf += ".idx";
> 	idxfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);

This fixes my problems, would it be possible if these changes could be 
incorporated into the sword library. If you are happy letting me do it 
my user name is willthimbleby.

Also whilst I'm at it, it would be usefull if the augmentModules method 
for SWMgr could be made public (unless someone tells me I really 
shouldn't touch it).

Cheers -Will