(svn r10792) -Fix [FS#1104]: when determining the gender of a string, do not assume that the gender is in the front of the string when there can be case switching code at that location.
authorrubidium
Sun, 05 Aug 2007 14:08:38 +0000
changeset 7411 6aa1fd67a914
parent 7410 14dc251e7ddb
child 7412 51db351a3313
(svn r10792) -Fix [FS#1104]: when determining the gender of a string, do not assume that the gender is in the front of the string when there can be case switching code at that location.
src/strings.cpp
--- a/src/strings.cpp	Sat Aug 04 23:35:27 2007 +0000
+++ b/src/strings.cpp	Sun Aug 05 14:08:38 2007 +0000
@@ -680,7 +680,18 @@
 				const char* s = GetStringPtr(argv_orig[(byte)*str++]); // contains the string that determines gender.
 				int len;
 				int gender = 0;
-				if (s != NULL && Utf8Consume(&s) == SCC_GENDER_INDEX) gender = (byte)s[0];
+				if (s != NULL) {
+					wchar_t c = Utf8Consume(&s);
+					/* Switch case is always put before genders, so remove those bits */
+					if (c == SCC_SWITCH_CASE) {
+						/* Skip to the last (i.e. default) case */
+						for (uint num = (byte)*s++; num != 0; num--) s += 3 + (s[1] << 8) + s[2];
+
+						c = Utf8Consume(&s);
+					}
+					/* Does this string have a gender, if so, set it */
+					if (c == SCC_GENDER_INDEX) gender = (byte)s[0];
+				}
 				str = ParseStringChoice(str, gender, buff, &len);
 				buff += len;
 				break;