zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@zsh.org>
To: Zsh workers <zsh-workers@zsh.org>
Subject: PATCH: fix .zle.sgr for empty sequences
Date: Sat, 09 Mar 2024 23:30:47 +0100	[thread overview]
Message-ID: <61192-1710023447.936507@Vf9U.zuLW.VgB3> (raw)

This fixes .zle.sgr from the new hlgroups module to return "0" when the
sequence is empty. In particular \e[m typically works them same as \e[0m
so we want to return the 0 in that case.

Oliver

diff --git a/Src/Modules/hlgroup.c b/Src/Modules/hlgroup.c
index 6382f3216..9c0aedcf8 100644
--- a/Src/Modules/hlgroup.c
+++ b/Src/Modules/hlgroup.c
@@ -59,6 +59,10 @@ convertattr(char *attrstr, int sgr)
 	    *t = ';';
 	    c++;
 	}
+	if (t <= s) { /* always return at least "0" */
+	    *s = '0';
+	    t = s + 1;
+	}
 	*t = '\0';
 	len = t - s;
     }


                 reply	other threads:[~2024-03-09 22:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61192-1710023447.936507@Vf9U.zuLW.VgB3 \
    --to=opk@zsh.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).