[Scummvm-git-logs] scummvm master -> 9b63c7b83e8b6eb2a7a5bd92a844b3f4df787c10
sev-
sev at scummvm.org
Wed Jan 22 22:00:17 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
00b49814c5 DIRECTOR: LINGO: Add number of functions.
9b63c7b83e DIRECTOR: LINGO: Implement code layout advice.
Commit: 00b49814c5b597b72208c0423a313e532c81a991
https://github.com/scummvm/scummvm/commit/00b49814c5b597b72208c0423a313e532c81a991
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2020-01-22T23:00:12+01:00
Commit Message:
DIRECTOR: LINGO: Add number of functions.
numberofchars: Is the string length
numberofitems: Count of ','. An empty string counts as 1 item.
numberoflines: Count of '\n'. An empty string counts as 1 line.
Changed paths:
engines/director/lingo/lingo-builtins.cpp
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index ef6e5db..17ae0ac 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1774,20 +1774,33 @@ void LB::b_window(int nargs) {
void LB::b_numberofchars(int nargs) {
Datum d = g_lingo->pop();
+ d.toString();
- warning("STUB: b_numberofchars");
- d.toInt();
- d.u.i = 0;
+ int len = strlen(d.u.s->c_str());
+ delete d.u.s;
+ d.u.i = len;
+ d.type = INT;
g_lingo->push(d);
}
void LB::b_numberofitems(int nargs) {
Datum d = g_lingo->pop();
- warning("STUB: b_numberofitems");
- d.toInt();
- d.u.i = 0;
+ d.toString();
+ int numberofitems = 1;
+ Common::String contents = d.u.s->c_str();
+ uint32 i = 0;
+ while (i < d.u.s->size()){
+ if (contents[i] == ',') {
+ numberofitems++;
+ }
+ ++i;
+ }
+ delete d.u.s;
+
+ d.u.i = numberofitems;
+ d.type = INT;
g_lingo->push(d);
}
@@ -1795,9 +1808,20 @@ void LB::b_numberofitems(int nargs) {
void LB::b_numberoflines(int nargs) {
Datum d = g_lingo->pop();
- warning("STUB: b_numberoflines");
- d.toInt();
- d.u.i = 0;
+ d.toString();
+ int numberoflines = 1;
+ Common::String contents = d.u.s->c_str();
+ uint32 i = 0;
+ while (i < d.u.s->size()){
+ if (contents[i] == '\n') {
+ numberoflines++;
+ }
+ ++i;
+ }
+ delete d.u.s;
+
+ d.u.i = numberoflines;
+ d.type = INT;
g_lingo->push(d);
}
Commit: 9b63c7b83e8b6eb2a7a5bd92a844b3f4df787c10
https://github.com/scummvm/scummvm/commit/9b63c7b83e8b6eb2a7a5bd92a844b3f4df787c10
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2020-01-22T23:00:12+01:00
Commit Message:
DIRECTOR: LINGO: Implement code layout advice.
Changed paths:
engines/director/lingo/lingo-builtins.cpp
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 17ae0ac..4ce2c18 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1789,13 +1789,10 @@ void LB::b_numberofitems(int nargs) {
d.toString();
int numberofitems = 1;
- Common::String contents = d.u.s->c_str();
- uint32 i = 0;
- while (i < d.u.s->size()){
- if (contents[i] == ',') {
+ Common::String contents = *d.u.s;
+ for (uint32 i = 0; i < d.u.s->size(); i++) {
+ if (contents[i] == ',')
numberofitems++;
- }
- ++i;
}
delete d.u.s;
@@ -1811,12 +1808,9 @@ void LB::b_numberoflines(int nargs) {
d.toString();
int numberoflines = 1;
Common::String contents = d.u.s->c_str();
- uint32 i = 0;
- while (i < d.u.s->size()){
- if (contents[i] == '\n') {
+ for (uint32 i = 0; i < d.u.s->size(); i++) {
+ if (contents[i] == '\n')
numberoflines++;
- }
- ++i;
}
delete d.u.s;
More information about the Scummvm-git-logs
mailing list