bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#63807: bug in compose-gstring-for-terminal?


From: Mattias Engdegård
Subject: bug#63807: bug in compose-gstring-for-terminal?
Date: Wed, 31 May 2023 15:49:23 +0200

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 via email to

[Prev in Thread] Current Thread [Next in Thread]