[sword-svn] r3403 - trunk/utilities
dmsmith at crosswire.org
dmsmith at crosswire.org
Tue Feb 9 09:53:41 MST 2016
Author: dmsmith
Date: 2016-02-09 09:53:41 -0700 (Tue, 09 Feb 2016)
New Revision: 3403
Modified:
trunk/utilities/imp2gbs.cpp
trunk/utilities/imp2vs.cpp
Log:
MODTOOLS-92 imp2vs multiline entry bug fixed. Changes patterned after imp2gbs
Modified: trunk/utilities/imp2gbs.cpp
===================================================================
--- trunk/utilities/imp2gbs.cpp 2016-02-09 07:18:54 UTC (rev 3402)
+++ trunk/utilities/imp2gbs.cpp 2016-02-09 16:53:41 UTC (rev 3403)
@@ -126,8 +126,8 @@
outPath.size(i);
}
}
-
+
void writeEntry(SWModule *book, SWBuf keyBuffer, SWBuf entBuffer) {
@@ -222,22 +222,22 @@
int main(int argc, char **argv) {
greekAccentsFilter.setOptionValue("Off"); // off = accents off
parseParams(argc, argv);
-
+
// Let's see if we can open our input file
FileDesc *fd = FileMgr::getSystemFileMgr()->open(inFile, FileMgr::RDONLY);
if (fd->getFd() < 0) {
fprintf(stderr, "error: %s: couldn't open input file: %s \n", argv[0], inFile.c_str());
exit(-2);
}
-
+
RawGenBook *book;
-
+
// Do some initialization stuff
if (!augMod) {
RawGenBook::createModule(outPath);
}
book = new RawGenBook(outPath);
-
+
SWBuf lineBuffer;
SWBuf keyBuffer;
SWBuf entBuffer;
Modified: trunk/utilities/imp2vs.cpp
===================================================================
--- trunk/utilities/imp2vs.cpp 2016-02-09 07:18:54 UTC (rev 3402)
+++ trunk/utilities/imp2vs.cpp 2016-02-09 16:53:41 UTC (rev 3403)
@@ -51,7 +51,7 @@
using namespace std;
-void writeEntry(const SWBuf &key, const SWBuf &entry, SWModule *module);
+void writeEntry(SWModule *module, const SWBuf &key, const SWBuf &entry);
void usage(const char *progName, const char *error = 0) {
if (error) fprintf(stderr, "\n%s: %s\n", progName, error);
@@ -241,28 +241,37 @@
FileDesc *fd = FileMgr::getSystemFileMgr()->open(inFileName, FileMgr::RDONLY);
SWBuf lineBuffer;
- SWBuf currentKey;
- SWBuf currentEntry;
+ SWBuf keyBuffer;
+ SWBuf entBuffer;
- while (FileMgr::getLine(fd, lineBuffer)) {
- if (lineBuffer.startsWith("$$$")) {
- writeEntry(currentKey, currentEntry, module);
- currentKey = lineBuffer;
- currentKey << 3;
- currentKey.trim();
- currentEntry = "";
- }
- else {
- currentEntry += lineBuffer;
- }
- }
- writeEntry(currentKey, currentEntry, module);
+ bool more = true;
+ do {
+ more = FileMgr::getLine(fd, lineBuffer)!=0;
+ if (lineBuffer.startsWith("$$$")) {
+ if ((keyBuffer.size()) && (entBuffer.size())) {
+ writeEntry(module, keyBuffer, entBuffer);
+ }
+ keyBuffer = lineBuffer;
+ keyBuffer << 3;
+ keyBuffer.trim();
+ entBuffer.size(0);
+ }
+ else {
+ if (keyBuffer.size()) {
+ entBuffer += lineBuffer;
+ entBuffer += "\n";
+ }
+ }
+ } while (more);
+ if ((keyBuffer.size()) && (entBuffer.size())) {
+ writeEntry(module, keyBuffer, entBuffer);
+ }
- FileMgr::getSystemFileMgr()->close(fd);
-
delete module;
delete vkey;
+ FileMgr::getSystemFileMgr()->close(fd);
+
return 0;
}
@@ -271,7 +280,7 @@
int page = 0;
-void writeEntry(const SWBuf &key, const SWBuf &entry, SWModule *module)
+void writeEntry(SWModule *module, const SWBuf &key, const SWBuf &entry)
{
if (key.size() && entry.size()) {
std::cout << "from file: " << key << std::endl;
More information about the sword-cvs
mailing list