pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

doomlegacy-devel: Add support for "\n" line breaks in UMAPINFO key "intertext".



Module Name:	pkgsrc-wip
Committed By:	Michael Baeuerle <micha%NetBSD.org@localhost>
Pushed By:	micha
Date:		Wed Aug 23 16:40:56 2023 +0200
Changeset:	9d6a948a03359ec0b1faf5789b5f1c26a034ee3c

Modified Files:
	doomlegacy-devel/TODO
	doomlegacy-devel/files/umapinfo.c

Log Message:
doomlegacy-devel: Add support for "\n" line breaks in UMAPINFO key "intertext".

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=9d6a948a03359ec0b1faf5789b5f1c26a034ee3c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 doomlegacy-devel/TODO             |  1 +
 doomlegacy-devel/files/umapinfo.c | 17 +++++++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diffs:
diff --git a/doomlegacy-devel/TODO b/doomlegacy-devel/TODO
index ba447b43ee..45301fb740 100644
--- a/doomlegacy-devel/TODO
+++ b/doomlegacy-devel/TODO
@@ -12,6 +12,7 @@ Part 25: Add UMAPINFO support
     => Module to parse and import data added
 [X] Hook keys into game engine
     => All keys should work now, up to the limits of the engine
+[X] Add support for "\n" line breaks in key "intertext".
 
 => Created upstream feature request ticket #100
 
diff --git a/doomlegacy-devel/files/umapinfo.c b/doomlegacy-devel/files/umapinfo.c
index 0f909f4f9c..698244e656 100644
--- a/doomlegacy-devel/files/umapinfo.c
+++ b/doomlegacy-devel/files/umapinfo.c
@@ -225,17 +225,26 @@ static char *UMI_GetQString(doom_umi1_ts_state state, size_t *len)
 
 
 // Accept only printable ASCII characters. Others are replaced with '?'
-// If parameter 'multiline' is true, LF control characters are accepted too
+// If parameter 'multiline' is true:
+// - LF control characters are accepted too
+// - Escape sequences "\n" are converted to SP LF
 static void UMI_ConvertToASCII(char *str, size_t length, boolean multiline)
 {
     size_t i = 0;
 
     for (i = 0; length > i; ++i)
     {
-       if (multiline && 0x0A == str[i])
-           continue;
+        if (multiline && 0x0A == str[i])
+            continue;
 
-       if (0x20 > str[i] || 0x7E < str[i])
+        if (0 < i && 0x5C == str[i - 1u] && 'n' == str[i])
+        {
+            str[i - 1u] = ' ';
+            str[i] = 0x0A;
+            continue;
+        }
+
+        if (0x20 > str[i] || 0x7E < str[i])
             str[i] = '?';
     }
 }


Home | Main Index | Thread Index | Old Index