time-stamp: padding with mixed uni- and multibyte

* lisp/time-stamp.el (time-stamp-string-preprocess): Use
'length' instead of 'format' to calculate string padding,
so that we consistently count characters, not bytes.
This commit is contained in:
Stephen Gildea 2025-10-15 20:42:07 -07:00
parent 39d711696a
commit 88c18efb3a

View file

@ -769,16 +769,21 @@ and all `time-stamp-format' compatibility."
(eq cur-char ?X)) ;full system name, experimental
(system-name))
))
(and (numberp field-result)
(= colon-cnt 0)
(or (string-equal field-width "")
(string-equal field-width "0"))
;; no width provided; set width for default
(setq field-width "02"))
(format (format "%%%s%c"
field-width
(if (numberp field-result) ?d ?s))
(or field-result "")))))) ;end of handle-one-conversion
(if (numberp field-result)
(progn
(and (= colon-cnt 0)
(or (string-equal field-width "")
(string-equal field-width "0"))
;; no width provided; set width for default
(setq field-width "02"))
(format (format "%%%sd" field-width)
(or field-result "")))
(let* ((field-width-num (string-to-number field-width))
(needed-padding (- field-width-num (length field-result))))
(if (> needed-padding 0)
(concat (make-string needed-padding ?\s) field-result)
field-result)))
)))) ;end of handle-one-conversion
;; iterate over the format string
(while (< ind fmt-len)
(setq cur-char (aref format ind))