[Scummvm-git-logs] scummvm master -> 2d2d61f8ff2285d24a67a82485fb9970ff5cd69d

rvanlaar noreply at scummvm.org
Thu Sep 15 12:49:31 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
2d2d61f8ff DIRECTOR: LINGO: Fix deleting first item


Commit: 2d2d61f8ff2285d24a67a82485fb9970ff5cd69d
    https://github.com/scummvm/scummvm/commit/2d2d61f8ff2285d24a67a82485fb9970ff5cd69d
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-09-15T14:46:46+02:00

Commit Message:
DIRECTOR: LINGO: Fix deleting first item

Given an item list: "lorem,ipsum,dolor,sit,amet" and the lingo code:
`delete item 1 of list`.
The first item "lorem" was deleted but without the comma. Leaving an
empty first item.

In Star Trek: The Next Generation Interactive Technical Manual the
code repeatedly deleted the first item till it encountered an `@`.
The result was a loop in which it was stuck.

- Includes lingo test.

Changed paths:
    engines/director/lingo/lingo-code.cpp
    engines/director/lingo/tests/delete.lingo


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 307f8139ab7..e6a6fc5738a 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1737,9 +1737,13 @@ void LC::c_delete() {
 			break;
 		case kChunkItem:
 		case kChunkLine:
-			// last char of the first portion is the delimiter. skip it.
-			if (start > 0)
+			// when deleting the first item, include the delimiter after the item
+			// deleting another item, remove the delimiter in front
+			if (start == 0) {
+				end++;
+			} else {
 				start--;
+			}
 			break;
 		}
 	}
diff --git a/engines/director/lingo/tests/delete.lingo b/engines/director/lingo/tests/delete.lingo
index dcab0c170bb..00c2142e996 100644
--- a/engines/director/lingo/tests/delete.lingo
+++ b/engines/director/lingo/tests/delete.lingo
@@ -42,6 +42,10 @@ put "lorem,ipsum,dolor,sit,amet" into test
 delete item 2 to 5 of test
 scummvmAssertEqual(test, "lorem")
 
+put "lorem,ipsum,dolor,sit,amet" into test
+delete item 1 of test
+scummvmAssertEqual(test, "ipsum,dolor,sit,amet")
+
 put "lorem,ipsum,dolor,sit,amet" into test
 delete the last item of test
 scummvmAssertEqual(test, "lorem,ipsum,dolor,sit")




More information about the Scummvm-git-logs mailing list