[sword-svn] r2335 - in trunk: include src/keys src/utilfuns
scribe at crosswire.org
scribe at crosswire.org
Fri Apr 24 07:51:54 MST 2009
Author: scribe
Date: 2009-04-24 07:51:54 -0700 (Fri, 24 Apr 2009)
New Revision: 2335
Modified:
trunk/include/roman.h
trunk/src/keys/versekey.cpp
trunk/src/utilfuns/roman.cpp
Log:
Fixed roman numeral processing where "PS C" is ok, but "II C" is not ok :)
Modified: trunk/include/roman.h
===================================================================
--- trunk/include/roman.h 2009-04-24 00:14:12 UTC (rev 2334)
+++ trunk/include/roman.h 2009-04-24 14:51:54 UTC (rev 2335)
@@ -24,7 +24,7 @@
/** Checks if a string is a roman numeral.
*/
-char isroman(const char *);
+char isroman(const char *, int maxchars = 0);
/* char* to_rom(int num, char *p); */
/** Converts a roman numeral to a string.
Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp 2009-04-24 00:14:12 UTC (rev 2334)
+++ trunk/src/keys/versekey.cpp 2009-04-24 14:51:54 UTC (rev 2335)
@@ -580,7 +580,8 @@
for (loop = strlen(book) - 1; loop+1; loop--) {
if (book[loop] == ' ') {
- if (isroman(&book[loop+1])) {
+ // "PS C" is ok, but "II C" is not ok
+ if (isroman(&book[loop+1]) && !isroman(book,loop)) {
if (verse == -1) {
verse = chap;
chap = from_rom(&book[loop+1]);
@@ -791,7 +792,8 @@
for (loop = strlen(book) - 1; loop+1; loop--) {
if (book[loop] == ' ') {
- if (isroman(&book[loop+1])) {
+ // "PS C" is ok, but "II C" is not ok
+ if (isroman(&book[loop+1]) && !isroman(book,loop)) {
if (verse == -1) {
verse = chap;
chap = from_rom(&book[loop+1]);
@@ -800,7 +802,7 @@
}
break;
}
- }
+ }
if ((!stricmp(book, "V")) || (!stricmp(book, "VER"))) { // Verse abbrev.
if (verse == -1) {
Modified: trunk/src/utilfuns/roman.cpp
===================================================================
--- trunk/src/utilfuns/roman.cpp 2009-04-24 00:14:12 UTC (rev 2334)
+++ trunk/src/utilfuns/roman.cpp 2009-04-24 14:51:54 UTC (rev 2335)
@@ -23,9 +23,9 @@
SWORD_NAMESPACE_START
-char isroman (const char* str) {
- char * ch = (char*)str;
- for (; *ch; ch++)
+char isroman (const char *str, int maxchars) {
+ char *ch = (char*)str;
+ for (; *ch && (!maxchars || (ch-str) <= maxchars); ch++)
if (!strchr("IVXLCDMivxlcdm ", *ch))
return 0;
return 1;
More information about the sword-cvs
mailing list