summaryrefslogtreecommitdiff
path: root/src/modules/common
diff options
context:
space:
mode:
authorDaniel Glassey <wdg@debian.org>2015-09-07 11:14:57 +0100
committerDaniel Glassey <wdg@debian.org>2015-09-07 11:14:57 +0100
commit7b6c8b08e9d29332dcd0a1029e7421334bfb6f61 (patch)
treedc263ee8b6c923716a8e0fed64756b7af1238dc7 /src/modules/common
parent7a00574163029c0c2b649878c95d5acbd083564a (diff)
Imported Upstream version 1.7.3+dfsg
Diffstat (limited to 'src/modules/common')
-rw-r--r--src/modules/common/bz2comprs.cpp4
-rw-r--r--src/modules/common/rawstr.cpp7
-rw-r--r--src/modules/common/rawstr4.cpp7
-rw-r--r--src/modules/common/rawverse.cpp5
-rw-r--r--src/modules/common/rawverse4.cpp8
-rw-r--r--src/modules/common/swcomprs.cpp4
-rw-r--r--src/modules/common/xzcomprs.cpp4
-rw-r--r--src/modules/common/zipcomprs.cpp4
-rw-r--r--src/modules/common/zverse.cpp54
9 files changed, 56 insertions, 41 deletions
diff --git a/src/modules/common/bz2comprs.cpp b/src/modules/common/bz2comprs.cpp
index 16f6d11..7863e98 100644
--- a/src/modules/common/bz2comprs.cpp
+++ b/src/modules/common/bz2comprs.cpp
@@ -3,9 +3,9 @@
* bz2comprs.cpp - Bzip2Compress, a driver class that provides bzip2
* compression (Burrows–Wheeler with Huffman coding)
*
- * $Id: bz2comprs.cpp 2858 2013-07-08 03:08:10Z chrislit $
+ * $Id: bz2comprs.cpp 3156 2014-04-17 03:50:37Z greg.hellings $
*
- * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2000-2014 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/rawstr.cpp b/src/modules/common/rawstr.cpp
index 788ab6e..12371ab 100644
--- a/src/modules/common/rawstr.cpp
+++ b/src/modules/common/rawstr.cpp
@@ -5,7 +5,7 @@
* and provides lookup and parsing functions based on
* class StrKey
*
- * $Id: rawstr.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ * $Id: rawstr.cpp 3181 2014-04-17 04:27:57Z greg.hellings $
*
* Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -43,7 +43,7 @@ SWORD_NAMESPACE_START
*/
int RawStr::instance = 0;
-char RawStr::nl = '\n';
+const char RawStr::nl = '\n';
const int RawStr::IDXENTRYSIZE = 6;
@@ -372,7 +372,6 @@ void RawStr::doSetText(const char *ikey, const char *buf, long len)
__s32 shiftSize;
__u16 size;
__u16 outsize;
- static const char nl[] = {13, 10};
char *tmpbuf = 0;
char *key = 0;
char *dbKey = 0;
@@ -452,7 +451,7 @@ void RawStr::doSetText(const char *ikey, const char *buf, long len)
datfd->write(outbuf, (int)size);
// add a new line to make data file easier to read in an editor
- datfd->write(&nl, 2);
+ datfd->write(&nl, 1);
idxfd->write(&outstart, 4);
idxfd->write(&outsize, 2);
diff --git a/src/modules/common/rawstr4.cpp b/src/modules/common/rawstr4.cpp
index e2ce899..c88e70d 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 2833 2013-06-29 06:40:28Z chrislit $
+ * $Id: rawstr4.cpp 3181 2014-04-17 04:27:57Z greg.hellings $
*
* Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -44,6 +44,7 @@ SWORD_NAMESPACE_START
*/
int RawStr4::instance = 0;
+const char RawStr4::nl = '\n';
const int RawStr4::IDXENTRYSIZE = 8;
@@ -59,7 +60,6 @@ RawStr4::RawStr4(const char *ipath, int fileMode, bool caseSensitive) : caseSens
{
SWBuf buf;
- nl = '\n';
lastoff = -1;
path = 0;
stdstr(&path, ipath);
@@ -380,7 +380,6 @@ void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
__s32 shiftSize;
__u32 size;
__u32 outsize;
- static const char nl[] = {13, 10};
char *tmpbuf = 0;
char *key = 0;
char *dbKey = 0;
@@ -460,7 +459,7 @@ void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
datfd->write(outbuf, (long)size);
// add a new line to make data file easier to read in an editor
- datfd->write(&nl, 2);
+ datfd->write(&nl, 1);
idxfd->write(&outstart, 4);
idxfd->write(&outsize, 4);
diff --git a/src/modules/common/rawverse.cpp b/src/modules/common/rawverse.cpp
index 5527d38..34fba10 100644
--- a/src/modules/common/rawverse.cpp
+++ b/src/modules/common/rawverse.cpp
@@ -5,6 +5,7 @@
* and provides lookup and parsing functions based on
* class VerseKey
*
+ * $Id: rawverse.cpp 3181 2014-04-17 04:27:57Z greg.hellings $
*
* Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -44,7 +45,7 @@ SWORD_NAMESPACE_START
*/
int RawVerse::instance = 0;
-const char *RawVerse::nl = "\r\n";
+const char RawVerse::nl = '\n';
/******************************************************************************
@@ -193,7 +194,7 @@ void RawVerse::doSetText(char testmt, long idxoff, const char *buf, long len)
textfp[testmt-1]->write(buf, (int)size);
// add a new line to make data file easier to read in an editor
- textfp[testmt-1]->write(nl, 2);
+ textfp[testmt-1]->write(&nl, 1);
}
else {
start = 0;
diff --git a/src/modules/common/rawverse4.cpp b/src/modules/common/rawverse4.cpp
index b87ea0d..100ef6b 100644
--- a/src/modules/common/rawverse4.cpp
+++ b/src/modules/common/rawverse4.cpp
@@ -6,7 +6,7 @@
* and provides lookup and parsing functions based on
* class VerseKey
*
- * $Id: rawverse4.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ * $Id: rawverse4.cpp 3182 2014-04-17 04:28:36Z greg.hellings $
*
* Copyright 2007-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -46,7 +46,7 @@ SWORD_NAMESPACE_START
*/
int RawVerse4::instance = 0;
-const char *RawVerse4::nl = "\r\n";
+const char RawVerse4::nl = '\n';
/******************************************************************************
@@ -131,7 +131,7 @@ void RawVerse4::findOffset(char testmt, long idxoff, long *start, unsigned long
*start = swordtoarch32(tmpStart);
*size = swordtoarch32(tmpSize);
- if (len < 2) {
+ if (len < 4) {
*size = (unsigned long)((*start) ? (textfp[testmt-1]->seek(0, SEEK_END) - (long)*start) : 0); // if for some reason we get an error reading size, make size to end of file
}
}
@@ -195,7 +195,7 @@ void RawVerse4::doSetText(char testmt, long idxoff, const char *buf, long len)
textfp[testmt-1]->write(buf, (int)size);
// add a new line to make data file easier to read in an editor
- textfp[testmt-1]->write(nl, 2);
+ textfp[testmt-1]->write(&nl, 1);
}
else {
start = 0;
diff --git a/src/modules/common/swcomprs.cpp b/src/modules/common/swcomprs.cpp
index 9df8e7d..a9ac72e 100644
--- a/src/modules/common/swcomprs.cpp
+++ b/src/modules/common/swcomprs.cpp
@@ -2,9 +2,9 @@
*
* swcomprs.cpp - a driver class that provides compression utilities
*
- * $Id: swcomprs.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ * $Id: swcomprs.cpp 3175 2014-04-17 04:21:31Z greg.hellings $
*
- * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1996-2014 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/xzcomprs.cpp b/src/modules/common/xzcomprs.cpp
index db8a4a8..513e170 100644
--- a/src/modules/common/xzcomprs.cpp
+++ b/src/modules/common/xzcomprs.cpp
@@ -3,9 +3,9 @@
* xzcomprs.cpp - XzCompress, a driver class that provides xz (LZMA2)
* compression
*
- * $Id: xzcomprs.cpp 2850 2013-07-02 09:57:20Z chrislit $
+ * $Id: xzcomprs.cpp 3156 2014-04-17 03:50:37Z greg.hellings $
*
- * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2000-2014 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/zipcomprs.cpp b/src/modules/common/zipcomprs.cpp
index 3e44abd..28471d8 100644
--- a/src/modules/common/zipcomprs.cpp
+++ b/src/modules/common/zipcomprs.cpp
@@ -3,9 +3,9 @@
* zipcomprs.cpp - ZipCompress, a driver class that provides zlib
* compression
*
- * $Id: zipcomprs.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ * $Id: zipcomprs.cpp 3175 2014-04-17 04:21:31Z greg.hellings $
*
- * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2000-2014 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/zverse.cpp b/src/modules/common/zverse.cpp
index c280d98..cd63eca 100644
--- a/src/modules/common/zverse.cpp
+++ b/src/modules/common/zverse.cpp
@@ -5,7 +5,7 @@
* and provides lookup and parsing functions based on
* class VerseKey for compressed modules
*
- * $Id: zverse.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ * $Id: zverse.cpp 3166 2014-04-17 04:08:45Z greg.hellings $
*
* Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -428,7 +428,11 @@ char zVerse::createModule(const char *ipath, int blockBound, const char *v11n)
{
char *path = 0;
char *buf = new char [ strlen (ipath) + 20 ];
+ char retVal = 0;
FileDesc *fd, *fd2;
+ __s32 offset = 0;
+ __s16 size = 0;
+ VerseKey vk;
stdstr(&path, ipath);
@@ -438,69 +442,81 @@ char zVerse::createModule(const char *ipath, int blockBound, const char *v11n)
sprintf(buf, "%s/ot.%czs", path, uniqueIndexID[blockBound]);
FileMgr::removeFile(buf);
fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
- fd->getFd();
+ if (fd->getFd() < 1) goto erroropen1;
FileMgr::getSystemFileMgr()->close(fd);
sprintf(buf, "%s/nt.%czs", path, uniqueIndexID[blockBound]);
FileMgr::removeFile(buf);
fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
- fd->getFd();
+ if (fd->getFd() < 1) goto erroropen1;
FileMgr::getSystemFileMgr()->close(fd);
sprintf(buf, "%s/ot.%czz", path, uniqueIndexID[blockBound]);
FileMgr::removeFile(buf);
fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
- fd->getFd();
+ if (fd->getFd() < 1) goto erroropen1;
FileMgr::getSystemFileMgr()->close(fd);
sprintf(buf, "%s/nt.%czz", path, uniqueIndexID[blockBound]);
FileMgr::removeFile(buf);
- fd2 = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
- fd2->getFd();
+ fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
+ if (fd->getFd() < 1) goto erroropen1;
FileMgr::getSystemFileMgr()->close(fd);
sprintf(buf, "%s/ot.%czv", path, uniqueIndexID[blockBound]);
FileMgr::removeFile(buf);
fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
- fd->getFd();
+ if (fd->getFd() < 1) goto erroropen1;
sprintf(buf, "%s/nt.%czv", path, uniqueIndexID[blockBound]);
FileMgr::removeFile(buf);
fd2 = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
- fd2->getFd();
+ if (fd2->getFd() < 1) goto erroropen2;
- VerseKey vk;
vk.setVersificationSystem(v11n);
vk.setIntros(true);
- __s32 offset = 0;
- __s16 size = 0;
offset = archtosword32(offset);
size = archtosword16(size);
for (vk = TOP; !vk.popError(); vk++) {
if (vk.getTestament() < 2) {
- fd->write(&offset, 4); //compBufIdxOffset
- fd->write(&offset, 4);
- fd->write(&size, 2);
+ if (fd->write(&offset, 4) != 4) goto writefailure; //compBufIdxOffset
+ if (fd->write(&offset, 4) != 4) goto writefailure;
+ if (fd->write(&size, 2) != 2) goto writefailure;
}
else {
- fd2->write(&offset, 4); //compBufIdxOffset
- fd2->write(&offset, 4);
- fd2->write(&size, 2);
+ if (fd2->write(&offset, 4) != 4) goto writefailure; //compBufIdxOffset
+ if (fd2->write(&offset, 4) != 4) goto writefailure;
+ if (fd2->write(&size, 2) != 2) goto writefailure;
}
}
fd2->write(&offset, 4); //compBufIdxOffset
fd2->write(&offset, 4);
fd2->write(&size, 2);
- FileMgr::getSystemFileMgr()->close(fd);
+ goto cleanup;
+
+erroropen1:
+ retVal = -1;
+ goto cleanup1;
+
+erroropen2:
+ retVal = -1;
+ goto cleanup;
+
+writefailure:
+ retVal = -2;
+
+cleanup:
FileMgr::getSystemFileMgr()->close(fd2);
+cleanup1:
+ FileMgr::getSystemFileMgr()->close(fd);
delete [] path;
delete [] buf;
- return 0;
+ return retVal;
}