From cbe604acdd0303d821bb87707a9a5532fb2a2853 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Tue, 25 Feb 2025 10:21:47 -0500
Subject: [PATCH] CSI < c only takes one manditory argument with default

Fixes bug introduced in cc07b354 where the command without any
parameters would not return anything.
---
 src/conio/cterm.c | 40 +++++++++++++++++++---------------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/conio/cterm.c b/src/conio/cterm.c
index e6f6d01674..ed377853a1 100644
--- a/src/conio/cterm.c
+++ b/src/conio/cterm.c
@@ -2636,28 +2636,26 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
 						case 'c':
 							/* SyncTERM Device Attributes */
 							if (seq->param_str[0] == '<' && parse_parameters(seq)) {
+								seq_default(seq, 0, 0);
 								tmp[0] = 0;
-								for (i=0; i<seq->param_count; i++) {
-									seq_default(seq, i, 0);
-									switch (seq->param_int[i]) {
-										case 0:		/* Advanced features */
-											strcpy(tmp, "\x1b[<0");
-											if (cio_api.options & CONIO_OPT_LOADABLE_FONTS)
-												strcat(tmp, ";1");
-											if (cio_api.options & CONIO_OPT_BRIGHT_BACKGROUND)
-												strcat(tmp, ";2");
-											if (cio_api.options & CONIO_OPT_PALETTE_SETTING)
-												strcat(tmp, ";3");
-											if (cio_api.options & CONIO_OPT_SET_PIXEL)
-												strcat(tmp, ";4");
-											if (cio_api.options & CONIO_OPT_FONT_SELECT)
-												strcat(tmp, ";5");
-											if (cio_api.options & CONIO_OPT_EXTENDED_PALETTE)
-												strcat(tmp, ";6");
-											if (cio_api.mouse)
-												strcat(tmp, ";7");
-											strcat(tmp, "c");
-									}
+								switch (seq->param_int[0]) {
+									case 0:		/* Advanced features */
+										strcpy(tmp, "\x1b[<0");
+										if (cio_api.options & CONIO_OPT_LOADABLE_FONTS)
+											strcat(tmp, ";1");
+										if (cio_api.options & CONIO_OPT_BRIGHT_BACKGROUND)
+											strcat(tmp, ";2");
+										if (cio_api.options & CONIO_OPT_PALETTE_SETTING)
+											strcat(tmp, ";3");
+										if (cio_api.options & CONIO_OPT_SET_PIXEL)
+											strcat(tmp, ";4");
+										if (cio_api.options & CONIO_OPT_FONT_SELECT)
+											strcat(tmp, ";5");
+										if (cio_api.options & CONIO_OPT_EXTENDED_PALETTE)
+											strcat(tmp, ";6");
+										if (cio_api.mouse)
+											strcat(tmp, ";7");
+										strcat(tmp, "c");
 								}
 								if(retbuf && *tmp && strlen(retbuf) + strlen(tmp) < retsize)
 									strcat(retbuf, tmp);
-- 
GitLab