[sword-svn] r3567 - trunk/utilities

scribe at crosswire.org scribe at crosswire.org
Sun Feb 18 18:55:50 MST 2018


Author: scribe
Date: 2018-02-18 18:55:49 -0700 (Sun, 18 Feb 2018)
New Revision: 3567

Modified:
   trunk/utilities/imp2vs.cpp
Log:
added new option to imp2vs to allow augmenting a module but replacing entries (-r) instead of appending to end of existing entries

Modified: trunk/utilities/imp2vs.cpp
===================================================================
--- trunk/utilities/imp2vs.cpp	2018-02-17 21:54:56 UTC (rev 3566)
+++ trunk/utilities/imp2vs.cpp	2018-02-19 01:55:49 UTC (rev 3567)
@@ -52,7 +52,7 @@
 
 using namespace std;
 
-void writeEntry(SWModule *module, const SWBuf &key, const SWBuf &entry);
+void writeEntry(SWModule *module, const SWBuf &key, const SWBuf &entry, bool replace);
 
 void usage(const char *progName, const char *error = 0) {
 	if (error) fprintf(stderr, "\n%s: %s\n", progName, error);
@@ -106,6 +106,7 @@
 	
 	bool fourByteSize      = false;
 	bool append	    = false;
+	bool replace	    = false;
 	int iType	      = 4;
 	SWBuf cipherKey        = "";
 	SWCompress *compressor = 0;
@@ -115,6 +116,9 @@
 		if (!strcmp(argv[i], "-a")) {
 			append = true;
 		}
+		else if (!strcmp(argv[i], "-r")) {
+			replace = true;
+		}
 		else if (!strcmp(argv[i], "-z")) {
 			if (fourByteSize) usage(*argv, "Cannot specify both -z and -4");
 			compType = "ZIP";
@@ -265,7 +269,7 @@
 		more = FileMgr::getLine(fd, lineBuffer)!=0;
 		if (lineBuffer.startsWith("$$$")) {
 			if ((keyBuffer.size()) && (entBuffer.size())) {
-				writeEntry(module, keyBuffer, entBuffer);
+				writeEntry(module, keyBuffer, entBuffer, replace);
 			}
 			keyBuffer = lineBuffer;
 			keyBuffer << 3;
@@ -280,7 +284,7 @@
 		}
 	} while (more);
 	if ((keyBuffer.size()) && (entBuffer.size())) {
-		writeEntry(module, keyBuffer, entBuffer);
+		writeEntry(module, keyBuffer, entBuffer, replace);
 	}
 
 	delete module;
@@ -298,7 +302,7 @@
 int page = 0;
 
 
-void writeEntry(SWModule *module, const SWBuf &key, const SWBuf &entry)
+void writeEntry(SWModule *module, const SWBuf &key, const SWBuf &entry, bool replace)
 {
 	if (key.size() && entry.size()) {
 		std::cout << "from file: " << key << std::endl;
@@ -312,7 +316,7 @@
 			*vkey = listKey;
 			if (first) {
 				*linkMaster = *vkey;
-				SWBuf text = module->getRawEntry();
+				SWBuf text = (replace) ? "" : module->getRawEntry();
 				text += entry;
 
 




More information about the sword-cvs mailing list