[sword-cvs] sword/src/modules/common rawstr4.cpp,1.18,1.19 zstr.cpp,1.17,1.18
sword@www.crosswire.org
sword@www.crosswire.org
Thu, 27 Feb 2003 00:39:39 -0700
Update of /usr/local/cvsroot/sword/src/modules/common
In directory www:/tmp/cvs-serv29516/src/modules/common
Modified Files:
rawstr4.cpp zstr.cpp
Log Message:
no message
Index: rawstr4.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/common/rawstr4.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** rawstr4.cpp 20 Feb 2003 07:25:20 -0000 1.18
--- rawstr4.cpp 27 Feb 2003 07:39:37 -0000 1.19
***************
*** 96,100 ****
*/
! void RawStr4::getidxbufdat(long ioffset, char **buf) {
int size;
char ch;
--- 96,100 ----
*/
! void RawStr4::getIDXBufDat(long ioffset, char **buf) {
int size;
char ch;
***************
*** 129,133 ****
*/
! void RawStr4::getidxbuf(long ioffset, char **buf)
{
char *trybuf, *targetbuf;
--- 129,133 ----
*/
! void RawStr4::getIDXBuf(long ioffset, char **buf)
{
char *trybuf, *targetbuf;
***************
*** 140,144 ****
offset = swordtoarch32(offset);
! getidxbufdat(offset, buf);
for (trybuf = targetbuf = *buf; *trybuf; trybuf++, targetbuf++) {
*targetbuf = *trybuf;
--- 140,144 ----
offset = swordtoarch32(offset);
! getIDXBufDat(offset, buf);
for (trybuf = targetbuf = *buf; *trybuf; trybuf++, targetbuf++) {
*targetbuf = *trybuf;
***************
*** 163,167 ****
*/
! signed char RawStr4::findoffset(const char *ikey, long *start, unsigned long *size, long away, long *idxoff)
{
char *trybuf, *targetbuf, *key, quitflag = 0;
--- 163,167 ----
*/
! signed char RawStr4::findOffset(const char *ikey, long *start, unsigned long *size, long away, long *idxoff)
{
char *trybuf, *targetbuf, *key, quitflag = 0;
***************
*** 184,188 ****
tryoff = (lastoff == -1) ? headoff + ((((tailoff / 8) - (headoff / 8))) / 2) * 8 : lastoff;
lastoff = -1;
! getidxbuf(tryoff, &trybuf);
if (!*trybuf) { // In case of extra entry at end of idx
--- 184,188 ----
tryoff = (lastoff == -1) ? headoff + ((((tailoff / 8) - (headoff / 8))) / 2) * 8 : lastoff;
lastoff = -1;
! getIDXBuf(tryoff, &trybuf);
if (!*trybuf) { // In case of extra entry at end of idx
***************
*** 276,285 ****
*/
! void RawStr4::preptext(char *buf)
{
! char *to, *from, space = 0, cr = 0, realdata = 0, nlcnt = 0;
!
! for (to = from = buf; *from; from++) {
! switch (*from) {
case 10:
if (!realdata)
--- 276,285 ----
*/
! void RawStr4::prepText(SWBuf &buf)
{
! unsigned int to, from;
! char space = 0, cr = 0, realdata = 0, nlcnt = 0;
! for (to = from = 0; buf[from]; from++) {
! switch (buf[from]) {
case 10:
if (!realdata)
***************
*** 290,294 ****
if (nlcnt > 1) {
// *to++ = nl;
! *to++ = nl;
// nlcnt = 0;
}
--- 290,295 ----
if (nlcnt > 1) {
// *to++ = nl;
! buf[to++] = 10;
! // *to++ = nl[1];
// nlcnt = 0;
}
***************
*** 297,301 ****
if (!realdata)
continue;
! *to++ = nl;
space = 0;
cr = 1;
--- 298,303 ----
if (!realdata)
continue;
! // *to++ = nl[0];
! buf[to++] = 10;
space = 0;
cr = 1;
***************
*** 306,323 ****
if (space) {
space = 0;
! if (*from != ' ') {
! *to++ = ' ';
from--;
continue;
}
}
! *to++ = *from;
}
! *to = 0;
! while (to > (buf+1)) { // remove trailing excess
to--;
! if ((*to == 10) || (*to == ' '))
! *to = 0;
else break;
}
--- 308,325 ----
if (space) {
space = 0;
! if (buf[from] != ' ') {
! buf[to++] = ' ';
from--;
continue;
}
}
! buf[to++] = buf[from];
}
! buf.setSize(to);
! while (to > 1) { // remove trailing excess
to--;
! if ((buf[to] == 10) || (buf[to] == ' '))
! buf.setSize(to);
else break;
}
***************
*** 335,343 ****
*/
! void RawStr4::readtext(long istart, unsigned long *isize, char **idxbuf, char **buf)
{
! char *ch;
char *idxbuflocal = 0;
! getidxbufdat(istart, &idxbuflocal);
long start = istart;
--- 337,345 ----
*/
! void RawStr4::readText(long istart, unsigned long *isize, char **idxbuf, SWBuf &buf)
{
! unsigned int ch;
char *idxbuflocal = 0;
! getIDXBufDat(istart, &idxbuflocal);
long start = istart;
***************
*** 345,374 ****
if (*idxbuf)
delete [] *idxbuf;
- if (*buf)
- delete [] *buf;
- *buf = new char [ ++(*isize) ];
*idxbuf = new char [ (*isize) ];
! memset(*buf, 0, *isize);
lseek(datfd->getFd(), start, SEEK_SET);
! read(datfd->getFd(), *buf, (int)((*isize) - 1));
! for (ch = *buf; *ch; ch++) { // skip over index string
! if (*ch == 10) {
ch++;
break;
}
}
! memmove(*buf, ch, *isize - (unsigned long)(ch-*buf));
!
// resolve link
! if (!strncmp(*buf, "@LINK", 5)) {
! for (ch = *buf; *ch; ch++) { // null before nl
! if (*ch == 10) {
! *ch = 0;
break;
}
}
! findoffset(*buf + 6, &start, isize);
}
else break;
--- 347,375 ----
if (*idxbuf)
delete [] *idxbuf;
*idxbuf = new char [ (*isize) ];
! buf = "";
! buf.setFillByte(0);
! buf.setSize(*isize);
lseek(datfd->getFd(), start, SEEK_SET);
! read(datfd->getFd(), buf.getRawData(), (int)((*isize) - 1));
! for (ch = 0; buf[ch]; ch++) { // skip over index string
! if (buf[ch] == 10) {
ch++;
break;
}
}
! buf = SWBuf(buf.c_str()+ch);
// resolve link
! if (!strncmp(buf.c_str(), "@LINK", 5)) {
! for (ch = 0; buf[ch]; ch++) { // null before nl
! if (buf[ch] == 10) {
! buf[ch] = 0;
break;
}
}
! findOffset(buf.c_str() + 6, &start, isize);
!
}
else break;
***************
*** 394,398 ****
*/
! void RawStr4::setText(const char *ikey, const char *buf, long len) {
long start, outstart;
--- 395,399 ----
*/
! void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
long start, outstart;
***************
*** 410,419 ****
char *ch = 0;
! char errorStatus = findoffset(ikey, &start, &size, 0, &idxoff);
stdstr(&key, ikey);
toupperstr_utf8(key);
len = (len < 0) ? strlen(buf) : len;
! getidxbufdat(start, &dbKey);
if (strcmp(key, dbKey) < 0) {
--- 411,420 ----
char *ch = 0;
! char errorStatus = findOffset(ikey, &start, &size, 0, &idxoff);
stdstr(&key, ikey);
toupperstr_utf8(key);
len = (len < 0) ? strlen(buf) : len;
! getIDXBufDat(start, &dbKey);
if (strcmp(key, dbKey) < 0) {
***************
*** 447,451 ****
}
}
! findoffset(tmpbuf + 8, &start, &size, 0, &idxoff);
++size;
}
--- 448,452 ----
}
}
! findOffset(tmpbuf + 8, &start, &size, 0, &idxoff);
++size;
}
***************
*** 514,521 ****
*/
! void RawStr4::linkentry(const char *destkey, const char *srckey) {
char *text = new char [ strlen(destkey) + 7 ];
sprintf(text, "@LINK %s", destkey);
! setText(srckey, text);
delete [] text;
}
--- 515,522 ----
*/
! void RawStr4::doLinkEntry(const char *destkey, const char *srckey) {
char *text = new char [ strlen(destkey) + 7 ];
sprintf(text, "@LINK %s", destkey);
! doSetText(srckey, text);
delete [] text;
}
Index: zstr.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/common/zstr.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** zstr.cpp 1 Oct 2002 19:52:40 -0000 1.17
--- zstr.cpp 27 Feb 2003 07:39:37 -0000 1.18
***************
*** 283,291 ****
*/
! void zStr::prepText(char *buf) {
! char *to, *from, space = 0, cr = 0, realdata = 0, nlcnt = 0;
!
! for (to = from = buf; *from; from++) {
! switch (*from) {
case 10:
if (!realdata)
--- 283,291 ----
*/
! void zStr::prepText(SWBuf &buf) {
! unsigned int to, from;
! char space = 0, cr = 0, realdata = 0, nlcnt = 0;
! for (to = from = 0; buf[from]; from++) {
! switch (buf[from]) {
case 10:
if (!realdata)
***************
*** 296,300 ****
if (nlcnt > 1) {
// *to++ = nl;
! *to++ = nl;
// nlcnt = 0;
}
--- 296,301 ----
if (nlcnt > 1) {
// *to++ = nl;
! buf[to++] = 10;
! // *to++ = nl[1];
// nlcnt = 0;
}
***************
*** 303,307 ****
if (!realdata)
continue;
! *to++ = nl;
space = 0;
cr = 1;
--- 304,309 ----
if (!realdata)
continue;
! // *to++ = nl[0];
! buf[to++] = 10;
space = 0;
cr = 1;
***************
*** 312,329 ****
if (space) {
space = 0;
! if (*from != ' ') {
! *to++ = ' ';
from--;
continue;
}
}
! *to++ = *from;
}
! *to = 0;
! while (to > (buf+1)) { // remove trailing excess
to--;
! if ((*to == 10) || (*to == ' '))
! *to = 0;
else break;
}
--- 314,331 ----
if (space) {
space = 0;
! if (buf[from] != ' ') {
! buf[to++] = ' ';
from--;
continue;
}
}
! buf[to++] = buf[from];
}
! buf.setSize(to);
! while (to > 1) { // remove trailing excess
to--;
! if ((buf[to] == 10) || (buf[to] == ' '))
! buf.setSize(to);
else break;
}