[sword-svn] r2123 - in trunk: examples/cmdline src/keys
scribe at www.crosswire.org
scribe at www.crosswire.org
Sat Nov 24 12:56:32 MST 2007
Author: scribe
Date: 2007-11-24 12:56:30 -0700 (Sat, 24 Nov 2007)
New Revision: 2123
Modified:
trunk/examples/cmdline/search.cpp
trunk/src/keys/listkey.cpp
Log:
added check for bounds set in listkey equals assignment
added ability to search within result set on example
search app
Modified: trunk/examples/cmdline/search.cpp
===================================================================
--- trunk/examples/cmdline/search.cpp 2007-11-24 17:58:08 UTC (rev 2122)
+++ trunk/examples/cmdline/search.cpp 2007-11-24 19:56:30 UTC (rev 2123)
@@ -10,8 +10,8 @@
using namespace sword;
#endif
+char printed = 0;
void percentUpdate(char percent, void *userData) {
- static char printed = 0;
char maxHashes = *((char *)userData);
while ((((float)percent)/100) * maxHashes > printed) {
@@ -36,8 +36,8 @@
VerseKey parser;
ModMap::iterator it;
- if ((argc != 3) && (argc != 4)) {
- fprintf(stderr, "\nusage: %s <modname> <\"search string\"> [\"search_scope\"]\n"
+ if ((argc < 3) || (argc > 5)) {
+ fprintf(stderr, "\nusage: %s <modname> <\"search string\"> [\"search_scope\"] [\"search again for string in previous result set\"]\n"
"\tExample: search KJV \"swift hear slow speak\"\n\n", argv[0]);
exit(-1);
@@ -60,7 +60,7 @@
target = (*it).second;
- if (argc == 4) { // if min / max specified
+ if (argc > 3) { // if min / max specified
scope = parser.ParseVerseList(argv[3], parser, true);
scope.Persist(1);
target->setKey(scope);
@@ -75,8 +75,17 @@
* -3 - entryAttrib (eg. Word//Lemma/G1234/)
* -4 - Lucene
*/
- listkey = target->Search(searchTerm.c_str(), -2, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
+ listkey = target->Search(searchTerm.c_str(), -4, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
std::cout << "\n";
+ if (argc > 4) { // if min / max specified
+ scope = listkey;
+ scope.Persist(1);
+ target->setKey(scope);
+ printed = 0;
+ std::cout << " ";
+ listkey = target->Search(argv[4], -4, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
+ std::cout << "\n";
+ }
listkey.sort();
while (!listkey.Error()) {
std::cout << (const char *)listkey << std::endl;
Modified: trunk/src/keys/listkey.cpp
===================================================================
--- trunk/src/keys/listkey.cpp 2007-11-24 17:58:08 UTC (rev 2122)
+++ trunk/src/keys/listkey.cpp 2007-11-24 19:56:30 UTC (rev 2123)
@@ -296,7 +296,7 @@
for (arraypos = 0; arraypos < arraycnt; arraypos++) {
SWKey *key = array[arraypos];
if (key) {
- if (key->isTraversable()) {
+ if (key->isTraversable() && key->isBoundSet()) {
key->setText(ikey);
if (!key->Error())
break;
More information about the sword-cvs
mailing list