[Scummvm-git-logs] scummvm master -> 6e5d7c23951a83de6a9496bcc475837d35e76179

rvanlaar roland at rolandvanlaar.nl
Sun Aug 8 22:24:23 UTC 2021


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:
6e5d7c2395 DEVTOOLS: COMPANION: bring escape inline


Commit: 6e5d7c23951a83de6a9496bcc475837d35e76179
    https://github.com/scummvm/scummvm/commit/6e5d7c23951a83de6a9496bcc475837d35e76179
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2021-08-09T00:22:18+02:00

Commit Message:
DEVTOOLS: COMPANION: bring escape inline

Original dumper-companion.pl script encoded \x81 to \x81\x79\x81.
- added test to check for correct behavior
- refactored escape string to handle this special case

Changed paths:
    devtools/dumper-companion.py


diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index 1cb0dc8f1b..3ae3aee453 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -52,10 +52,14 @@ def file_to_macbin(f: machfs.File, name: str, encoding: str) -> bytes:
 
 
 def escape_string(s: str) -> str:
-    new_name = [
-        "\x81" + chr(0x80 + ord(i)) if i in '/":*[]+|\\?%<>,;=' or ord(i) < 0x20 else i
-        for i in s
-    ]
+    new_name = ""
+    for char in s:
+        if char == "\x81":
+            new_name += "\x81\x79"
+        if char in '/":*[]+|\\?%<>,;=' or ord(char) < 0x20:
+            new_name += "\x81" + chr(0x80 + ord(char))
+        else:
+            new_name += char
     return "".join(new_name)
 
 
@@ -190,6 +194,6 @@ def test_decode_name():
 
 
 def test_escape_string():
-    checks = [["\r", "\x81\x8d"]]
+    checks = [["\r", "\x81\x8d"], ["\x81", "\x81\x79\x81"]]
     for input, expected in checks:
         assert escape_string(input) == expected




More information about the Scummvm-git-logs mailing list