summaryrefslogtreecommitdiff
path: root/src/modules/common/rawstr4.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/common/rawstr4.cpp')
-rw-r--r--src/modules/common/rawstr4.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/modules/common/rawstr4.cpp b/src/modules/common/rawstr4.cpp
index c88e70d..0b54c00 100644
--- a/src/modules/common/rawstr4.cpp
+++ b/src/modules/common/rawstr4.cpp
@@ -5,7 +5,7 @@
* and provides lookup and parsing functions based on
* class StrKey
*
- * $Id: rawstr4.cpp 3181 2014-04-17 04:27:57Z greg.hellings $
+ * $Id: rawstr4.cpp 3524 2017-11-07 03:08:49Z scribe $
*
* Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -74,8 +74,10 @@ RawStr4::RawStr4(const char *ipath, int fileMode, bool caseSensitive) : caseSens
buf.setFormatted("%s.dat", path);
datfd = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);
- if (datfd < 0) {
- SWLog::getSystemLog()->logError("%d", errno);
+ if (!datfd || datfd->getFd() < 0) {
+ // couldn't find datafile but this might be fine if we're
+ // merely instantiating a remote InstallMgr SWMgr
+ SWLog::getSystemLog()->logDebug("Couldn't open file: %s. errno: %d", buf.c_str(), errno);
}
instance++;
@@ -111,7 +113,7 @@ void RawStr4::getIDXBufDat(long ioffset, char **buf) const
{
int size;
char ch;
- if (datfd > 0) {
+ if ((unsigned long)datfd > 0) {
datfd->seek(ioffset, SEEK_SET);
for (size = 0; datfd->read(&ch, 1) == 1; size++) {
if ((ch == '\\') || (ch == 10) || (ch == 13))
@@ -145,7 +147,7 @@ void RawStr4::getIDXBuf(long ioffset, char **buf) const
{
__u32 offset;
- if (idxfd > 0) {
+ if ((unsigned long)idxfd > 0) {
idxfd->seek(ioffset, SEEK_SET);
idxfd->read(&offset, 4);
@@ -193,9 +195,9 @@ signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, lon
headoff = 0;
stdstr(&key, ikey, 3);
- if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, (unsigned int)(strlen(key)*3));
- int keylen = strlen(key);
+ int keylen = (int)strlen(key);
bool substr = false;
trybuf = maxbuf = 0;
@@ -252,7 +254,7 @@ signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, lon
idxfd->read(&tmpStart, 4);
idxfd->read(&tmpSize, 4);
if (idxoff)
- *idxoff = tryoff;
+ *idxoff = (__u32)tryoff;
*start = swordtoarch32(tmpStart);
*size = swordtoarch32(tmpSize);
@@ -271,17 +273,17 @@ signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, lon
if (bad) {
if(!awayFromSubstrCheck)
retval = -1;
- *start = laststart;
- *size = lastsize;
+ *start = (__u32)laststart;
+ *size = (__u32)lastsize;
tryoff = lasttry;
if (idxoff)
- *idxoff = tryoff;
+ *idxoff = (__u32)tryoff;
break;
}
idxfd->read(&tmpStart, 4);
idxfd->read(&tmpSize, 4);
if (idxoff)
- *idxoff = tryoff;
+ *idxoff = (__u32)tryoff;
*start = swordtoarch32(tmpStart);
*size = swordtoarch32(tmpSize);
@@ -355,7 +357,7 @@ void RawStr4::readText(__u32 istart, __u32 *isize, char **idxbuf, SWBuf &buf) co
while (true); // while we're resolving links
if (idxbuflocal) {
- unsigned int localsize = strlen(idxbuflocal);
+ unsigned int localsize = (unsigned int)strlen(idxbuflocal);
localsize = (localsize < (*isize - 1)) ? localsize : (*isize - 1);
strncpy(*idxbuf, idxbuflocal, localsize);
(*idxbuf)[localsize] = 0;
@@ -389,7 +391,7 @@ void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
char errorStatus = findOffset(ikey, &start, &size, 0, &idxoff);
stdstr(&key, ikey, 3);
- if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, (unsigned int)(strlen(key)*3));
len = (len < 0) ? strlen(buf) : len;
getIDXBufDat(start, &dbKey);
@@ -432,7 +434,7 @@ void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
while (true); // while we're resolving links
}
- endoff = idxfd->seek(0, SEEK_END);
+ endoff = (__u32)idxfd->seek(0, SEEK_END);
shiftSize = endoff - idxoff;
@@ -446,9 +448,9 @@ void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
sprintf(outbuf, "%s%c%c", key, 13, 10);
size = strlen(outbuf);
memcpy(outbuf + size, buf, len);
- size = outsize = size + len;
+ size = outsize = size + (__u32)len;
- start = outstart = datfd->seek(0, SEEK_END);
+ start = outstart = (__u32)datfd->seek(0, SEEK_END);
outstart = archtosword32(start);
outsize = archtosword32(size);