aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--apps/windoze/CBuilder5/BibleCS/AboutBoxfrm.dfm4
-rw-r--r--apps/windoze/CBuilder5/BibleCS/biblecsmgr.cpp3
-rw-r--r--apps/windoze/CBuilder5/BibleCS/mainfrm.cpp9
-rw-r--r--apps/windoze/CBuilder5/BibleCS/sword.bpr22
-rw-r--r--apps/windoze/CBuilder5/BibleCS/sword.resbin1972 -> 1972 bytes
-rw-r--r--apps/windoze/CBuilder5/BibleCS/swordlib.bpr16
-rw-r--r--examples/cmdline/search.cpp16
-rw-r--r--include/rawcom.h10
-rw-r--r--include/rawtext.h11
-rw-r--r--include/zcom.h15
-rw-r--r--include/ztext.h10
-rw-r--r--src/keys/treekeyidx.cpp6
-rw-r--r--src/modules/comments/rawcom/rawcom.cpp98
-rw-r--r--src/modules/comments/zcom/zcom.cpp103
-rw-r--r--src/modules/common/rawstr.cpp2
-rw-r--r--src/modules/texts/rawtext/rawtext.cpp118
-rw-r--r--src/modules/texts/ztext/ztext.cpp119
-rw-r--r--src/utilfuns/zlib/infcodes.c214
-rw-r--r--src/utilfuns/zlib/inffast.c196
-rwxr-xr-xusrinst.sh5
21 files changed, 431 insertions, 551 deletions
diff --git a/ChangeLog b/ChangeLog
index 1d8e077..05165af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
API ChangeLog (see the ChangeLog in each 'apps' directory for
app specific changes
+
+20-Oct-2002 Troy A. Griffitts <scribe@crosswire.org>
+ Added optimizations for ListKey persistent keys
+ in VerseKey drivers
+
09-Oct-2002 Daniel Glassey <dglassey@crosswire.org>
Add debian directory so you can build debs from cvs
diff --git a/apps/windoze/CBuilder5/BibleCS/AboutBoxfrm.dfm b/apps/windoze/CBuilder5/BibleCS/AboutBoxfrm.dfm
index 6863fa0..d8adede 100644
--- a/apps/windoze/CBuilder5/BibleCS/AboutBoxfrm.dfm
+++ b/apps/windoze/CBuilder5/BibleCS/AboutBoxfrm.dfm
@@ -1,6 +1,6 @@
object AboutBox: TAboutBox
- Left = 296
- Top = 109
+ Left = 313
+ Top = 111
BorderStyle = bsDialog
Caption = 'About The SWORD Project'
ClientHeight = 448
diff --git a/apps/windoze/CBuilder5/BibleCS/biblecsmgr.cpp b/apps/windoze/CBuilder5/BibleCS/biblecsmgr.cpp
index 54859d4..83a7940 100644
--- a/apps/windoze/CBuilder5/BibleCS/biblecsmgr.cpp
+++ b/apps/windoze/CBuilder5/BibleCS/biblecsmgr.cpp
@@ -110,7 +110,8 @@ signed char BibleCSMGR::Load () {
};
void BibleCSMGR::applyUserPrefs() {
- (*config) += (*userPrefs);
+ if ((config) && (userPrefs))
+ (*config) += (*userPrefs);
}
void BibleCSMGR::AddGlobalOptions (SWModule * module, ConfigEntMap & section,
diff --git a/apps/windoze/CBuilder5/BibleCS/mainfrm.cpp b/apps/windoze/CBuilder5/BibleCS/mainfrm.cpp
index bc54534..e4eab26 100644
--- a/apps/windoze/CBuilder5/BibleCS/mainfrm.cpp
+++ b/apps/windoze/CBuilder5/BibleCS/mainfrm.cpp
@@ -964,8 +964,15 @@ void __fastcall TForm1::FormShow(TObject *Sender)
DefaultStrKey->Persist(1);
*DefaultStrKey = "";
- mainmgr = new BibleCSMGR(ModInstFrm);
+ try {
+ mainmgr = new BibleCSMGR(ModInstFrm);
+ }
+ catch (...) {
+ Application->Terminate();
+ }
+ if (!mainmgr->config)
+ Application->Terminate();
// Load devotion and show form
for (it = mainmgr->Modules.begin(); it != mainmgr->Modules.end(); it++) {
diff --git a/apps/windoze/CBuilder5/BibleCS/sword.bpr b/apps/windoze/CBuilder5/BibleCS/sword.bpr
index ac9ee50..120e95b 100644
--- a/apps/windoze/CBuilder5/BibleCS/sword.bpr
+++ b/apps/windoze/CBuilder5/BibleCS/sword.bpr
@@ -43,7 +43,7 @@
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
<RELEASELIBPATH value="$(BCB)\lib\release"/>
<LINKER value="ilink32"/>
- <USERDEFINES value="_ICU_;_ICUSWORD_;USBINARY"/>
+ <USERDEFINES value="_ICU_;_ICUSWORD_;USBINARY;_DEBUG"/>
<SYSDEFINES value="NO_STRICT"/>
<MAINSOURCE value="sword.cpp"/>
<INCLUDEPATH value="TntUnicodeControls;..\..;..\..\..\..\..\icu-sword\source\common;..\..\..\..\..\icu-sword\source\i18n;..\..\..\..\include;$(BCB)\include;$(BCB)\include\vcl;rxlib"/>
@@ -55,16 +55,16 @@
<IDLCFLAGS value="-I..\.. -I..\..\..\..\..\icu-sword\source\common
-I..\..\..\..\..\icu-sword\source\i18n -I..\..\..\..\include
-I$(BCB)\include -I$(BCB)\include\vcl -Irxlib -src_suffix cpp -D_ICU_"/>
- <CFLAG1 value="-O2 -Vx -Ve -RT- -X- -a8 -4 -b- -k- -vi -c -tW -tWM"/>
- <PFLAGS value="-N2obj -N0obj -$Y- -$L- -$D- -v -M -JPHNE"/>
+ <CFLAG1 value="-vGc -vGt -vGd -Od -Vx -Ve -RT- -X- -r- -a8 -4 -b- -k -y -v -vi- -c -tW -tWM"/>
+ <PFLAGS value="-N2obj -N0obj -$Y+ -$W -$O- -v -M -JPHNE"/>
<RFLAGS value=""/>
- <AFLAGS value="/mx /w2 /zn"/>
- <LFLAGS value="-Iobj -D&quot;&quot; -aa -Tpe -GD -s -Gn"/>
+ <AFLAGS value="/mx /w2 /zi"/>
+ <LFLAGS value="-Iobj -D&quot;&quot; -aa -Tpe -GD -s -Gn -v"/>
</OPTIONS>
<LINKER>
<ALLOBJ value="c0w32.obj $(OBJFILES)"/>
<ALLRES value="$(RESFILES)"/>
- <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib"/>
+ <ALLLIB value="cg32.lib $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib"/>
</LINKER>
<IDEOPTIONS>
[Version Info]
@@ -73,7 +73,7 @@ AutoIncBuild=1
MajorVer=1
MinorVer=5
Release=4
-Build=130
+Build=131
Debug=0
PreRelease=0
Special=0
@@ -85,7 +85,7 @@ CodePage=1252
[Version Info Keys]
CompanyName=CrossWire Software &amp; Bible Society
FileDescription=Windows 32bit User Interface to The SWORD Project
-FileVersion=1.5.4.130
+FileVersion=1.5.4.131
InternalName=biblecs
LegalCopyright=(c) 2002 CrossWire Bible Society under the terms of the GNU General Public License
LegalTrademarks=
@@ -125,8 +125,8 @@ Item0=$(BCB)\source\vcl
[HistoryLists\hlConditionals]
Count=8
-Item0=_ICU_;_ICUSWORD_;USBINARY
-Item1=_ICU_;_ICUSWORD_;USBINARY;_DEBUG
+Item0=_ICU_;_ICUSWORD_;USBINARY;_DEBUG
+Item1=_ICU_;_ICUSWORD_;USBINARY
Item2=_ICU_;_ICUSWORD_;_DEBUG;USBINARY
Item3=_ICU_;_ICUSWORD_;_DEBUG
Item4=_ICU_;_ICUSWORD_
@@ -159,7 +159,7 @@ RemoteDebug=0
[Compiler]
ShowInfoMsgs=0
LinkDebugVcl=0
-LinkCGLIB=0
+LinkCGLIB=1
[Language]
ActiveLang=
diff --git a/apps/windoze/CBuilder5/BibleCS/sword.res b/apps/windoze/CBuilder5/BibleCS/sword.res
index 9adcbc3..4c24f8a 100644
--- a/apps/windoze/CBuilder5/BibleCS/sword.res
+++ b/apps/windoze/CBuilder5/BibleCS/sword.res
Binary files differ
diff --git a/apps/windoze/CBuilder5/BibleCS/swordlib.bpr b/apps/windoze/CBuilder5/BibleCS/swordlib.bpr
index 9978ead..a280a48 100644
--- a/apps/windoze/CBuilder5/BibleCS/swordlib.bpr
+++ b/apps/windoze/CBuilder5/BibleCS/swordlib.bpr
@@ -78,7 +78,7 @@
<DEBUGLIBPATH value=""/>
<RELEASELIBPATH value=""/>
<LINKER value="TLib"/>
- <USERDEFINES value="_ICU_;_ICUSWORD_;USBINARY"/>
+ <USERDEFINES value="_ICU_;_ICUSWORD_;USBINARY;_DEBUG"/>
<SYSDEFINES value="NO_STRICT;_NO_VCL"/>
<MAINSOURCE value="swordlib.cpp"/>
<INCLUDEPATH value="..\InstallMgr\curl\include;..\..;..\..\..\..\src\modules\genbook\rawgenbook;..\..\..\..\src\modules\genbook;..\..\..\..\src\modules\lexdict\zld;..\..\..\..\..\icu-sword\source\common;..\..\..\..\..\icu-sword\source\i18n;..\..\..\..\src\utilfuns\zlib;..\..\..\..\src\modules\lexdict\rawld4;..\..\..\..\src\modules\comments\zcom;..\..\..\..\src\modules\texts\ztext;..\..\..\..\src\frontend;..\..\..;..\..\..\..\utilfuns;..\..\..\framework;..\..\..\..\src\modules\comments\rawfiles;..\..\..\..\src\modules\comments\hrefcom;..\..\..\..\include;..\..\..\..\frontend;..\..\..\..\src\utilfuns;..\..\..\..\src\modules;..\..\..\..\src\modules\texts;..\..\..\..\src\modules\texts\rawtext;..\..\..\..\src\modules\texts\rawgbf;..\..\..\..\src\modules\lexdict;..\..\..\..\src\modules\lexdict\rawld;..\..\..\..\src\modules\filters;..\..\..\..\src\modules\common;..\..\..\..\src\modules\comments;..\..\..\..\src\modules\comments\rawcom;..\..\..\..\src\mgr;..\..\..\..\src\keys;$(BCB)\include;$(BCB)\include\vcl"/>
@@ -107,11 +107,11 @@
-I..\..\..\..\src\modules\comments\rawcom -I..\..\..\..\src\mgr
-I..\..\..\..\src\keys -I$(BCB)\include -I$(BCB)\include\vcl -src_suffix
cpp -D_ICU_ -D_DEBUG"/>
- <CFLAG1 value="-O2 -H=c:\PROGRA~1\borland\CBUILD~2\lib\vcl50.csm -Hc -Vx -Ve -RT- -X- -a8
- -4 -b- -k- -vi -c -g0 -tWM"/>
- <PFLAGS value="-N2..\..\..\..\obj -N0..\..\..\..\obj -$Y- -$L- -$D- -v -M -JPHNE"/>
+ <CFLAG1 value="-vGc -vGt -vGd -Od -H=c:\PROGRA~1\borland\CBUILD~2\lib\vcl50.csm -Hc -Vx
+ -Ve -RT- -X- -r- -a8 -4 -b- -k -y -v -vi- -c -g0 -tWM"/>
+ <PFLAGS value="-N2..\..\..\..\obj -N0..\..\..\..\obj -$Y+ -$W -$O- -v -M -JPHNE"/>
<RFLAGS value=""/>
- <AFLAGS value="/mx /w2 /zn"/>
+ <AFLAGS value="/mx /w2 /zi"/>
<LFLAGS value="/P512"/>
</OPTIONS>
<LINKER>
@@ -163,8 +163,8 @@ Item5=..\..\..\..\src\modules\lexdict\zld;..\..;..\..\..\..\src\utilfuns\zlib;..
[HistoryLists\hlConditionals]
Count=8
-Item0=_ICU_;_ICUSWORD_;USBINARY
-Item1=_ICU_;_ICUSWORD_;USBINARY;_DEBUG
+Item0=_ICU_;_ICUSWORD_;USBINARY;_DEBUG
+Item1=_ICU_;_ICUSWORD_;USBINARY
Item2=_ICU_;_ICUSWORD_;_DEBUG;USBINARY
Item3=_ICU_;_ICUSWORD_;_DEBUG
Item4=_ICU_;_ICUSWORD_
@@ -200,7 +200,7 @@ RemoteDebug=0
[Compiler]
ShowInfoMsgs=0
LinkDebugVcl=0
-LinkCGLIB=0
+LinkCGLIB=1
[Language]
ActiveLang=
diff --git a/examples/cmdline/search.cpp b/examples/cmdline/search.cpp
index 235f5b6..34af335 100644
--- a/examples/cmdline/search.cpp
+++ b/examples/cmdline/search.cpp
@@ -33,11 +33,12 @@ int main(int argc, char **argv)
SWMgr manager;
SWModule *target;
ListKey listkey;
- VerseKey vk;
+ ListKey scope;
+ VerseKey parser;
ModMap::iterator it;
- if ((argc != 3) && (argc != 5)) {
- fprintf(stderr, "usage: %s <modname> <\"search string\"> [\"min\" \"max\"]\n", argv[0]);
+ if ((argc != 3) && (argc != 4)) {
+ fprintf(stderr, "usage: %s <modname> <\"search string\"> [\"search_scope\"]\n", argv[0]);
exit(-1);
}
@@ -52,11 +53,10 @@ int main(int argc, char **argv)
target = (*it).second;
- if (argc == 5) { // if min / max specified
- vk.LowerBound(argv[3]);
- vk.UpperBound(argv[4]);
- vk.Persist(1);
- target->setKey(vk);
+ if (argc == 4) { // if min / max specified
+ scope = parser.ParseVerseList(argv[3], parser, true);
+ scope.Persist(1);
+ target->setKey(scope);
}
std::cout << "[0=================================50===============================100]\n ";
diff --git a/include/rawcom.h b/include/rawcom.h
index c5d0aff..fef7e5a 100644
--- a/include/rawcom.h
+++ b/include/rawcom.h
@@ -2,7 +2,7 @@
* rawcom.h - code for class 'RawCom'- a module that reads raw commentary
* files: ot and nt using indexs ??.bks ??.cps ??.vss
*
- * $Id: rawcom.h,v 1.16 2002/10/01 19:52:40 dglassey Exp $
+ * $Id: rawcom.h,v 1.17 2002/10/21 00:30:37 scribe Exp $
*
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -32,8 +32,10 @@ SWORD_NAMESPACE_START
class SWDLLEXPORT RawCom:public RawVerse, public SWCom {
+ VerseKey &getVerseKey();
+
+
public:
-
RawCom(const char *ipath, const char *iname = 0, const char *idesc = 0,
SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
@@ -55,10 +57,10 @@ public:
virtual void deleteEntry(); // Delete current module entry
// end write interface ------------------------
- // OPERATORS -----------------------------------------------------------------
-
SWMODULE_OPERATORS
};
+
SWORD_NAMESPACE_END
+
#endif
diff --git a/include/rawtext.h b/include/rawtext.h
index 00b2f00..528bb0c 100644
--- a/include/rawtext.h
+++ b/include/rawtext.h
@@ -2,7 +2,7 @@
* rawtext.h - code for class 'RawText'- a module that reads raw text files:
* ot and nt using indexs ??.bks ??.cps ??.vss
*
- * $Id: rawtext.h,v 1.25 2002/10/01 19:52:40 dglassey Exp $
+ * $Id: rawtext.h,v 1.26 2002/10/21 00:30:37 scribe Exp $
*
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -31,12 +31,14 @@
SWORD_NAMESPACE_START
-class SWDLLEXPORT RawText:public SWText, public RawVerse {
+class SWDLLEXPORT RawText : public SWText, public RawVerse {
+
RawStr *fastSearch[2];
+ VerseKey &getVerseKey();
+
public:
-
RawText(const char *ipath, const char *iname = 0, const char *idesc = 0, SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN, SWTextDirection dir = DIRECTION_LTR, SWTextMarkup markup = FMT_UNKNOWN,
const char* ilang = 0);
virtual ~RawText();
@@ -55,9 +57,6 @@ public:
virtual void deleteEntry(); // Delete current module entry
// end write interface ------------------------
-
- // OPERATORS -----------------------------------------------------------------
-
SWMODULE_OPERATORS
};
diff --git a/include/zcom.h b/include/zcom.h
index 618deed..135aa2f 100644
--- a/include/zcom.h
+++ b/include/zcom.h
@@ -2,7 +2,7 @@
* zcom.h - code for class 'zCom'- a module that reads compressed text
* files: ot and nt using indexs ??.vss
*
- * $Id: zcom.h,v 1.17 2002/10/01 19:52:40 dglassey Exp $
+ * $Id: zcom.h,v 1.18 2002/10/21 00:30:37 scribe Exp $
*
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -32,11 +32,14 @@
SWORD_NAMESPACE_START
class SWDLLEXPORT zCom:public zVerse, public SWCom {
+
VerseKey *lastWriteKey;
bool sameBlock(VerseKey * lastWriteKey, VerseKey * key);
int blockType;
-public:
+ VerseKey &getVerseKey();
+
+public:
zCom(const char *ipath, const char *iname = 0, const char *idesc = 0,
int blockType = CHAPTERBLOCKS, SWCompress * icomp = 0,
@@ -45,8 +48,8 @@ public:
SWTextMarkup markup = FMT_UNKNOWN, const char* ilang = 0);
virtual ~zCom();
virtual char *getRawEntry();
- virtual void increment(int steps);
- virtual void decrement(int steps) { increment(-steps); }
+ virtual void increment(int steps = 1);
+ virtual void decrement(int steps = 1) { increment(-steps); }
// write interface ----------------------------
virtual bool isWritable() {
@@ -66,12 +69,10 @@ public:
virtual void flush() { flushCache(); }
// end swcacher interface ----------------------
-
- // OPERATORS -----------------------------------------------------------------
-
SWMODULE_OPERATORS
};
SWORD_NAMESPACE_END
+
#endif
diff --git a/include/ztext.h b/include/ztext.h
index 3c9ac4e..6b4a8a4 100644
--- a/include/ztext.h
+++ b/include/ztext.h
@@ -2,7 +2,7 @@
* ztext.h - code for class 'zText'- a module that reads compressed text
* files: ot and nt using indexs ??.vss
*
- * $Id: ztext.h,v 1.26 2002/10/01 19:52:40 dglassey Exp $
+ * $Id: ztext.h,v 1.27 2002/10/21 00:30:37 scribe Exp $
*
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -36,11 +36,14 @@ SWORD_NAMESPACE_START
* It should not be used in frontends, unless you are doing very special things.
*/
class SWDLLEXPORT zText:public zVerse, public SWText {
+
VerseKey *lastWriteKey;
bool sameBlock(VerseKey * lastWriteKey, VerseKey * key);
int blockType;
+ VerseKey &getVerseKey();
+
+
public:
-
zText(const char *ipath, const char *iname = 0, const char *idesc = 0,
int blockType = CHAPTERBLOCKS, SWCompress * icomp = 0,
@@ -71,9 +74,6 @@ public:
virtual void flush() { flushCache(); }
// end swcacher interface ----------------------
-
- // OPERATORS -----------------------------------------------------------------
-
SWMODULE_OPERATORS
};
diff --git a/src/keys/treekeyidx.cpp b/src/keys/treekeyidx.cpp
index e12a458..04831d2 100644
--- a/src/keys/treekeyidx.cpp
+++ b/src/keys/treekeyidx.cpp
@@ -1,7 +1,7 @@
/******************************************************************************
* versekey.h - code for class 'versekey'- a standard Biblical verse key
*
- * $Id: treekeyidx.cpp,v 1.12 2002/10/08 00:36:00 scribe Exp $
+ * $Id: treekeyidx.cpp,v 1.13 2002/10/21 00:30:37 scribe Exp $
*
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -341,7 +341,7 @@ char TreeKeyIdx::getTreeNodeFromIdxOffset(long ioffset, TreeNode *node) const {
if (ioffset < 0) {
ioffset = 0;
- error = 7777; // out of bounds but still position to 0;
+ error = 77; // out of bounds but still position to 0;
}
node->offset = ioffset;
@@ -350,7 +350,7 @@ char TreeKeyIdx::getTreeNodeFromIdxOffset(long ioffset, TreeNode *node) const {
lseek(idxfd->getFd(), ioffset, SEEK_SET);
if (read(idxfd->getFd(), &offset, 4) == 4) {
offset = swordtoarch32(offset);
- error = (error == 7777) ? KEYERR_OUTOFBOUNDS : 0;
+ error = (error == 77) ? KEYERR_OUTOFBOUNDS : 0;
getTreeNodeFromDatOffset(offset, node);
}
else {
diff --git a/src/modules/comments/rawcom/rawcom.cpp b/src/modules/comments/rawcom/rawcom.cpp
index de400d6..c9cfcd5 100644
--- a/src/modules/comments/rawcom/rawcom.cpp
+++ b/src/modules/comments/rawcom/rawcom.cpp
@@ -54,15 +54,7 @@ RawCom::~RawCom()
char *RawCom::getRawEntry() {
long start = 0;
unsigned short size = 0;
- VerseKey *key = 0;
-
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- if (!key)
- key = new VerseKey(this->key);
-
+ VerseKey *key = &getVerseKey();
findoffset(key->Testament(), key->Index(), &start, &size);
entrySize = size; // support getEntrySize call
@@ -85,9 +77,6 @@ char *RawCom::getRawEntry() {
if (!isUnicode())
preptext(entrybuf);
- if (key != this->key)
- delete key;
-
return entrybuf;
}
@@ -103,14 +92,7 @@ char *RawCom::getRawEntry() {
void RawCom::increment(int steps) {
long start;
unsigned short size;
- VerseKey *tmpkey = 0;
-
- try {
- tmpkey = SWDYNAMIC_CAST(VerseKey, key);
- }
- catch ( ... ) {}
- if (!tmpkey)
- tmpkey = new VerseKey(key);
+ VerseKey *tmpkey = &getVerseKey();
findoffset(tmpkey->Testament(), tmpkey->Index(), &start, &size);
@@ -120,15 +102,7 @@ void RawCom::increment(int steps) {
unsigned short lastsize = size;
SWKey lasttry = *tmpkey;
(steps > 0) ? (*key)++ : (*key)--;
- if (tmpkey != key)
- delete tmpkey;
- tmpkey = 0;
- try {
- tmpkey = SWDYNAMIC_CAST(VerseKey, key);
- }
- catch ( ... ) {}
- if (!tmpkey)
- tmpkey = new VerseKey(key);
+ tmpkey = &getVerseKey();
if ((error = key->Error())) {
*key = lastgood;
@@ -145,41 +119,18 @@ void RawCom::increment(int steps) {
}
}
error = (error) ? KEYERR_OUTOFBOUNDS : 0;
-
- if (tmpkey != key)
- delete tmpkey;
}
void RawCom::setEntry(const char *inbuf, long len) {
- VerseKey *key = 0;
- // see if we have a VerseKey * or decendant
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!key)
- key = new VerseKey(this->key);
-
+ VerseKey *key = &getVerseKey();
settext(key->Testament(), key->Index(), inbuf, len);
-
- if (this->key != key) // free our key if we created a VerseKey
- delete key;
}
void RawCom::linkEntry(const SWKey *inkey) {
- VerseKey *destkey = 0;
+ VerseKey *destkey = &getVerseKey();
const VerseKey *srckey = 0;
- // see if we have a VerseKey * or decendant
- try {
- destkey = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!destkey)
- destkey = new VerseKey(this->key);
// see if we have a VerseKey * or decendant
try {
@@ -192,9 +143,6 @@ void RawCom::linkEntry(const SWKey *inkey) {
linkentry(destkey->Testament(), destkey->Index(), srckey->Index());
- if (this->key != destkey) // free our key if we created a VerseKey
- delete destkey;
-
if (inkey != srckey) // free our key if we created a VerseKey
delete srckey;
}
@@ -208,19 +156,37 @@ void RawCom::linkEntry(const SWKey *inkey) {
void RawCom::deleteEntry() {
- VerseKey *key = 0;
+ VerseKey *key = &getVerseKey();
+ settext(key->Testament(), key->Index(), "");
+}
+
+VerseKey &RawCom::getVerseKey() {
+ static VerseKey tmpVK;
+ VerseKey *key;
+ // see if we have a VerseKey * or decendant
try {
key = SWDYNAMIC_CAST(VerseKey, this->key);
}
- catch ( ... ) {}
- if (!key)
- key = new VerseKey(this->key);
-
- settext(key->Testament(), key->Index(), "");
-
- if (key != this->key)
- delete key;
+ catch ( ... ) { }
+ if (!key) {
+ ListKey *lkTest = 0;
+ try {
+ lkTest = SWDYNAMIC_CAST(ListKey, this->key);
+ }
+ catch ( ... ) { }
+ if (lkTest) {
+ try {
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ }
+ catch ( ... ) { }
+ }
+ }
+ if (!key) {
+ tmpVK = *(this->key);
+ return tmpVK;
+ }
+ else return *key;
}
diff --git a/src/modules/comments/zcom/zcom.cpp b/src/modules/comments/zcom/zcom.cpp
index 7d5d3c2..b3a10de 100644
--- a/src/modules/comments/zcom/zcom.cpp
+++ b/src/modules/comments/zcom/zcom.cpp
@@ -58,15 +58,7 @@ zCom::~zCom() {
char *zCom::getRawEntry() {
long start = 0;
unsigned short size = 0;
- VerseKey *key = 0;
-
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!key)
- key = new VerseKey(this->key);
+ VerseKey *key = &getVerseKey();
findoffset(key->Testament(), key->Index(), &start, &size);
entrySize = size; // support getEntrySize call
@@ -87,9 +79,6 @@ char *zCom::getRawEntry() {
if (!isUnicode())
preptext(entrybuf);
- if (this->key != key) // free our key if we created a VerseKey
- delete key;
-
return entrybuf;
}
@@ -113,16 +102,7 @@ bool zCom::sameBlock(VerseKey *k1, VerseKey *k2) {
}
void zCom::setEntry(const char *inbuf, long len) {
- VerseKey *key = 0;
- // see if we have a VerseKey * or decendant
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!key)
- key = new VerseKey(this->key);
-
+ VerseKey *key = &getVerseKey();
// see if we've jumped across blocks since last write
if (lastWriteKey) {
@@ -135,23 +115,12 @@ void zCom::setEntry(const char *inbuf, long len) {
settext(key->Testament(), key->Index(), inbuf, len);
lastWriteKey = (VerseKey *)key->clone(); // must delete
-
- if (this->key != key) // free our key if we created a VerseKey
- delete key;
}
void zCom::linkEntry(const SWKey *inkey) {
- VerseKey *destkey = 0;
+ VerseKey *destkey = &getVerseKey();
const VerseKey *srckey = 0;
- // see if we have a VerseKey * or decendant
- try {
- destkey = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!destkey)
- destkey = new VerseKey(this->key);
// see if we have a VerseKey * or decendant
try {
@@ -165,9 +134,6 @@ void zCom::linkEntry(const SWKey *inkey) {
linkentry(destkey->Testament(), destkey->Index(), srckey->Index());
- if (this->key != destkey) // free our key if we created a VerseKey
- delete destkey;
-
if (inkey != srckey) // free our key if we created a VerseKey
delete srckey;
}
@@ -180,19 +146,8 @@ void zCom::linkEntry(const SWKey *inkey) {
void zCom::deleteEntry() {
- VerseKey *key = 0;
-
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- if (!key)
- key = new VerseKey(this->key);
-
+ VerseKey *key = &getVerseKey();
settext(key->Testament(), key->Index(), "");
-
- if (key != this->key)
- delete key;
}
@@ -207,14 +162,7 @@ void zCom::deleteEntry() {
void zCom::increment(int steps) {
long start;
unsigned short size;
- VerseKey *tmpkey = 0;
-
- try {
- tmpkey = SWDYNAMIC_CAST(VerseKey, key);
- }
- catch ( ... ) {}
- if (!tmpkey)
- tmpkey = new VerseKey(key);
+ VerseKey *tmpkey = &getVerseKey();
findoffset(tmpkey->Testament(), tmpkey->Index(), &start, &size);
@@ -224,15 +172,7 @@ void zCom::increment(int steps) {
unsigned short lastsize = size;
SWKey lasttry = *tmpkey;
(steps > 0) ? (*key)++ : (*key)--;
- if (tmpkey != key)
- delete tmpkey;
- tmpkey = 0;
- try {
- tmpkey = SWDYNAMIC_CAST(VerseKey, key);
- }
- catch ( ... ) {}
- if (!tmpkey)
- tmpkey = new VerseKey(key);
+ tmpkey = &getVerseKey();
if ((error = key->Error())) {
*key = lastgood;
@@ -249,9 +189,36 @@ void zCom::increment(int steps) {
}
}
error = (error) ? KEYERR_OUTOFBOUNDS : 0;
+}
+
- if (tmpkey != key)
- delete tmpkey;
+VerseKey &zCom::getVerseKey() {
+ static VerseKey tmpVK;
+ VerseKey *key;
+ // see if we have a VerseKey * or decendant
+ try {
+ key = SWDYNAMIC_CAST(VerseKey, this->key);
+ }
+ catch ( ... ) { }
+ if (!key) {
+ ListKey *lkTest = 0;
+ try {
+ lkTest = SWDYNAMIC_CAST(ListKey, this->key);
+ }
+ catch ( ... ) { }
+ if (lkTest) {
+ try {
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ }
+ catch ( ... ) { }
+ }
+ }
+ if (!key) {
+ tmpVK = *(this->key);
+ return tmpVK;
+ }
+ else return *key;
}
+
SWORD_NAMESPACE_END
diff --git a/src/modules/common/rawstr.cpp b/src/modules/common/rawstr.cpp
index a9f9c1d..eeb3bf8 100644
--- a/src/modules/common/rawstr.cpp
+++ b/src/modules/common/rawstr.cpp
@@ -171,7 +171,7 @@ signed char RawStr::findoffset(const char *ikey, long *start, unsigned short *si
if (*ikey) {
headoff = 0;
- key = new char [ strlen(ikey) + 10 ]; // just in case toupper needs a few extra
+ key = new char [ (strlen(ikey)*2) + 10 ]; // just in case toupper needs a few extra
strcpy(key, ikey);
toupperstr_utf8(key);
diff --git a/src/modules/texts/rawtext/rawtext.cpp b/src/modules/texts/rawtext/rawtext.cpp
index fe14e9b..ef7742a 100644
--- a/src/modules/texts/rawtext/rawtext.cpp
+++ b/src/modules/texts/rawtext/rawtext.cpp
@@ -77,6 +77,35 @@ RawText::~RawText()
}
+VerseKey &RawText::getVerseKey() {
+ static VerseKey tmpVK;
+ VerseKey *key;
+ // see if we have a VerseKey * or decendant
+ try {
+ key = SWDYNAMIC_CAST(VerseKey, this->key);
+ }
+ catch ( ... ) { }
+ if (!key) {
+ ListKey *lkTest = 0;
+ try {
+ lkTest = SWDYNAMIC_CAST(ListKey, this->key);
+ }
+ catch ( ... ) { }
+ if (lkTest) {
+ try {
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ }
+ catch ( ... ) { }
+ }
+ }
+ if (!key) {
+ tmpVK = *(this->key);
+ return tmpVK;
+ }
+ else return *key;
+}
+
+
/******************************************************************************
* RawText::getRawEntry - Returns the correct verse when char * cast
* is requested
@@ -87,18 +116,9 @@ RawText::~RawText()
char *RawText::getRawEntry() {
long start = 0;
unsigned short size = 0;
- VerseKey *key = 0;
+ VerseKey &key = getVerseKey();
- // see if we have a VerseKey * or decendant
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) { }
- // if we don't have a VerseKey * decendant, create our own
- if (!key)
- key = new VerseKey(this->key);
-
- findoffset(key->Testament(), key->Index(), &start, &size);
+ findoffset(key.Testament(), key.Index(), &start, &size);
entrySize = size; // support getEntrySize call
unsigned long newsize = (size + 2) * FILTERPAD;
@@ -110,18 +130,15 @@ char *RawText::getRawEntry() {
}
*entrybuf = 0;
- readtext(key->Testament(), start, (size + 2), entrybuf);
+ readtext(key.Testament(), start, (size + 2), entrybuf);
entrybuf[size] = 0;
rawFilter(entrybuf, size, 0); // hack, decipher
- rawFilter(entrybuf, size*FILTERPAD, key);
+ rawFilter(entrybuf, size*FILTERPAD, &key);
if (!isUnicode())
preptext(entrybuf);
- if (this->key != key) // free our key if we created a VerseKey
- delete key;
-
return entrybuf;
}
@@ -458,34 +475,14 @@ ListKey &RawText::Search(const char *istr, int searchType, int flags, SWKey *sco
void RawText::setEntry(const char *inbuf, long len) {
- VerseKey *key = 0;
- // see if we have a VerseKey * or decendant
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!key)
- key = new VerseKey(this->key);
-
- settext(key->Testament(), key->Index(), inbuf, len);
-
- if (this->key != key) // free our key if we created a VerseKey
- delete key;
+ VerseKey &key = getVerseKey();
+ settext(key.Testament(), key.Index(), inbuf, len);
}
void RawText::linkEntry(const SWKey *inkey) {
- VerseKey *destkey = 0;
+ VerseKey &destkey = getVerseKey();
const VerseKey *srckey = 0;
- // see if we have a VerseKey * or decendant
- try {
- destkey = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!destkey)
- destkey = new VerseKey(this->key);
// see if we have a VerseKey * or decendant
try {
@@ -496,10 +493,7 @@ void RawText::linkEntry(const SWKey *inkey) {
if (!srckey)
srckey = new VerseKey(inkey);
- linkentry(destkey->Testament(), destkey->Index(), srckey->Index());
-
- if (this->key != destkey) // free our key if we created a VerseKey
- delete destkey;
+ linkentry(destkey.Testament(), destkey.Index(), srckey->Index());
if (inkey != srckey) // free our key if we created a VerseKey
delete srckey;
@@ -513,20 +507,8 @@ void RawText::linkEntry(const SWKey *inkey) {
*/
void RawText::deleteEntry() {
-
- VerseKey *key = 0;
-
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- if (!key)
- key = new VerseKey(this->key);
-
- settext(key->Testament(), key->Index(), "");
-
- if (key != this->key)
- delete key;
+ VerseKey &key = getVerseKey();
+ settext(key.Testament(), key.Index(), "");
}
/******************************************************************************
@@ -540,14 +522,7 @@ void RawText::deleteEntry() {
void RawText::increment(int steps) {
long start;
unsigned short size;
- VerseKey *tmpkey = 0;
-
- try {
- tmpkey = SWDYNAMIC_CAST(VerseKey, key);
- }
- catch ( ... ) {}
- if (!tmpkey)
- tmpkey = new VerseKey(key);
+ VerseKey *tmpkey = &getVerseKey();
findoffset(tmpkey->Testament(), tmpkey->Index(), &start, &size);
@@ -557,15 +532,7 @@ void RawText::increment(int steps) {
unsigned short lastsize = size;
SWKey lasttry = *tmpkey;
(steps > 0) ? (*key)++ : (*key)--;
- if (tmpkey != key)
- delete tmpkey;
- tmpkey = 0;
- try {
- tmpkey = SWDYNAMIC_CAST(VerseKey, key);
- }
- catch ( ... ) {}
- if (!tmpkey)
- tmpkey = new VerseKey(key);
+ tmpkey = &getVerseKey();
if ((error = key->Error())) {
*key = lastgood;
@@ -582,9 +549,6 @@ void RawText::increment(int steps) {
}
}
error = (error) ? KEYERR_OUTOFBOUNDS : 0;
-
- if (tmpkey != key)
- delete tmpkey;
}
SWORD_NAMESPACE_END
diff --git a/src/modules/texts/ztext/ztext.cpp b/src/modules/texts/ztext/ztext.cpp
index fe90216..00793c2 100644
--- a/src/modules/texts/ztext/ztext.cpp
+++ b/src/modules/texts/ztext/ztext.cpp
@@ -63,18 +63,9 @@ char *zText::getRawEntry()
{
long start = 0;
unsigned short size = 0;
- VerseKey *key = 0;
+ VerseKey &key = getVerseKey();
- // see if we have a VerseKey * or decendant
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!key)
- key = new VerseKey(this->key);
-
- findoffset(key->Testament(), key->Index(), &start, &size);
+ findoffset(key.Testament(), key.Index(), &start, &size);
entrySize = size; // support getEntrySize call
unsigned long newsize = (size + 2) * FILTERPAD;
@@ -86,16 +77,13 @@ char *zText::getRawEntry()
}
*entrybuf = 0;
- zreadtext(key->Testament(), start, (size + 2), entrybuf);
+ zreadtext(key.Testament(), start, (size + 2), entrybuf);
- rawFilter(entrybuf, size*FILTERPAD, key);
+ rawFilter(entrybuf, size*FILTERPAD, &key);
if (!isUnicode())
preptext(entrybuf);
- if (this->key != key) // free our key if we created a VerseKey
- delete key;
-
return entrybuf;
}
@@ -120,45 +108,25 @@ bool zText::sameBlock(VerseKey *k1, VerseKey *k2) {
void zText::setEntry(const char *inbuf, long len) {
- VerseKey *key = 0;
- // see if we have a VerseKey * or decendant
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!key)
- key = new VerseKey(this->key);
-
+ VerseKey &key = getVerseKey();
// see if we've jumped across blocks since last write
if (lastWriteKey) {
- if (!sameBlock(lastWriteKey, key)) {
+ if (!sameBlock(lastWriteKey, &key)) {
flushCache();
}
delete lastWriteKey;
}
- settext(key->Testament(), key->Index(), inbuf, len);
-
- lastWriteKey = (VerseKey *)key->clone(); // must delete
+ settext(key.Testament(), key.Index(), inbuf, len);
- if (this->key != key) // free our key if we created a VerseKey
- delete key;
+ lastWriteKey = (VerseKey *)key.clone(); // must delete
}
void zText::linkEntry(const SWKey *inkey) {
- VerseKey *destkey = 0;
+ VerseKey &destkey = getVerseKey();
const VerseKey *srckey = 0;
- // see if we have a VerseKey * or decendant
- try {
- destkey = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!destkey)
- destkey = new VerseKey(this->key);
// see if we have a VerseKey * or decendant
try {
@@ -170,10 +138,7 @@ void zText::linkEntry(const SWKey *inkey) {
if (!srckey)
srckey = new VerseKey(inkey);
- linkentry(destkey->Testament(), destkey->Index(), srckey->Index());
-
- if (this->key != destkey) // free our key if we created a VerseKey
- delete destkey;
+ linkentry(destkey.Testament(), destkey.Index(), srckey->Index());
if (inkey != srckey) // free our key if we created a VerseKey
delete srckey;
@@ -187,19 +152,9 @@ void zText::linkEntry(const SWKey *inkey) {
void zText::deleteEntry() {
- VerseKey *key = 0;
+ VerseKey &key = getVerseKey();
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- if (!key)
- key = new VerseKey(this->key);
-
- settext(key->Testament(), key->Index(), "");
-
- if (key != this->key)
- delete key;
+ settext(key.Testament(), key.Index(), "");
}
@@ -213,14 +168,7 @@ void zText::deleteEntry() {
void zText::increment(int steps) {
long start;
unsigned short size;
- VerseKey *tmpkey = 0;
-
- try {
- tmpkey = SWDYNAMIC_CAST(VerseKey, key);
- }
- catch ( ... ) {}
- if (!tmpkey)
- tmpkey = new VerseKey(key);
+ VerseKey *tmpkey = &getVerseKey();
findoffset(tmpkey->Testament(), tmpkey->Index(), &start, &size);
@@ -230,15 +178,7 @@ void zText::increment(int steps) {
unsigned short lastsize = size;
SWKey lasttry = *tmpkey;
(steps > 0) ? (*key)++ : (*key)--;
- if (tmpkey != key)
- delete tmpkey;
- tmpkey = 0;
- try {
- tmpkey = SWDYNAMIC_CAST(VerseKey, key);
- }
- catch ( ... ) {}
- if (!tmpkey)
- tmpkey = new VerseKey(key);
+ tmpkey = &getVerseKey();
if ((error = key->Error())) {
*key = lastgood;
@@ -256,9 +196,36 @@ void zText::increment(int steps) {
}
}
error = (error) ? KEYERR_OUTOFBOUNDS : 0;
+}
+
- if (tmpkey != key)
- delete tmpkey;
+VerseKey &zText::getVerseKey() {
+ static VerseKey tmpVK;
+ VerseKey *key;
+ // see if we have a VerseKey * or decendant
+ try {
+ key = SWDYNAMIC_CAST(VerseKey, this->key);
+ }
+ catch ( ... ) { }
+ if (!key) {
+ ListKey *lkTest = 0;
+ try {
+ lkTest = SWDYNAMIC_CAST(ListKey, this->key);
+ }
+ catch ( ... ) { }
+ if (lkTest) {
+ try {
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ }
+ catch ( ... ) { }
+ }
+ }
+ if (!key) {
+ tmpVK = *(this->key);
+ return tmpVK;
+ }
+ else return *key;
}
+
SWORD_NAMESPACE_END
diff --git a/src/utilfuns/zlib/infcodes.c b/src/utilfuns/zlib/infcodes.c
index 9abe541..0d54ea7 100644
--- a/src/utilfuns/zlib/infcodes.c
+++ b/src/utilfuns/zlib/infcodes.c
@@ -92,7 +92,7 @@ int r;
uInt n; /* bytes available there */
Bytef *q; /* output window write pointer */
uInt m; /* bytes to end of window or read pointer */
- Bytef *f; /* pointer to copy strings from */
+ unsigned long csf; /* pointer to copy strings from */
inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
/* copy input/output information to locals (UPDATE macro restores) */
@@ -103,120 +103,120 @@ int r;
{ /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
case START: /* x: set up for LEN */
#ifndef SLOW
- if (m >= 258 && n >= 10)
- {
- UPDATE
- r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
- LOAD
- if (r != Z_OK)
- {
- c->mode = r == Z_STREAM_END ? WASH : BADCODE;
- break;
- }
- }
+ if (m >= 258 && n >= 10)
+ {
+ UPDATE
+ r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
+ LOAD
+ if (r != Z_OK)
+ {
+ c->mode = r == Z_STREAM_END ? WASH : BADCODE;
+ break;
+ }
+ }
#endif /* !SLOW */
- c->sub.code.need = c->lbits;
- c->sub.code.tree = c->ltree;
- c->mode = LEN;
+ c->sub.code.need = c->lbits;
+ c->sub.code.tree = c->ltree;
+ c->mode = LEN;
case LEN: /* i: get length/literal/eob next */
- j = c->sub.code.need;
- NEEDBITS(j)
- t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
- DUMPBITS(t->bits)
- e = (uInt)(t->exop);
- if (e == 0) /* literal */
- {
- c->sub.lit = t->base;
- Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", t->base));
- c->mode = LIT;
- break;
- }
- if (e & 16) /* length */
- {
- c->sub.copy.get = e & 15;
- c->len = t->base;
- c->mode = LENEXT;
- break;
- }
- if ((e & 64) == 0) /* next table */
- {
- c->sub.code.need = e;
- c->sub.code.tree = t + t->base;
- break;
- }
- if (e & 32) /* end of block */
- {
- Tracevv((stderr, "inflate: end of block\n"));
- c->mode = WASH;
- break;
- }
- c->mode = BADCODE; /* invalid code */
- z->msg = (char*)"invalid literal/length code";
- r = Z_DATA_ERROR;
- LEAVE
+ j = c->sub.code.need;
+ NEEDBITS(j)
+ t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
+ DUMPBITS(t->bits)
+ e = (uInt)(t->exop);
+ if (e == 0) /* literal */
+ {
+ c->sub.lit = t->base;
+ Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
+ "inflate: literal '%c'\n" :
+ "inflate: literal 0x%02x\n", t->base));
+ c->mode = LIT;
+ break;
+ }
+ if (e & 16) /* length */
+ {
+ c->sub.copy.get = e & 15;
+ c->len = t->base;
+ c->mode = LENEXT;
+ break;
+ }
+ if ((e & 64) == 0) /* next table */
+ {
+ c->sub.code.need = e;
+ c->sub.code.tree = t + t->base;
+ break;
+ }
+ if (e & 32) /* end of block */
+ {
+ Tracevv((stderr, "inflate: end of block\n"));
+ c->mode = WASH;
+ break;
+ }
+ c->mode = BADCODE; /* invalid code */
+ z->msg = (char*)"invalid literal/length code";
+ r = Z_DATA_ERROR;
+ LEAVE
case LENEXT: /* i: getting length extra (have base) */
- j = c->sub.copy.get;
- NEEDBITS(j)
- c->len += (uInt)b & inflate_mask[j];
- DUMPBITS(j)
- c->sub.code.need = c->dbits;
- c->sub.code.tree = c->dtree;
- Tracevv((stderr, "inflate: length %u\n", c->len));
- c->mode = DIST;
+ j = c->sub.copy.get;
+ NEEDBITS(j)
+ c->len += (uInt)b & inflate_mask[j];
+ DUMPBITS(j)
+ c->sub.code.need = c->dbits;
+ c->sub.code.tree = c->dtree;
+ Tracevv((stderr, "inflate: length %u\n", c->len));
+ c->mode = DIST;
case DIST: /* i: get distance next */
- j = c->sub.code.need;
- NEEDBITS(j)
- t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
- DUMPBITS(t->bits)
- e = (uInt)(t->exop);
- if (e & 16) /* distance */
- {
- c->sub.copy.get = e & 15;
- c->sub.copy.dist = t->base;
- c->mode = DISTEXT;
- break;
- }
- if ((e & 64) == 0) /* next table */
- {
- c->sub.code.need = e;
- c->sub.code.tree = t + t->base;
- break;
- }
- c->mode = BADCODE; /* invalid code */
- z->msg = (char*)"invalid distance code";
- r = Z_DATA_ERROR;
- LEAVE
+ j = c->sub.code.need;
+ NEEDBITS(j)
+ t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
+ DUMPBITS(t->bits)
+ e = (uInt)(t->exop);
+ if (e & 16) /* distance */
+ {
+ c->sub.copy.get = e & 15;
+ c->sub.copy.dist = t->base;
+ c->mode = DISTEXT;
+ break;
+ }
+ if ((e & 64) == 0) /* next table */
+ {
+ c->sub.code.need = e;
+ c->sub.code.tree = t + t->base;
+ break;
+ }
+ c->mode = BADCODE; /* invalid code */
+ z->msg = (char*)"invalid distance code";
+ r = Z_DATA_ERROR;
+ LEAVE
case DISTEXT: /* i: getting distance extra */
- j = c->sub.copy.get;
- NEEDBITS(j)
- c->sub.copy.dist += (uInt)b & inflate_mask[j];
- DUMPBITS(j)
- Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist));
- c->mode = COPY;
+ j = c->sub.copy.get;
+ NEEDBITS(j)
+ c->sub.copy.dist += (uInt)b & inflate_mask[j];
+ DUMPBITS(j)
+ Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist));
+ c->mode = COPY;
case COPY: /* o: copying bytes in window, waiting for space */
- f = q - c->sub.copy.dist;
- while (f < s->window) /* modulo window size-"while" instead */
- f += s->end - s->window; /* of "if" handles invalid distances */
- while (c->len)
- {
- NEEDOUT
- OUTBYTE(*f++)
- if (f == s->end)
- f = s->window;
- c->len--;
- }
- c->mode = START;
- break;
+ csf = (unsigned long)q - c->sub.copy.dist;
+ while (csf < (unsigned long)s->window) /* modulo window size-"while" instead */
+ csf += (unsigned long)(s->end - s->window); /* of "if" handles invalid distances */
+ while (c->len)
+ {
+ NEEDOUT
+ OUTBYTE(*(Bytef *)csf++)
+ if (csf == (unsigned long)s->end)
+ csf = (unsigned long)s->window;
+ c->len--;
+ }
+ c->mode = START;
+ break;
case LIT: /* o: got literal, waiting for output space */
- NEEDOUT
- OUTBYTE(c->sub.lit)
- c->mode = START;
- break;
+ NEEDOUT
+ OUTBYTE(c->sub.lit)
+ c->mode = START;
+ break;
case WASH: /* o: got eob, possibly more output */
- if (k > 7) /* return unused byte, if any */
- {
+ if (k > 7) /* return unused byte, if any */
+ {
Assert(k < 16, "inflate_codes grabbed too many bytes")
k -= 8;
n++;
diff --git a/src/utilfuns/zlib/inffast.c b/src/utilfuns/zlib/inffast.c
index aa7f1d4..a7ebc64 100644
--- a/src/utilfuns/zlib/inffast.c
+++ b/src/utilfuns/zlib/inffast.c
@@ -44,7 +44,7 @@ z_streamp z;
uInt md; /* mask for distance tree */
uInt c; /* bytes to copy */
uInt d; /* distance back to copy from */
- Bytef *r; /* copy source pointer */
+ unsigned long csp; /* copy source pointer */
/* load input, output, bit values */
LOAD
@@ -59,107 +59,107 @@ z_streamp z;
GRABBITS(20) /* max bits for literal/length code */
if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)
{
- DUMPBITS(t->bits)
- Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
- "inflate: * literal '%c'\n" :
- "inflate: * literal 0x%02x\n", t->base));
- *q++ = (Byte)t->base;
- m--;
- continue;
+ DUMPBITS(t->bits)
+ Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
+ "inflate: * literal '%c'\n" :
+ "inflate: * literal 0x%02x\n", t->base));
+ *q++ = (Byte)t->base;
+ m--;
+ continue;
}
do {
- DUMPBITS(t->bits)
- if (e & 16)
- {
- /* get extra bits for length */
- e &= 15;
- c = t->base + ((uInt)b & inflate_mask[e]);
- DUMPBITS(e)
- Tracevv((stderr, "inflate: * length %u\n", c));
+ DUMPBITS(t->bits)
+ if (e & 16)
+ {
+ /* get extra bits for length */
+ e &= 15;
+ c = t->base + ((uInt)b & inflate_mask[e]);
+ DUMPBITS(e)
+ Tracevv((stderr, "inflate: * length %u\n", c));
- /* decode distance base of block to copy */
- GRABBITS(15); /* max bits for distance code */
- e = (t = td + ((uInt)b & md))->exop;
- do {
- DUMPBITS(t->bits)
- if (e & 16)
- {
- /* get extra bits to add to distance base */
- e &= 15;
- GRABBITS(e) /* get extra bits (up to 13) */
- d = t->base + ((uInt)b & inflate_mask[e]);
- DUMPBITS(e)
- Tracevv((stderr, "inflate: * distance %u\n", d));
+ /* decode distance base of block to copy */
+ GRABBITS(15); /* max bits for distance code */
+ e = (t = td + ((uInt)b & md))->exop;
+ do {
+ DUMPBITS(t->bits)
+ if (e & 16)
+ {
+ /* get extra bits to add to distance base */
+ e &= 15;
+ GRABBITS(e) /* get extra bits (up to 13) */
+ d = t->base + ((uInt)b & inflate_mask[e]);
+ DUMPBITS(e)
+ Tracevv((stderr, "inflate: * distance %u\n", d));
- /* do the copy */
- m -= c;
- r = q - d;
- if (r < s->window) /* wrap if needed */
- {
- do {
- r += s->end - s->window; /* force pointer in window */
- } while (r < s->window); /* covers invalid distances */
- e = s->end - r;
- if (c > e)
- {
- c -= e; /* wrapped copy */
- do {
- *q++ = *r++;
- } while (--e);
- r = s->window;
- do {
- *q++ = *r++;
- } while (--c);
- }
- else /* normal copy */
- {
- *q++ = *r++; c--;
- *q++ = *r++; c--;
- do {
- *q++ = *r++;
- } while (--c);
- }
- }
- else /* normal copy */
- {
- *q++ = *r++; c--;
- *q++ = *r++; c--;
- do {
- *q++ = *r++;
- } while (--c);
- }
- break;
- }
- else if ((e & 64) == 0)
- {
- t += t->base;
- e = (t += ((uInt)b & inflate_mask[e]))->exop;
- }
- else
- {
- z->msg = (char*)"invalid distance code";
- UNGRAB
- UPDATE
- return Z_DATA_ERROR;
- }
- } while (1);
- break;
- }
- if ((e & 64) == 0)
- {
- t += t->base;
- if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
- {
- DUMPBITS(t->bits)
- Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
- "inflate: * literal '%c'\n" :
- "inflate: * literal 0x%02x\n", t->base));
- *q++ = (Byte)t->base;
- m--;
- break;
- }
- }
- else if (e & 32)
+ /* do the copy */
+ m -= c;
+ csp = (unsigned long)q - d;
+ if (csp < (unsigned long)s->window) /* wrap if needed */
+ {
+ do {
+ csp += (unsigned long)(s->end - s->window); /* force pointer in window */
+ } while (csp < (unsigned long)s->window); /* covers invalid distances */
+ e = (unsigned long)s->end - csp;
+ if (c > e)
+ {
+ c -= e; /* wrapped copy */
+ do {
+ *q++ = *(Bytef *)csp++;
+ } while (--e);
+ csp = s->window;
+ do {
+ *q++ = *(Bytef *)csp++;
+ } while (--c);
+ }
+ else /* normal copy */
+ {
+ *q++ = *(Bytef *)csp++; c--;
+ *q++ = *(Bytef *)csp++; c--;
+ do {
+ *q++ = *(Bytef *)csp++;
+ } while (--c);
+ }
+ }
+ else /* normal copy */
+ {
+ *q++ = *(Bytef *)csp++; c--;
+ *q++ = *(Bytef *)csp++; c--;
+ do {
+ *q++ = *(Bytef *)csp++;
+ } while (--c);
+ }
+ break;
+ }
+ else if ((e & 64) == 0)
+ {
+ t += t->base;
+ e = (t += ((uInt)b & inflate_mask[e]))->exop;
+ }
+ else
+ {
+ z->msg = (char*)"invalid distance code";
+ UNGRAB
+ UPDATE
+ return Z_DATA_ERROR;
+ }
+ } while (1);
+ break;
+ }
+ if ((e & 64) == 0)
+ {
+ t += t->base;
+ if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
+ {
+ DUMPBITS(t->bits)
+ Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
+ "inflate: * literal '%c'\n" :
+ "inflate: * literal 0x%02x\n", t->base));
+ *q++ = (Byte)t->base;
+ m--;
+ break;
+ }
+ }
+ else if (e & 32)
{
Tracevv((stderr, "inflate: * end of block\n"));
UNGRAB
diff --git a/usrinst.sh b/usrinst.sh
index c24e5bf..5857f29 100755
--- a/usrinst.sh
+++ b/usrinst.sh
@@ -1,8 +1,9 @@
#!/bin/sh
CPPFLAGS=-DUSBINARY ./configure --prefix=/usr \
- --disable-shared --disable-debug --without-conf --sysconfdir=/etc \
---with-vcl \
+ --disable-shared --without-conf --sysconfdir=/etc \
+ --with-vcl \
+ --enable-debug --enable-profile \
$*
echo ""