mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
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:
parent
39d711696a
commit
88c18efb3a
1 changed files with 15 additions and 10 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue