unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 63807@debbugs.gnu.org
Subject: bug#63807: bug in compose-gstring-for-terminal?
Date: Wed, 31 May 2023 15:49:23 +0200	[thread overview]
Message-ID: <559C2D0F-D71E-433B-AE1A-888EBBD134CD@gmail.com> (raw)
In-Reply-To: <83a5xkfyc8.fsf@gnu.org>

31 maj 2023 kl. 15.02 skrev Eli Zaretskii <eliz@gnu.org>:

> Setting i to 2 is correct there

Would you explain why to someone who doesn't know how this is supposed to work?
There may be external invariants rescuing the mistake from having serious consequences so that the code is correct in a narrow sense but relying that is generally poor style.

It looks quite obvious that the intent is to increment i by 2; compare with the other clause,

		(progn
		  ;; Compose Cf (format) control characters by
		  ;; replacing with a space.
		  (lglyph-set-char glyph 32)
		  (lglyph-set-width glyph 1)
		  (setq i (1+ i)))

where a character is replaced with a space and we step to the next. In the (non-Cf) clause under scrutiny, we insert a space and, presumably, step past both characters:

	      ;; Compose by prepending a space.
	      (setq gstring (lgstring-insert-glyph gstring i
						   (lglyph-copy glyph))
		    nglyphs (lgstring-glyph-len gstring))
	      (setq glyph (lgstring-glyph gstring i))
	      (lglyph-set-char glyph 32)
	      (lglyph-set-width glyph 1)
	      (setq i (+ 2))

The main question is whether changing the last assignment to (setq i (+ i 2)) would have unintended consequences. As far as I've been able to determine, testing and inspection say no, it should be completely safe.






  reply	other threads:[~2023-05-31 13:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30 20:36 bug#63807: bug in compose-gstring-for-terminal? Mattias Engdegård
2023-05-31 13:02 ` Eli Zaretskii
2023-05-31 13:49   ` Mattias Engdegård [this message]
2023-05-31 14:30     ` Eli Zaretskii
2023-05-31 15:08       ` Mattias Engdegård
2023-05-31 16:15         ` Eli Zaretskii
2023-05-31 17:23           ` Mattias Engdegård

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=559C2D0F-D71E-433B-AE1A-888EBBD134CD@gmail.com \
    --to=mattias.engdegard@gmail.com \
    --cc=63807@debbugs.gnu.org \
    --cc=eliz@gnu.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.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).