diff options
| author | Stephen Gildea | 2025-10-15 20:42:07 -0700 |
|---|---|---|
| committer | Stephen Gildea | 2025-10-15 20:44:47 -0700 |
| commit | 88c18efb3a1b9e48a5fb72b80cc7cdd5d03fa894 (patch) | |
| tree | b9ddc21bafbc28a0dfa42f8c11b19894d846c44e | |
| parent | 39d711696ae61c72711789417983c43df3dc34b1 (diff) | |
| download | emacs-88c18efb3a1b9e48a5fb72b80cc7cdd5d03fa894.tar.gz emacs-88c18efb3a1b9e48a5fb72b80cc7cdd5d03fa894.zip | |
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.
| -rw-r--r-- | lisp/time-stamp.el | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el index faf5d51d441..1280c86bcbe 100644 --- a/lisp/time-stamp.el +++ b/lisp/time-stamp.el | |||
| @@ -769,16 +769,21 @@ and all `time-stamp-format' compatibility." | |||
| 769 | (eq cur-char ?X)) ;full system name, experimental | 769 | (eq cur-char ?X)) ;full system name, experimental |
| 770 | (system-name)) | 770 | (system-name)) |
| 771 | )) | 771 | )) |
| 772 | (and (numberp field-result) | 772 | (if (numberp field-result) |
| 773 | (= colon-cnt 0) | 773 | (progn |
| 774 | (or (string-equal field-width "") | 774 | (and (= colon-cnt 0) |
| 775 | (string-equal field-width "0")) | 775 | (or (string-equal field-width "") |
| 776 | ;; no width provided; set width for default | 776 | (string-equal field-width "0")) |
| 777 | (setq field-width "02")) | 777 | ;; no width provided; set width for default |
| 778 | (format (format "%%%s%c" | 778 | (setq field-width "02")) |
| 779 | field-width | 779 | (format (format "%%%sd" field-width) |
| 780 | (if (numberp field-result) ?d ?s)) | 780 | (or field-result ""))) |
| 781 | (or field-result "")))))) ;end of handle-one-conversion | 781 | (let* ((field-width-num (string-to-number field-width)) |
| 782 | (needed-padding (- field-width-num (length field-result)))) | ||
| 783 | (if (> needed-padding 0) | ||
| 784 | (concat (make-string needed-padding ?\s) field-result) | ||
| 785 | field-result))) | ||
| 786 | )))) ;end of handle-one-conversion | ||
| 782 | ;; iterate over the format string | 787 | ;; iterate over the format string |
| 783 | (while (< ind fmt-len) | 788 | (while (< ind fmt-len) |
| 784 | (setq cur-char (aref format ind)) | 789 | (setq cur-char (aref format ind)) |