summaryrefslogtreecommitdiff
path: root/src/modules/common/zstr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/common/zstr.cpp')
-rw-r--r--src/modules/common/zstr.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/modules/common/zstr.cpp b/src/modules/common/zstr.cpp
index 5b4da64..a745502 100644
--- a/src/modules/common/zstr.cpp
+++ b/src/modules/common/zstr.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * zstr.cpp - code for class 'zStr'- a module that reads compressed text
+ *
+ * zstr.cpp - code for class 'zStr'- a module that reads compressed text
* files and provides lookup and parsing functions based on
* class StrKey
*
+ * $Id: zstr.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -54,11 +56,10 @@ const int zStr::ZDXENTRYSIZE = 8;
* ENT: ipath - path of the directory where data and index files are located.
*/
-zStr::zStr(const char *ipath, int fileMode, long blockCount, SWCompress *icomp)
+zStr::zStr(const char *ipath, int fileMode, long blockCount, SWCompress *icomp, bool caseSensitive) : caseSensitive(caseSensitive)
{
SWBuf buf;
- nl = '\n';
lastoff = -1;
path = 0;
stdstr(&path, ipath);
@@ -144,7 +145,7 @@ void zStr::getKeyFromDatOffset(long ioffset, char **buf) const
datfd->read(*buf, size);
}
(*buf)[size] = 0;
- toupperstr_utf8(*buf, size*2);
+ if (!caseSensitive) toupperstr_utf8(*buf, size*2);
}
else {
*buf = (*buf) ? (char *)realloc(*buf, 1) : (char *)malloc(1);
@@ -201,7 +202,7 @@ signed char zStr::findKeyIndex(const char *ikey, long *idxoff, long away) const
if (*ikey) {
headoff = 0;
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
int keylen = strlen(key);
bool substr = false;
@@ -321,7 +322,7 @@ signed char zStr::findKeyIndex(const char *ikey, long *idxoff, long away) const
*
*/
-void zStr::getText(long offset, char **idxbuf, char **buf) {
+void zStr::getText(long offset, char **idxbuf, char **buf) const {
char *ch;
char *idxbuflocal = 0;
getKeyFromIdxOffset(offset, &idxbuflocal);
@@ -386,7 +387,7 @@ void zStr::getText(long offset, char **idxbuf, char **buf) {
* file.
*/
-void zStr::getCompressedText(long block, long entry, char **buf) {
+void zStr::getCompressedText(long block, long entry, char **buf) const {
__u32 size = 0;
@@ -431,12 +432,13 @@ void zStr::getCompressedText(long block, long entry, char **buf) {
void zStr::setText(const char *ikey, const char *buf, long len) {
+ static const char nl[] = {13, 10};
+
__u32 start, outstart;
__u32 size, outsize;
__s32 endoff;
long idxoff = 0;
__s32 shiftSize;
- static const char nl[] = {13, 10};
char *tmpbuf = 0;
char *key = 0;
char *dbKey = 0;
@@ -446,7 +448,7 @@ void zStr::setText(const char *ikey, const char *buf, long len) {
len = (len < 0) ? strlen(buf) : len;
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
char notFound = findKeyIndex(ikey, &idxoff, 0);
if (!notFound) {
@@ -583,7 +585,10 @@ void zStr::linkEntry(const char *destkey, const char *srckey) {
}
-void zStr::flushCache() {
+void zStr::flushCache() const {
+
+ static const char nl[] = {13, 10};
+
if (cacheBlock) {
if (cacheDirty) {
__u32 start = 0;