[sword-svn] r3503 - in trunk/src: keys modules/common modules/lexdict/rawld modules/lexdict/rawld4 modules/lexdict/zld
scribe at crosswire.org
scribe at crosswire.org
Wed Nov 1 03:36:13 MST 2017
Author: scribe
Date: 2017-11-01 03:36:13 -0700 (Wed, 01 Nov 2017)
New Revision: 3503
Modified:
trunk/src/keys/treekeyidx.cpp
trunk/src/modules/common/rawstr.cpp
trunk/src/modules/common/rawstr4.cpp
trunk/src/modules/common/zstr.cpp
trunk/src/modules/lexdict/rawld/rawld.cpp
trunk/src/modules/lexdict/rawld4/rawld4.cpp
trunk/src/modules/lexdict/zld/zld.cpp
Log:
Fixed odd checks for FileMgr::open result to be < 0 instead of FileMgr::open()->getFd() < 0
Modified: trunk/src/keys/treekeyidx.cpp
===================================================================
--- trunk/src/keys/treekeyidx.cpp 2017-11-01 10:36:04 UTC (rev 3502)
+++ trunk/src/keys/treekeyidx.cpp 2017-11-01 10:36:13 UTC (rev 3503)
@@ -62,7 +62,7 @@
buf.setFormatted("%s.dat", path);
datfd = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);
- if (datfd <= 0) {
+ if (!datfd || datfd->getFd() < 0) {
SWLog::getSystemLog()->logError("%d", errno);
error = errno;
}
@@ -332,7 +332,7 @@
__s32 tmp;
__u16 tmp2;
- if (datfd > 0) {
+ if (datfd && datfd->getFd() >= 0) {
datfd->seek(ioffset, SEEK_SET);
@@ -386,21 +386,19 @@
}
node->offset = (__s32)ioffset;
- if (idxfd > 0) {
- if (idxfd->getFd() > 0) {
- idxfd->seek(ioffset, SEEK_SET);
+ if (idxfd && idxfd->getFd() >= 0) {
+ idxfd->seek(ioffset, SEEK_SET);
+ if (idxfd->read(&offset, 4) == 4) {
+ offset = swordtoarch32(offset);
+ error = (error == 77) ? KEYERR_OUTOFBOUNDS : 0;
+ getTreeNodeFromDatOffset(offset, node);
+ }
+ else {
+ idxfd->seek(-4, SEEK_END);
if (idxfd->read(&offset, 4) == 4) {
offset = swordtoarch32(offset);
- error = (error == 77) ? KEYERR_OUTOFBOUNDS : 0;
getTreeNodeFromDatOffset(offset, node);
}
- else {
- idxfd->seek(-4, SEEK_END);
- if (idxfd->read(&offset, 4) == 4) {
- offset = swordtoarch32(offset);
- getTreeNodeFromDatOffset(offset, node);
- }
- }
}
}
return error;
@@ -423,7 +421,7 @@
long datOffset = 0;
__s32 tmp;
- if (idxfd > 0) {
+ if (idxfd && idxfd->getFd() >= 0) {
idxfd->seek(node->offset, SEEK_SET);
if (idxfd->read(&tmp, 4) != 4) {
datOffset = datfd->seek(0, SEEK_END);
@@ -489,7 +487,7 @@
void TreeKeyIdx::saveTreeNode(TreeNode *node) {
long datOffset = 0;
__s32 tmp;
- if (idxfd > 0) {
+ if (idxfd && idxfd->getFd() >= 0) {
idxfd->seek(node->offset, SEEK_SET);
datOffset = datfd->seek(0, SEEK_END);
Modified: trunk/src/modules/common/rawstr.cpp
===================================================================
--- trunk/src/modules/common/rawstr.cpp 2017-11-01 10:36:04 UTC (rev 3502)
+++ trunk/src/modules/common/rawstr.cpp 2017-11-01 10:36:13 UTC (rev 3503)
@@ -74,7 +74,7 @@
buf.setFormatted("%s.dat", path);
datfd = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);
- if (datfd < 0) {
+ if (!datfd || datfd->getFd() < 0) {
SWLog::getSystemLog()->logError("%d", errno);
}
@@ -111,7 +111,7 @@
{
int size;
char ch;
- if (datfd > 0) {
+ if (datfd && datfd->getFd() >= 0) {
datfd->seek(ioffset, SEEK_SET);
for (size = 0; datfd->read(&ch, 1) == 1; size++) {
if ((ch == '\\') || (ch == 10) || (ch == 13))
@@ -145,7 +145,7 @@
{
__u32 offset;
- if (idxfd > 0) {
+ if (idxfd && idxfd->getFd() >= 0) {
idxfd->seek(ioffset, SEEK_SET);
idxfd->read(&offset, 4);
Modified: trunk/src/modules/common/rawstr4.cpp
===================================================================
--- trunk/src/modules/common/rawstr4.cpp 2017-11-01 10:36:04 UTC (rev 3502)
+++ trunk/src/modules/common/rawstr4.cpp 2017-11-01 10:36:13 UTC (rev 3503)
@@ -74,7 +74,7 @@
buf.setFormatted("%s.dat", path);
datfd = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);
- if (datfd < 0) {
+ if (!datfd || datfd->getFd() < 0) {
SWLog::getSystemLog()->logError("%d", errno);
}
@@ -111,7 +111,7 @@
{
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 +145,7 @@
{
__u32 offset;
- if (idxfd > 0) {
+ if ((unsigned long)idxfd > 0) {
idxfd->seek(ioffset, SEEK_SET);
idxfd->read(&offset, 4);
Modified: trunk/src/modules/common/zstr.cpp
===================================================================
--- trunk/src/modules/common/zstr.cpp 2017-11-01 10:36:04 UTC (rev 3502)
+++ trunk/src/modules/common/zstr.cpp 2017-11-01 10:36:13 UTC (rev 3503)
@@ -83,7 +83,7 @@
buf.setFormatted("%s.zdt", path);
zdtfd = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);
- if (datfd <= 0) {
+ if (!datfd || datfd->getFd() < 0) {
SWLog::getSystemLog()->logError("%d", errno);
}
@@ -133,7 +133,7 @@
{
int size;
char ch;
- if (datfd > 0) {
+ if (datfd && datfd->getFd() >= 0) {
datfd->seek(ioffset, SEEK_SET);
for (size = 0; datfd->read(&ch, 1) == 1; size++) {
if ((ch == '\\') || (ch == 10) || (ch == 13))
@@ -167,7 +167,7 @@
{
__u32 offset;
- if (idxfd > 0) {
+ if (idxfd && idxfd->getFd() >= 0) {
idxfd->seek(ioffset, SEEK_SET);
idxfd->read(&offset, 4);
offset = swordtoarch32(offset);
@@ -295,7 +295,7 @@
*idxoff = tryoff;
- if (((laststart != start) || (lastsize != size)) && (start >= 0) && (size))
+ if (((laststart != start) || (lastsize != size)) && size)
away += (away < 0) ? 1 : -1;
}
Modified: trunk/src/modules/lexdict/rawld/rawld.cpp
===================================================================
--- trunk/src/modules/lexdict/rawld/rawld.cpp 2017-11-01 10:36:04 UTC (rev 3502)
+++ trunk/src/modules/lexdict/rawld/rawld.cpp 2017-11-01 10:36:13 UTC (rev 3503)
@@ -189,7 +189,7 @@
long RawLD::getEntryCount() const {
- if (idxfd < 0) return 0;
+ if (!idxfd || idxfd->getFd() < 0) return 0;
return idxfd->seek(0, SEEK_END) / IDXENTRYSIZE;
}
Modified: trunk/src/modules/lexdict/rawld4/rawld4.cpp
===================================================================
--- trunk/src/modules/lexdict/rawld4/rawld4.cpp 2017-11-01 10:36:04 UTC (rev 3502)
+++ trunk/src/modules/lexdict/rawld4/rawld4.cpp 2017-11-01 10:36:13 UTC (rev 3503)
@@ -187,7 +187,7 @@
long RawLD4::getEntryCount() const {
- if (idxfd < 0) return 0;
+ if (!idxfd || idxfd->getFd() < 0) return 0;
return idxfd->seek(0, SEEK_END) / IDXENTRYSIZE;
}
Modified: trunk/src/modules/lexdict/zld/zld.cpp
===================================================================
--- trunk/src/modules/lexdict/zld/zld.cpp 2017-11-01 10:36:04 UTC (rev 3502)
+++ trunk/src/modules/lexdict/zld/zld.cpp 2017-11-01 10:36:13 UTC (rev 3503)
@@ -187,7 +187,7 @@
long zLD::getEntryCount() const
{
- if (idxfd < 0) return 0;
+ if (!idxfd || idxfd->getFd() < 0) return 0;
return idxfd->seek(0, SEEK_END) / IDXENTRYSIZE;
}
More information about the sword-cvs
mailing list