aboutsummaryrefslogtreecommitdiff
path: root/engines/director/lingo/lingo.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2016-07-09 21:20:03 +0200
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commitda408c0ad03429a4cbe9718491c1130fef47e1d1 (patch)
treec13fe30f33233c571442ff8630285bb2c7a32b4b /engines/director/lingo/lingo.cpp
parent8084989605853dd23e265a1f649e36611bdbfd99 (diff)
downloadscummvm-rg350-da408c0ad03429a4cbe9718491c1130fef47e1d1.tar.gz
scummvm-rg350-da408c0ad03429a4cbe9718491c1130fef47e1d1.tar.bz2
scummvm-rg350-da408c0ad03429a4cbe9718491c1130fef47e1d1.zip
DIRECTOR: Lingo: Implement 'contains' and 'starts' string operators
Diffstat (limited to 'engines/director/lingo/lingo.cpp')
-rw-r--r--engines/director/lingo/lingo.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 9ec89ff0af..9fe17f3be5 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -222,8 +222,9 @@ Common::String *Datum::toString() {
case STRING:
delete s;
s = u.s;
+ break;
default:
- warning("Incorrect operation toInt() for type: %s", type2str());
+ warning("Incorrect operation toString() for type: %s", type2str());
}
u.s = s;
@@ -250,4 +251,44 @@ const char *Datum::type2str() {
}
}
+// This is table for built-in Macintosh font lowercasing.
+// '.' means that the symbol should be not changed, rest
+// of the symbols are stripping the diacritics
+// The table starts from 0x80
+//
+// TODO: Check it for correctness.
+static char lowerCaseConvert[] =
+"aacenoua" // 80
+"aaaaacee" // 88
+"eeiiiino" // 90
+"oooouuuu" // 98
+"........" // a0
+".......o" // a8
+"........" // b0
+".......o" // b8
+"........" // c0
+".. aao.." // c8
+"--.....y";// d0-d8
+
+Common::String *Lingo::toLowercaseMac(Common::String *s) {
+ Common::String *res = new Common::String;
+ const unsigned char *p = (const unsigned char *)s->c_str();
+
+ while (*p) {
+ if (*p >= 0x80 && *p <= 0xd8) {
+ if (lowerCaseConvert[*p - 0x80] != '.')
+ *res += lowerCaseConvert[*p - 0x80];
+ else
+ *res += *p;
+ } else if (*p < 0x80) {
+ *res += tolower(*p);
+ } else {
+ error("Unacceptable symbol in toLowercaseMac: %c", *p);
+ }
+ p++;
+ }
+
+ return res;
+}
+
} // End of namespace Director