[sword-svn] r2712 - in trunk: src/keys tests/testsuite

scribe at crosswire.org scribe at crosswire.org
Tue Jul 31 08:39:24 MST 2012


Author: scribe
Date: 2012-07-31 08:39:24 -0700 (Tue, 31 Jul 2012)
New Revision: 2712

Modified:
   trunk/src/keys/versekey.cpp
   trunk/tests/testsuite/verseparsing.good
   trunk/tests/testsuite/verseparsing.sh
Log:
Cleaned up suffix parsing.


Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp	2012-07-23 20:49:06 UTC (rev 2711)
+++ trunk/src/keys/versekey.cpp	2012-07-31 15:39:24 UTC (rev 2712)
@@ -593,7 +593,14 @@
 			tobook = 0;
 			bookno = -1;
 			if (*book) {
-				for (loop = strlen(book) - 1; loop+1; loop--) {
+				loop = strlen(book) - 1;
+
+				for (; loop+1; loop--) { if (book[loop] == ' ') book[loop] = 0; else break; }
+
+				if (loop > 0 && isdigit(book[loop-1]) && book[loop] >= 'a' && book[loop] <= 'z') {
+					book[loop--] = 0;
+				}
+				for (; loop+1; loop--) {
 					if ((isdigit(book[loop])) || (book[loop] == ' ')) {
 						book[loop] = 0;
 						continue;
@@ -795,9 +802,15 @@
 					break;
 				default:
 					// suffixes (and oddly 'f'-- ff.)
-					if (((*buf >= 'a' && *buf <= 'z') && (chap >=0)) || *buf == 'f') {
+					if ((*buf >= 'a' && *buf <= 'z' && (chap >=0 || bookno > -1 || lastKey->isBoundSet()))
+							|| *buf == 'f') {
 						// if suffix is already an 'f', then we need to mark if we're doubleF.
 						doubleF = (*buf == 'f' && suffix == 'f');
+						if (suffix && !doubleF) {
+							// we've already had a suffix one, so this is another letter, thus any number is not a number, e.g., '2jn'. We're on 'n'
+							number[tonumber] = 0;
+							tonumber = 0;
+						}
 						suffix = *buf;
 					}
 					else {
@@ -823,7 +836,14 @@
 	book[tobook] = 0;
 	tobook = 0;
 	if (*book) {
-		for (loop = strlen(book) - 1; loop+1; loop--) {
+		loop = strlen(book) - 1;
+
+		for (; loop+1; loop--) { if (book[loop] == ' ') book[loop] = 0; else break; }
+
+		if (loop > 0 && isdigit(book[loop-1]) && book[loop] >= 'a' && book[loop] <= 'z') {
+			book[loop--] = 0;
+		}
+		for (; loop+1; loop--) {
 			if ((isdigit(book[loop])) || (book[loop] == ' ')) {
 				book[loop] = 0;
 				continue;
@@ -1044,7 +1064,10 @@
 		tmpClone->setVerse   (lowerBoundComponents.verse);
 		tmpClone->setSuffix  (lowerBoundComponents.suffix);
 	}
-	else tmpClone->setIndex(lowerBound);
+	else {
+		tmpClone->setIndex(lowerBound);
+		tmpClone->setSuffix  (lowerBoundComponents.suffix);
+	}
 
 	return (*tmpClone);
 }
@@ -1064,7 +1087,10 @@
 		tmpClone->setVerse   (upperBoundComponents.verse);
 		tmpClone->setSuffix  (upperBoundComponents.suffix);
 	}
-	else tmpClone->setIndex(upperBound);
+	else {
+		tmpClone->setIndex(upperBound);
+		tmpClone->setSuffix  (upperBoundComponents.suffix);
+	}
 
 	return (*tmpClone);
 }

Modified: trunk/tests/testsuite/verseparsing.good
===================================================================
--- trunk/tests/testsuite/verseparsing.good	2012-07-23 20:49:06 UTC (rev 2711)
+++ trunk/tests/testsuite/verseparsing.good	2012-07-31 15:39:24 UTC (rev 2712)
@@ -56,8 +56,9 @@
 1Jn 1:1 ;3:10 en KJV ge 1: I John 1:1; I John 3:10
 1Jn 1:1 ; 3:10 en KJV ge 1: I John 1:1; I John 3:10
 1Jn 1:1a ; 3:10b en KJV ge 1: I John 1:1a; I John 3:10b
-1Jn 1:1-2a; 3:10b-11 en KJV ge 1: I John 1:1-Revelation of John 22:21; I John 3:10b-I John 3:11
-1Jn 1:1c;3:10d-12e,13 en KJV ge 1: I John 1:1c; I John 3:10d; I John 3:13
+1Jn 1:1-2a; 3:10b-11 en KJV ge 1: I John 1:1-I John 1:2a; I John 3:10b-I John 3:11
+1Jn 1:1c;3:10d-12e,13 en KJV ge 1: I John 1:1c; I John 3:10d-I John 3:12e; I John 3:13
+Luke 2:45b-3:1a;3:1b-7;3:8-14;3:15-21a en KJV ge 1: Luke 2:45b-Luke 3:1a; Luke 3:1b-Luke 3:7; Luke 3:8-Luke 3:14; Luke 3:15-Luke 3:21a
 1Jn1.1f; 3:10ff en KJV ge 1: I John 1:1-I John 1:2; I John 3:10-I John 3:24
 1Jn1.1ff;3:10f en KJV ge 1: I John 1:1-I John 1:10; I John 3:10-I John 3:11
 1Jn1.1,8ff; 3:10-12,14f,17ff en KJV ge 1: I John 1:1; I John 1:8-I John 1:10; I John 3:10-I John 3:12; I John 3:14-I John 3:15; I John 3:17-I John 3:24

Modified: trunk/tests/testsuite/verseparsing.sh
===================================================================
--- trunk/tests/testsuite/verseparsing.sh	2012-07-23 20:49:06 UTC (rev 2711)
+++ trunk/tests/testsuite/verseparsing.sh	2012-07-31 15:39:24 UTC (rev 2712)
@@ -85,9 +85,10 @@
 ../parsekey "1Jn 1:1 ; 3:10" en KJV ge 1
 ../parsekey "1Jn 1:1a ; 3:10b" en KJV ge 1
 
-### These two are not quite right yet
+### Suffix parsing
 ../parsekey "1Jn 1:1-2a; 3:10b-11" en KJV ge 1
 ../parsekey "1Jn 1:1c;3:10d-12e,13" en KJV ge 1
+../parsekey "Luke 2:45b-3:1a;3:1b-7;3:8-14;3:15-21a" en KJV ge 1
 
 ../parsekey "1Jn1.1f; 3:10ff" en KJV ge 1
 ../parsekey "1Jn1.1ff;3:10f" en KJV ge 1




More information about the sword-cvs mailing list