Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions system/mtm/mtm.SlackBuild
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ fi
tar xvf $CWD/$PRGNAM-$VERSION.tar.?z*
cd $PRGNAM-$VERSION

# Backport upstream commit 6af156e (Add nuke keystroke)
patch -p1 < $CWD/mtm-1.2.1-nuke.patch

# Add documentation for Ctrl+g k (nuke) keystroke to man page
patch -p1 < $CWD/mtm-1.2.1-man-nuke.patch
cat $CWD/patches/series | while read patch ; do
echo "*** Applying patch $patch"
cat $CWD/patches/$patch | patch -p1 --verbose || exit 1
done || exit 1

chown -R root:root .

Expand Down
19 changes: 19 additions & 0 deletions system/mtm/patches/0001-fix-empty-commandkey-arg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
From: r1w1s1 <r1w1s1@fastmail.com>
Date: Wed, 22 Apr 2026
Subject: Reject empty argument to -c flag

Without this check, `mtm -c ""` dereferences optarg[0] which is '\0',
making CTL('\0') == 0 the command prefix. Every NUL byte in PTY input
then triggers command mode. Ignore empty strings and keep the default.
---
--- a/mtm.c
+++ b/mtm.c
@@ -665,7 +665,7 @@ main(int argc, char **argv)

int c = 0;
while ((c = getopt(argc, argv, "c:T:t:")) != -1) switch (c){
- case 'c': commandkey = CTL(optarg[0]); break;
+ case 'c': if (optarg[0]) commandkey = CTL(optarg[0]); break;
case 'T': setenv("TERM", optarg, 1); break;
case 't': term = optarg; break;
default: quit(EXIT_FAILURE, USAGE); break;
39 changes: 39 additions & 0 deletions system/mtm/patches/0002-fix-sgr-truecolor-param-consumption.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From: r1w1s1 <r1w1s1@fastmail.com>
Date: Wed, 22 Apr 2026
Subject: Fix SGR parameter consumption for truecolor sequences

SGR 38/48 can take either `;5;N` (256-color) or `;2;R;G;B` (truecolor).
The old code assumed ;5;N and always skipped 2 params, so `;2;R;G;B`
caused R, G, B to be reinterpreted as SGR codes, producing garbage
attributes. Handle both forms and skip the correct number of params.
Truecolor values are not rendered (ncurses pair limitation) but are
now consumed cleanly.
---
--- a/mtm.c
+++ b/mtm.c
@@ -449,7 +449,11 @@
case 35: fg = COLOR_MAGENTA; doc = do8; break;
case 36: fg = COLOR_CYAN; doc = do8; break;
case 37: fg = COLOR_WHITE; doc = do8; break;
- case 38: fg = P0(i+1) == 5? P0(i+2) : s->fg; i += 2; doc = do256; break;
+ case 38:
+ if (P0(i+1) == 5) { fg = P0(i+2); i += 2; doc = do256; }
+ else if (P0(i+1) == 2) { i += 4; }
+ else i += 1;
+ break;
case 39: fg = -1; doc = true; break;
case 40: bg = COLOR_BLACK; doc = do8; break;
case 41: bg = COLOR_RED; doc = do8; break;
@@ -459,7 +463,11 @@
case 45: bg = COLOR_MAGENTA; doc = do8; break;
case 46: bg = COLOR_CYAN; doc = do8; break;
case 47: bg = COLOR_WHITE; doc = do8; break;
- case 48: bg = P0(i+1) == 5? P0(i+2) : s->bg; i += 2; doc = do256; break;
+ case 48:
+ if (P0(i+1) == 5) { bg = P0(i+2); i += 2; doc = do256; }
+ else if (P0(i+1) == 2) { i += 4; }
+ else i += 1;
+ break;
case 49: bg = -1; doc = true; break;
case 90: fg = COLOR_BLACK; doc = do16; break;
case 91: fg = COLOR_RED; doc = do16; break;
4 changes: 4 additions & 0 deletions system/mtm/patches/series
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mtm-1.2.1-man-nuke.patch
mtm-1.2.1-nuke.patch
0001-fix-empty-commandkey-arg.patch
0002-fix-sgr-truecolor-param-consumption.patch
Loading