void RawCom4::increment(int steps) { long start; unsigned long size; VerseKey *tmpkey = &getVerseKey(); findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size); SWKey lastgood = *tmpkey; while (steps) { long laststart = start; unsigned long lastsize = size; SWKey lasttry = *tmpkey; (steps > 0) ? ++(*key) : --(*key); tmpkey = &getVerseKey(); if ((error = key->popError())) { *key = lastgood; break; } long index = tmpkey->getTestamentIndex(); findOffset(tmpkey->getTestament(), index, &start, &size); if ( (((laststart != start) || (lastsize != size)) // we're a different entry // && (start > 0) && (size)) // and we actually have a size ||(!skipConsecutiveLinks)) { // or we don't want to skip consecutive links steps += (steps < 0) ? 1 : -1; lastgood = *tmpkey; } } error = (error) ? KEYERR_OUTOFBOUNDS : 0; }
int main(int argc, char **argv) { long pos, offset; int num1, num2, rangemax; char startflag = 0; short size; checkparams(argc, argv); openfiles(argv[1]); testmnt = key1.getTestament(); num1 = key1.getChapter(); num2 = key1.getVerse(); pos = 0; write(bfp, &pos, 4); /* Book offset for testament intros */ pos = 4; write(cfp, &pos, 4); /* Chapter offset for testament intro */ /* Right now just zero out intros until parsing correctly */ pos = 0; size = 0; write(vfp, &pos, 4); /* Module intro */ write(vfp, &size, 2); write(vfp, &pos, 4); /* Testament intro */ write(vfp, &size, 2); while(!findbreak(fp, &offset, &num1, &num2, &rangemax, &size)) { if (!startflag) { startflag = 1; } else { if (num2 < key2.getVerse()) { // new chapter if (num1 <= key2.getChapter()) { // new book key2.setVerse(1); key2.setChapter(1); key2.setBook(key2.getBook()+1); } printf("Found Chapter Break: %d ('%s')\n", num1, (const char *)key2); chapoffset = offset; chapsize = size; // continue; } } key2.setVerse(1); key2.setChapter(num1); key2.setVerse(num2); key3 = key2; // key3 += (rangemax - key3.getVerse()); writeidx(key1, key2, key3, offset, size); } close(vfp); close(cfp); close(bfp); close(fp); return 0; }
void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size) { long pos; short tmp; for (; ((key1 <= key3) && (key1.popError() != KEYERR_OUTOFBOUNDS) && (key1.getTestament() == testmnt)); key1+=1) { if (key1.getVerse() == 1) { // new chapter if (key1.getChapter() == 1) { // new book pos = lseek(cfp, 0, SEEK_CUR); write(bfp, &pos, 4); pos = lseek(vfp, 0, SEEK_CUR); /* Book intro (cps) */ write(cfp, &pos, 4); write(vfp, &chapoffset, 4); /* Book intro (vss) set to same as chap for now(it should be chap 1 which usually contains the book into anyway)*/ write(vfp, &chapsize, 2); } pos = lseek(vfp, 0, SEEK_CUR); write(cfp, &pos, 4); write(vfp, &chapoffset, 4); /* Chapter intro */ write(vfp, &chapsize, 2); } if (key1 >= key2) { write(vfp, &offset, 4); write(vfp, &size, 2); } else { pos = 0; tmp = 0; write(vfp, &pos, 4); write(vfp, &tmp, 2); } } }
bool RawCom4::hasEntry(const SWKey *k) const { long start; unsigned long size; VerseKey *vk = &getVerseKey(k); findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size); return size; }
void RawCom::linkEntry(const SWKey *inkey) { VerseKey *destkey = &getVerseKey(); const VerseKey *srckey = &getVerseKey(inkey); doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex()); if (inkey != srckey) // free our key if we created a VerseKey delete srckey; }
SWBuf &RawCom4::getRawEntryBuf() const { long start = 0; unsigned long size = 0; VerseKey *key = &getVerseKey(); findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size); entrySize = size; // support getEntrySize call entryBuf = ""; readText(key->getTestament(), start, size, entryBuf); rawFilter(entryBuf, 0); // hack, decipher rawFilter(entryBuf, key); // if (!isUnicode()) prepText(entryBuf); return entryBuf; }
SWBuf &HREFCom::getRawEntryBuf() const { long start; unsigned short size; VerseKey *key = 0; key = &getVerseKey(); findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size); entrySize = size; // support getEntrySize call SWBuf tmpbuf; readText(key->getTestament(), start, size, tmpbuf); entryBuf = prefix; entryBuf += tmpbuf.c_str(); prepText(entryBuf); if (key != this->key) delete key; return entryBuf; }
char RawVerse::createModule(const char *ipath, const char *v11n) { char *path = 0; char *buf = new char [ strlen (ipath) + 20 ]; FileDesc *fd, *fd2; stdstr(&path, ipath); if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\')) path[strlen(path)-1] = 0; sprintf(buf, "%s/ot", path); FileMgr::removeFile(buf); fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); fd->getFd(); FileMgr::getSystemFileMgr()->close(fd); sprintf(buf, "%s/nt", path); FileMgr::removeFile(buf); fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); fd->getFd(); FileMgr::getSystemFileMgr()->close(fd); sprintf(buf, "%s/ot.vss", path); FileMgr::removeFile(buf); fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); fd->getFd(); sprintf(buf, "%s/nt.vss", path); FileMgr::removeFile(buf); fd2 = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); fd2->getFd(); VerseKey vk; vk.setVersificationSystem(v11n); vk.setIntros(1); __s32 offset = 0; __u16 size = 0; offset = archtosword32(offset); size = archtosword16(size); for (vk = TOP; !vk.popError(); vk++) { if (vk.getTestament() < 2) { fd->write(&offset, 4); fd->write(&size, 2); } else { fd2->write(&offset, 4); fd2->write(&size, 2); } } fd2->write(&offset, 4); fd2->write(&size, 2); FileMgr::getSystemFileMgr()->close(fd); FileMgr::getSystemFileMgr()->close(fd2); delete [] path; delete [] buf; return 0; }
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); if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\')) path[strlen(path)-1] = 0; sprintf(buf, "%s/ot.%czs", path, uniqueIndexID[blockBound]); FileMgr::removeFile(buf); 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/nt.%czs", path, uniqueIndexID[blockBound]); FileMgr::removeFile(buf); 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.%czz", path, uniqueIndexID[blockBound]); FileMgr::removeFile(buf); 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/nt.%czz", path, uniqueIndexID[blockBound]); FileMgr::removeFile(buf); 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); 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); if (fd2->getFd() < 1) goto erroropen2; vk.setVersificationSystem(v11n); vk.setIntros(true); offset = archtosword32(offset); size = archtosword16(size); for (vk = TOP; !vk.popError(); vk++) { if (vk.getTestament() < 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 { 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); 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 retVal; }
int main(int argc, char **argv) { SWCipher *zobj; VerseKey key; RawVerse *rawdrv; int ofd[2], oxfd[2]; long tmpoff = 0, offset, loffset = 0, lzoffset = 0; unsigned short size, lsize = 0, lzsize; char *tmpbuf; if (argc != 3) { fprintf(stderr, "usage: %s <datapath> \"<key>\"\n", argv[0]); exit(1); } rawdrv = new RawVerse(argv[1]); zobj = new SWCipher((unsigned char *)argv[2]); tmpbuf = new char [ strlen(argv[1]) + 11 ]; sprintf(tmpbuf, "%sot.zzz", argv[1]); ofd[0] = FileMgr::createPathAndFile(tmpbuf); sprintf(tmpbuf, "%sot.zzz.vss", argv[1]); oxfd[0] = FileMgr::createPathAndFile(tmpbuf); sprintf(tmpbuf, "%snt.zzz", argv[1]); ofd[1] = FileMgr::createPathAndFile(tmpbuf); sprintf(tmpbuf, "%snt.zzz.vss", argv[1]); oxfd[1] = FileMgr::createPathAndFile(tmpbuf); delete [] tmpbuf; printf("\n"); write(oxfd[0], &lzoffset, 4); write(oxfd[0], &lzsize, 2); write(oxfd[1], &lzoffset, 4); write(oxfd[1], &lzsize, 2); key.setAutoNormalize(false); key.setIntros(true); for (key.setIndex(0); (!key.popError()); key++) { rawdrv->findOffset(key.getTestament(), key.getIndex(), &offset, &size); printf("%s: OLD offset: %ld; size: %d\n", (const char *)key, offset, size); if ((offset == loffset) && (size == lsize)) { printf("using previous offset,size %d\n", size); offset = lseek(oxfd[key.getTestament() - 1], 0, SEEK_CUR); printf("%ld %ld %d \n", offset, lzoffset, lzsize); write(oxfd[key.getTestament() - 1], &lzoffset, 4); write(oxfd[key.getTestament() - 1], &lzsize, 2); } else { lsize = size; loffset = offset; if (size) { SWBuf tmpbuf; rawdrv->readText(key.getTestament(), offset, size, tmpbuf); zobj->Buf(tmpbuf.c_str(), size); unsigned long ulSize = size; zobj->cipherBuf(&ulSize); size = (unsigned int)ulSize; } offset = lseek(ofd[key.getTestament() - 1], 0, SEEK_CUR); tmpoff = lseek(oxfd[key.getTestament() - 1], 0, SEEK_CUR); printf("%s: (%ld) NEW offset: %ld; size: %d\n", (const char *)key, tmpoff, offset, size); write(oxfd[key.getTestament() - 1], &offset, 4); unsigned long ulSize = size; if (size) write(ofd[key.getTestament() - 1], zobj->cipherBuf(&ulSize), size); size = (unsigned int)ulSize; lzoffset = offset; write(oxfd[key.getTestament() - 1], &size, 2); lzsize = size; } } delete zobj; close(ofd[0]); close(oxfd[0]); close(ofd[1]); close(oxfd[1]); return 0; }
char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *module) { if (option) { char token[2112]; // cheese. Fix. int tokpos = 0; bool intoken = false; int word = 1; char val[128]; char *valto; char *ch; char wordstr[5]; unsigned int textStart = 0, lastAppendLen = 0, textEnd = 0; SWBuf tmp; bool newText = false; bool needWordOut = false; AttributeValue *wordAttrs = 0; SWBuf modName = (module)?module->getName():""; SWBuf wordSrcPrefix = modName; const SWBuf orig = text; const char * from = orig.c_str(); VerseKey *vkey = 0; if (key) { vkey = SWDYNAMIC_CAST(VerseKey, key); } for (text = ""; *from; from++) { if (*from == '<') { intoken = true; tokpos = 0; token[0] = 0; token[1] = 0; token[2] = 0; textEnd = text.length(); continue; } if (*from == '>') { // process tokens intoken = false; if (!strnicmp(token, "sync type=\"Strongs\" ", 20)) { // Strongs valto = val; for (unsigned int i = 27; token[i] != '\"' && i < 150; i++) *valto++ = token[i]; *valto = 0; if (atoi((!isdigit(*val))?val+1:val) < 5627) { // normal strongs number sprintf(wordstr, "%03d", word++); needWordOut = (word > 2); wordAttrs = &(module->getEntryAttributes()["Word"][wordstr]); (*wordAttrs)["Strongs"] = val; //printf("Adding: [\"Word\"][%s][\"Strongs\"] = %s\n", wordstr, val); tmp = ""; tmp.append(text.c_str()+textStart, (int)(textEnd - textStart)); (*wordAttrs)["Text"] = tmp; text.append("</span>"); SWBuf ts; ts.appendFormatted("%d", textStart); (*wordAttrs)["TextStart"] = ts; //printf("Adding: [\"Word\"][%s][\"Text\"] = %s\n", wordstr, tmp.c_str()); newText = true; } else { // verb morph (*wordAttrs)["Morph"] = val; //printf("Adding: [\"Word\"][%s][\"Morph\"] = %s\n", wordstr, val); } } if (!strncmp(token, "sync type=\"morph\"", 17)) { for (ch = token+17; *ch; ch++) { if (!strncmp(ch, "class=\"", 7)) { valto = val; for (unsigned int i = 7; ch[i] != '\"' && i < 127; i++) *valto++ = ch[i]; *valto = 0; (*wordAttrs)["MorphClass"] = val; //printf("Adding: [\"Word\"][%s][\"MorphClass\"] = %s\n", wordstr, val); } if (!strncmp(ch, "value=\"", 7)) { valto = val; for (unsigned int i = 7; ch[i] != '\"' && i < 127; i++) *valto++ = ch[i]; *valto = 0; (*wordAttrs)["Morph"] = val; //printf("Adding: [\"Word\"][%s][\"Morph\"] = %s\n", wordstr, val); } } newText = true; } // if not a strongs token, keep token in text text += '<'; text += token; text += '>'; if (needWordOut) { char wstr[10]; sprintf(wstr, "%03d", word-2); AttributeValue *wAttrs = &(module->getEntryAttributes()["Word"][wstr]); needWordOut = false; SWBuf strong = (*wAttrs)["Strongs"]; SWBuf morph = (*wAttrs)["Morph"]; SWBuf morphClass = (*wAttrs)["MorphClass"]; SWBuf wordText = (*wAttrs)["Text"]; SWBuf textSt = (*wAttrs)["TextStart"]; if (strong.size()) { char gh = 0; gh = isdigit(strong[0]) ? 0:strong[0]; if (!gh) { if (vkey) { gh = vkey->getTestament() ? 'H' : 'G'; } } else strong << 1; SWModule *sLex = 0; SWModule *sMorph = 0; if (gh == 'G') { sLex = defaultGreekLex; sMorph = defaultGreekParse; } if (gh == 'H') { sLex = defaultHebLex; sMorph = defaultHebParse; } SWBuf lexName = ""; if (sLex) { // we can pass the real lex name in, but we have some // aliases in the javascript to optimize bandwidth lexName = sLex->getName(); if (lexName == "StrongsGreek") lexName = "G"; if (lexName == "StrongsHebrew") lexName = "H"; } SWBuf wordID; if (vkey) { // optimize for bandwidth and use only the verse as the unique entry id wordID.appendFormatted("%d", vkey->getVerse()); } else { wordID = key->getText(); } for (unsigned int i = 0; i < wordID.size(); i++) { if ((!isdigit(wordID[i])) && (!isalpha(wordID[i]))) { wordID[i] = '_'; } } wordID.appendFormatted("_%s%d", wordSrcPrefix.c_str(), atoi(wstr)); if (textSt.size()) { int textStr = atoi(textSt.c_str()); textStr += lastAppendLen; SWBuf spanStart = ""; if (!sMorph) sMorph = 0; // avoid unused warnings for now /* if (sMorph) { SWBuf popMorph = "<a onclick=\""; popMorph.appendFormatted("p(\'%s\',\'%s\','%s','');\" >%s</a>", sMorph->getName(), morph.c_str(), wordID.c_str(), morph.c_str()); morph = popMorph; } */ // 'p' = 'fillpop' to save bandwidth const char *m = strchr(morph.c_str(), ':'); if (m) m++; else m = morph.c_str(); spanStart.appendFormatted("<span class=\"clk\" onclick=\"p('%s','%s','%s','%s','','%s');\" >", lexName.c_str(), strong.c_str(), wordID.c_str(), m, modName.c_str()); text.insert(textStr, spanStart); lastAppendLen = spanStart.length(); } } } if (newText) { textStart = text.length(); newText = false; } continue; } if (intoken) { if (tokpos < 2045) { token[tokpos++] = *from; // TODO: why is this + 2 ? token[tokpos+2] = 0; } } else { text += *from; } } char wstr[10]; sprintf(wstr, "%03d", word-1); AttributeValue *wAttrs = &(module->getEntryAttributes()["Word"][wstr]); needWordOut = false; SWBuf strong = (*wAttrs)["Strongs"]; SWBuf morph = (*wAttrs)["Morph"]; SWBuf morphClass = (*wAttrs)["MorphClass"]; SWBuf wordText = (*wAttrs)["Text"]; SWBuf textSt = (*wAttrs)["TextStart"]; if (strong.size()) { char gh = 0; gh = isdigit(strong[0]) ? 0:strong[0]; if (!gh) { if (vkey) { gh = vkey->getTestament() ? 'H' : 'G'; } } else strong << 1; SWModule *sLex = 0; if (gh == 'G') { sLex = defaultGreekLex; } if (gh == 'H') { sLex = defaultHebLex; } SWBuf lexName = ""; if (sLex) { // we can pass the real lex name in, but we have some // aliases in the javascript to optimize bandwidth lexName = sLex->getName(); if (lexName == "StrongsGreek") lexName = "G"; if (lexName == "StrongsHebrew") lexName = "H"; } SWBuf wordID; if (vkey) { // optimize for bandwidth and use only the verse as the unique entry id wordID.appendFormatted("%d", vkey->getVerse()); } else { wordID = key->getText(); } for (unsigned int i = 0; i < wordID.size(); i++) { if ((!isdigit(wordID[i])) && (!isalpha(wordID[i]))) { wordID[i] = '_'; } } wordID.appendFormatted("_%s%d", wordSrcPrefix.c_str(), atoi(wstr)); if (textSt.size()) { int textStr = atoi(textSt.c_str()); textStr += lastAppendLen; SWBuf spanStart = ""; // 'p' = 'fillpop' to save bandwidth const char *m = strchr(morph.c_str(), ':'); if (m) m++; else m = morph.c_str(); spanStart.appendFormatted("<span class=\"clk\" onclick=\"p('%s','%s','%s','%s','','%s');\" >", lexName.c_str(), strong.c_str(), wordID.c_str(), m, modName.c_str()); text.insert(textStr, spanStart); } } } return 0; }
void RawCom4::deleteEntry() { VerseKey *key = &getVerseKey(); doSetText(key->getTestament(), key->getTestamentIndex(), ""); }
void RawCom4::linkEntry(const SWKey *inkey) { VerseKey *destkey = &getVerseKey(); const VerseKey *srckey = &getVerseKey(inkey); doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex()); }
void RawCom4::setEntry(const char *inbuf, long len) { VerseKey *key = &getVerseKey(); doSetText(key->getTestament(), key->getTestamentIndex(), inbuf, len); }
char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *module) { SWBuf token; bool intoken = false; int wordNum = 1; char wordstr[5]; const char *wordStart = 0; SWBuf page = ""; // some modules include <seg> page info, so we add these to the words const SWBuf orig = text; const char * from = orig.c_str(); for (text = ""; *from; ++from) { if (*from == '<') { intoken = true; token = ""; continue; } if (*from == '>') { // process tokens intoken = false; // possible page seg -------------------------------- if (token.startsWith("seg ")) { XMLTag stag(token); SWBuf type = stag.getAttribute("type"); if (type == "page") { SWBuf number = stag.getAttribute("subtype"); if (number.length()) { page = number; } } } // --------------------------------------------------- if (token.startsWith("w ")) { // Word XMLTag wtag(token); if (module->isProcessEntryAttributes()) { wordStart = from+1; char gh = 0; VerseKey *vkey = 0; if (key) { vkey = SWDYNAMIC_CAST(VerseKey, key); } SWBuf lemma = ""; SWBuf morph = ""; SWBuf src = ""; SWBuf morphClass = ""; SWBuf lemmaClass = ""; const char *attrib; sprintf(wordstr, "%03d", wordNum); // why is morph entry attribute processing done in here? Well, it's faster. It makes more local sense to place this code in osismorph. // easier to keep lemma and morph in same wordstr number too maybe. if ((attrib = wtag.getAttribute("morph"))) { int count = wtag.getAttributePartCount("morph", ' '); int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 do { SWBuf mClass = ""; SWBuf mp = ""; attrib = wtag.getAttribute("morph", i, ' '); if (i < 0) i = 0; // to handle our -1 condition const char *m = strchr(attrib, ':'); if (m) { int len = m-attrib; mClass.append(attrib, len); attrib += (len+1); } if ((mClass == "x-Robinsons") || (mClass == "x-Robinson") || (mClass == "Robinson")) { mClass = "robinson"; } if (i) { morphClass += " "; morph += " "; } mp += attrib; morphClass += mClass; morph += mp; if (count > 1) { SWBuf tmp; tmp.setFormatted("Morph.%d", i+1); module->getEntryAttributes()["Word"][wordstr][tmp] = mp; tmp.setFormatted("MorphClass.%d", i+1); module->getEntryAttributes()["Word"][wordstr][tmp] = mClass; } } while (++i < count); } if ((attrib = wtag.getAttribute("lemma"))) { int count = wtag.getAttributePartCount("lemma", ' '); int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 do { gh = 0; SWBuf lClass = ""; SWBuf l = ""; attrib = wtag.getAttribute("lemma", i, ' '); if (i < 0) i = 0; // to handle our -1 condition const char *m = strchr(attrib, ':'); if (m) { int len = m-attrib; lClass.append(attrib, len); attrib += (len+1); } if ((lClass == "x-Strongs") || (lClass == "strong") || (lClass == "Strong")) { if (isdigit(attrib[0])) { if (vkey) { gh = vkey->getTestament() ? 'H' : 'G'; } } else { gh = *attrib; attrib++; } lClass = "strong"; } if (gh) l += gh; l += attrib; if (i) { lemmaClass += " "; lemma += " "; } lemma += l; lemmaClass += lClass; if (count > 1) { SWBuf tmp; tmp.setFormatted("Lemma.%d", i+1); module->getEntryAttributes()["Word"][wordstr][tmp] = l; tmp.setFormatted("LemmaClass.%d", i+1); module->getEntryAttributes()["Word"][wordstr][tmp] = lClass; } } while (++i < count); module->getEntryAttributes()["Word"][wordstr]["PartCount"].setFormatted("%d", count); } if ((attrib = wtag.getAttribute("src"))) { int count = wtag.getAttributePartCount("src", ' '); int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0 do { SWBuf mp = ""; attrib = wtag.getAttribute("src", i, ' '); if (i < 0) i = 0; // to handle our -1 condition if (i) src += " "; mp += attrib; src += mp; if (count > 1) { SWBuf tmp; tmp.setFormatted("Src.%d", i+1); module->getEntryAttributes()["Word"][wordstr][tmp] = mp; } } while (++i < count); } if (lemma.length()) module->getEntryAttributes()["Word"][wordstr]["Lemma"] = lemma; if (lemmaClass.length()) module->getEntryAttributes()["Word"][wordstr]["LemmaClass"] = lemmaClass; if (morph.length()) module->getEntryAttributes()["Word"][wordstr]["Morph"] = morph; if (morphClass.length()) module->getEntryAttributes()["Word"][wordstr]["MorphClass"] = morphClass; if (src.length()) module->getEntryAttributes()["Word"][wordstr]["Src"] = src; if (page.length()) module->getEntryAttributes()["Word"][wordstr]["Page"] = page; if (wtag.isEmpty()) { int j; for (j = token.length()-1; ((j>0) && (strchr(" /", token[j]))); j--); token.size(j+1); } token += " wn=\""; token += wordstr; token += "\""; if (wtag.isEmpty()) { token += "/"; } wordNum++; } if (!option) { /* * Code which handles multiple lemma types. Kindof works but breaks at least WEBIF filters for strongs. * int count = wtag.getAttributePartCount("lemma", ' '); for (int i = 0; i < count; i++) { SWBuf a = wtag.getAttribute("lemma", i, ' '); const char *prefix = a.stripPrefix(':'); if ((prefix) && (!strcmp(prefix, "x-Strongs") || !strcmp(prefix, "strong") || !strcmp(prefix, "Strong"))) { // remove attribute part wtag.setAttribute("lemma", 0, i, ' '); i--; count--; } } * Instead the codee below just removes the lemma attribute *****/ const char *l = wtag.getAttribute("lemma"); if (l) { SWBuf savlm = l; wtag.setAttribute("lemma", 0); wtag.setAttribute("savlm", savlm); token = wtag; token.trim(); // drop <> token << 1; token--; } } } if (token.startsWith("/w")) { // Word End if (module->isProcessEntryAttributes()) { if (wordStart) { SWBuf tmp; tmp.append(wordStart, (from-wordStart)-3); sprintf(wordstr, "%03d", wordNum-1); module->getEntryAttributes()["Word"][wordstr]["Text"] = tmp; } } wordStart = 0; } // keep token in text text.append('<'); text.append(token); text.append('>'); continue; } if (intoken) { token += *from; } else { text.append(*from); } } return 0; }