[sword-svn] r2294 - in trunk: include src/modules/lexdict src/modules/lexdict/rawld src/modules/lexdict/rawld4 src/modules/lexdict/zld

scribe at crosswire.org scribe at crosswire.org
Sun Mar 29 07:48:48 MST 2009


Author: scribe
Date: 2009-03-29 07:48:47 -0700 (Sun, 29 Mar 2009)
New Revision: 2294

Modified:
   trunk/include/rawld.h
   trunk/include/rawld4.h
   trunk/include/swld.h
   trunk/include/zld.h
   trunk/src/modules/lexdict/rawld/rawld.cpp
   trunk/src/modules/lexdict/rawld4/rawld4.cpp
   trunk/src/modules/lexdict/swld.cpp
   trunk/src/modules/lexdict/zld/zld.cpp
Log:
Isolated strongsPad to SWLD and applied Ben's update to handle prefix and bang


Modified: trunk/include/rawld.h
===================================================================
--- trunk/include/rawld.h	2009-03-29 14:09:43 UTC (rev 2293)
+++ trunk/include/rawld.h	2009-03-29 14:48:47 UTC (rev 2294)
@@ -31,7 +31,6 @@
 SWORD_NAMESPACE_START
 
 class SWDLLEXPORT RawLD : public RawStr, public SWLD {
-	void strongsPad(char *buf);
 	char getEntry(long away = 0);
 
 public:

Modified: trunk/include/rawld4.h
===================================================================
--- trunk/include/rawld4.h	2009-03-29 14:09:43 UTC (rev 2293)
+++ trunk/include/rawld4.h	2009-03-29 14:48:47 UTC (rev 2294)
@@ -31,7 +31,6 @@
 SWORD_NAMESPACE_START
 
 class SWDLLEXPORT RawLD4 : public RawStr4, public SWLD {
-	void strongsPad(char *buf);
 	char getEntry(long away = 0);
 
 public:

Modified: trunk/include/swld.h
===================================================================
--- trunk/include/swld.h	2009-03-29 14:09:43 UTC (rev 2293)
+++ trunk/include/swld.h	2009-03-29 14:48:47 UTC (rev 2294)
@@ -35,6 +35,7 @@
 class SWDLLEXPORT SWLD : public SWModule {
 protected:
 	char *entkeytxt;
+	static void strongsPad(char *buf);
 public:
 	/** Initializes data for instance of SWLD
 	*/

Modified: trunk/include/zld.h
===================================================================
--- trunk/include/zld.h	2009-03-29 14:09:43 UTC (rev 2293)
+++ trunk/include/zld.h	2009-03-29 14:48:47 UTC (rev 2294)
@@ -31,8 +31,6 @@
 SWORD_NAMESPACE_START
 
 class SWDLLEXPORT zLD : public zStr, public SWLD {
-
-	void strongsPad(char *buf);
 	char getEntry(long away = 0);
 
 public:

Modified: trunk/src/modules/lexdict/rawld/rawld.cpp
===================================================================
--- trunk/src/modules/lexdict/rawld/rawld.cpp	2009-03-29 14:09:43 UTC (rev 2293)
+++ trunk/src/modules/lexdict/rawld/rawld.cpp	2009-03-29 14:48:47 UTC (rev 2294)
@@ -19,8 +19,6 @@
  *
  */
 
-#include <ctype.h>
-#include <stdio.h>
 #include <fcntl.h>
 
 #include <utilstr.h>
@@ -59,50 +57,6 @@
 
 
 /******************************************************************************
- * RawLD::strongsPad	- Pads a key if (it-1) is 100% digits to 5 places
- *						allows for final to be alpha, e.g. '123B'
- *
- * ENT: buf -	buffer to check and pad
- */
-
-void RawLD::strongsPad(char *buf)
-{
-	char *check;
-	int size = 0;
-	int len = strlen(buf);
-	char subLet = 0;
-	bool bang = false;
-	if ((len < 8) && (len > 0)) {
-		for (check = buf; *(check+1); check++) {
-			if (!isdigit(*check))
-				break;
-			else size++;
-		}
-
-		if (size && ((size == (len-1)) || (size == (len-2)))) {
-			if (*check == '!') {
-				bang = true;
-				check++;
-			}
-			if (isalpha(*check)) {
-				subLet = toupper(*check);
-				*(check-(bang?1:0)) = 0;
-			}
-			sprintf(buf, "%.5d", atoi(buf));
-			if (subLet) {
-				check = buf+(strlen(buf));
-				if (bang) {
-					*check++ = '!';
-				}
-				*check++ = subLet;
-				*check = 0;
-			}
-		}
-	}
-}
-
-
-/******************************************************************************
  * RawLD::getEntry	- Looks up entry from data file.  'Snaps' to closest
  *				entry and sets 'entrybuf'.
  *

Modified: trunk/src/modules/lexdict/rawld4/rawld4.cpp
===================================================================
--- trunk/src/modules/lexdict/rawld4/rawld4.cpp	2009-03-29 14:09:43 UTC (rev 2293)
+++ trunk/src/modules/lexdict/rawld4/rawld4.cpp	2009-03-29 14:48:47 UTC (rev 2294)
@@ -19,8 +19,6 @@
  *
  */
 
-#include <ctype.h>
-#include <stdio.h>
 #include <fcntl.h>
 
 #include <filemgr.h>
@@ -59,50 +57,6 @@
 
 
 /******************************************************************************
- * RawLD4::strongsPad	- Pads a key if (it-1) is 100% digits to 5 places
- *						allows for final to be alpha, e.g. '123B'
- *
- * ENT: buf -	buffer to check and pad
- */
-
-void RawLD4::strongsPad(char *buf)
-{
-	char *check;
-	int size = 0;
-	int len = strlen(buf);
-	char subLet = 0;
-	bool bang = false;
-	if ((len < 8) && (len > 0)) {
-		for (check = buf; *(check+1); check++) {
-			if (!isdigit(*check))
-				break;
-			else size++;
-		}
-
-		if (size && ((size == (len-1)) || (size == (len-2)))) {
-			if (*check == '!') {
-				bang = true;
-				check++;
-			}
-			if (isalpha(*check)) {
-				subLet = toupper(*check);
-				*(check-(bang?1:0)) = 0;
-			}
-			sprintf(buf, "%.5d", atoi(buf));
-			if (subLet) {
-				check = buf+(strlen(buf));
-				if (bang) {
-					*check++ = '!';
-				}
-				*check++ = subLet;
-				*check = 0;
-			}
-		}
-	}
-}
-
-
-/******************************************************************************
  * RawLD4::getEntry	- Looks up entry from data file.  'Snaps' to closest
  *				entry and sets 'entrybuf'.
  *

Modified: trunk/src/modules/lexdict/swld.cpp
===================================================================
--- trunk/src/modules/lexdict/swld.cpp	2009-03-29 14:09:43 UTC (rev 2293)
+++ trunk/src/modules/lexdict/swld.cpp	2009-03-29 14:48:47 UTC (rev 2294)
@@ -19,6 +19,8 @@
  *
  */
 
+#include <ctype.h>
+#include <stdio.h>
 #include <swld.h>
 #include <strkey.h>
 
@@ -95,4 +97,55 @@
 }
 
 
+/******************************************************************************
+ * SWLD::strongsPad	- Pads a key if (it-1) is 100% digits to 5 places
+ *						allows for final to be alpha, e.g. '123B'
+ *
+ * ENT: buf -	buffer to check and pad
+ */
+
+void SWLD::strongsPad(char *buf)
+{
+	char *check;
+	int size = 0;
+	int len = strlen(buf);
+	char subLet = 0;
+	bool bang = false, prefix=false;
+	if ((len < 9) && (len > 0)) {
+		// Handle initial G or H
+		if (*buf == 'G' || *buf == 'H' || *buf == 'g' || *buf == 'h') {
+			buf += 1;
+			len -= 1;
+			prefix = true;
+		}
+
+		for (check = buf; *(check); check++) {
+			if (!isdigit(*check))
+				break;
+			else size++;
+		}
+
+		if (size && ((size == len) || (size == len - 1) || (size == (len-2)))) {
+			if (*check == '!') {
+				bang = true;
+				check++;
+			}
+			if (isalpha(*check)) {
+				subLet = toupper(*check);
+				*(check-(bang?1:0)) = 0;
+			}
+			sprintf(buf, prefix?"%.4d":"%.5d", atoi(buf));
+			if (subLet) {
+				check = buf+(strlen(buf));
+				if (bang) {
+					*check++ = '!';
+				}
+				*check++ = subLet;
+				*check = 0;
+			}
+		}
+	}
+}
+
+
 SWORD_NAMESPACE_END

Modified: trunk/src/modules/lexdict/zld/zld.cpp
===================================================================
--- trunk/src/modules/lexdict/zld/zld.cpp	2009-03-29 14:09:43 UTC (rev 2293)
+++ trunk/src/modules/lexdict/zld/zld.cpp	2009-03-29 14:48:47 UTC (rev 2294)
@@ -18,8 +18,6 @@
  *
  */
 
-#include <ctype.h>
-#include <stdio.h>
 #include <fcntl.h>
 
 #include <utilstr.h>
@@ -58,48 +56,6 @@
 
 
 /******************************************************************************
- * zLD::strongsPad	- Pads a key if it is 100% digits to 5 places
- *
- * ENT: buf -	buffer to check and pad
- */
-
-void zLD::strongsPad(char *buf) {
-	char *check;
-	int size = 0;
-	int len = strlen(buf);
-	char subLet = 0;
-	bool bang = false;
-	if ((len < 8) && (len > 0)) {
-		for (check = buf; *(check+1); check++) {
-			if (!isdigit(*check))
-				break;
-			else size++;
-		}
-
-		if (size && ((size == (len-1)) || (size == (len-2)))) {
-			if (*check == '!') {
-				bang = true;
-				check++;
-			}
-			if (isalpha(*check)) {
-				subLet = toupper(*check);
-				*(check-(bang?1:0)) = 0;
-			}
-			sprintf(buf, "%.5d", atoi(buf));
-			if (subLet) {
-				check = buf+(strlen(buf));
-				if (bang) {
-					*check++ = '!';
-				}
-				*check++ = subLet;
-				*check = 0;
-			}
-		}
-	}
-}
-
-
-/******************************************************************************
  * zLD::getEntry	- Looks up entry from data file.  'Snaps' to closest
  *				entry and sets 'entrybuf'.
  *




More information about the sword-cvs mailing list