From df2e700cd5231c2174c0a5c860cb099e117badb8 Mon Sep 17 00:00:00 2001 From: meator Date: Thu, 17 Jun 2021 22:22:41 +0200 Subject: [PATCH] cgdb: fix escape sequences This commit adds a patch that fixes bad escape sequences in prompt. This should be fixed in next release of cgdb. The patch is based of https://github.com/cgdb/cgdb/issues/239#issuecomment-706249589 and https://github.com/cgdb/cgdb/issues/255#issuecomment-820546156. --- srcpkgs/cgdb/patches/fixescape.patch | 48 ++++++++++++++++++++++++++++ srcpkgs/cgdb/template | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/cgdb/patches/fixescape.patch diff --git a/srcpkgs/cgdb/patches/fixescape.patch b/srcpkgs/cgdb/patches/fixescape.patch new file mode 100644 index 000000000000..529e832108d7 --- /dev/null +++ b/srcpkgs/cgdb/patches/fixescape.patch @@ -0,0 +1,48 @@ +From 242ea26b6f4aa7ce2ce56cbb1b50cd93a3126a57 Mon Sep 17 00:00:00 2001 +From: meator +Date: Thu, 17 Jun 2021 21:30:06 +0200 +Subject: [PATCH] Patch + +This is a patch for v0.7.1 of cgdb. It fixes bad escape sequences in prompt string. Based of https://github.com/cgdb/cgdb/issues/239#issuecomment-706249589 and https://github.com/cgdb/cgdb/issues/255#issuecomment-820546156. + +--- + cgdb/scroller.cpp | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +diff --git a/cgdb/scroller.cpp b/cgdb/scroller.cpp +index 2d01e82..d2d36ca 100644 +--- a/cgdb/scroller.cpp ++++ b/cgdb/scroller.cpp +@@ -106,14 +106,27 @@ static char *parse(struct scroller *scr, struct hl_line_attr **attrs, + /* Carriage return -> Move back to the beginning of the line */ + case '\r': + i = 0; +- if (buf[j + 1] != '\n') { ++ if ((buflen - j) >= 1 && buf[j + 1] != '\n') { + sbfree(*attrs); + *attrs = NULL; + } + break; + case '\033': + /* Handle ansi escape characters */ +- if (hl_ansi_color_support(hl_groups_instance) && ++ /* see https://conemu.github.io/en/AnsiEscapeCodes.html#SGR_Select_Graphic_Rendition_parameters ++ */ ++ if ((buflen - j) >= 6 ++ && buf[j + 1] == '[' && buf[j + 2] == '?' && buf[j + 3] == '2' ++ && buf[j + 4] == '0' && buf[j + 5] == '0' && buf[j + 6] == '4') { ++ /* simply ignore these escape sequences like e.g. "[?2004h" */ ++ j += 7; ++ } else if ((buflen - j) >= 2 && buf[j + 1] == '[' && buf[j + 2] == '?') { ++ /* simply ignore these escape sequences like e.g. "[?1h" */ ++ j += 4; ++ } else if ((buflen - j) >= 1 && (buf[j + 1] == '=' || buf[j + 1] == '>')) { ++ /* simply ignore these escape sequences */ ++ j += 1; ++ } else if (hl_ansi_color_support(hl_groups_instance) && + debugwincolor) { + int attr; + int ansi_count = hl_ansi_get_color_attrs( +-- +2.32.0 + diff --git a/srcpkgs/cgdb/template b/srcpkgs/cgdb/template index bf75df74a341..86ce9b0b8dd0 100644 --- a/srcpkgs/cgdb/template +++ b/srcpkgs/cgdb/template @@ -1,7 +1,7 @@ # Template file for 'cgdb' pkgname=cgdb version=0.7.1 -revision=1 +revision=2 build_style=gnu-configure configure_args="ac_cv_rl_version=6.3 ac_cv_file__proc_self_status=yes"