summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-06-11 07:36:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-06-11 07:36:02 -0700
commitf7c05ba9ec1634ec6d127e8e5b3edafc834ab2f0 (patch)
treea8d075b8534b2ebfa03ca8a121865802a9f1bc35 /share
parent1a583e55bddab7b2146a7a3bfb51e7fcda87608b (diff)
downloadtxr-f7c05ba9ec1634ec6d127e8e5b3edafc834ab2f0.tar.gz
txr-f7c05ba9ec1634ec6d127e8e5b3edafc834ab2f0.tar.bz2
txr-f7c05ba9ec1634ec6d127e8e5b3edafc834ab2f0.zip
pic: allow trailing exclamation.
* share/txr/stdlib/pic.tl (expand-pic-num, expand-pic, pic): Allow ### to be followed by a single !. This is not counted toward the field width. * tests/018/format.tl: Cover with some tests. * txr.1: Doc updated.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/pic.tl5
1 files changed, 3 insertions, 2 deletions
diff --git a/share/txr/stdlib/pic.tl b/share/txr/stdlib/pic.tl
index 25a9c70b..a6228334 100644
--- a/share/txr/stdlib/pic.tl
+++ b/share/txr/stdlib/pic.tl
@@ -32,6 +32,7 @@
(minus (eql [fmt 0] #\-))
(exc (pos #\! fmt))
(dot (or exc (pos #\. fmt)))
+ (fmt (if (and exc (eq #\! [fmt -1])) [fmt 0..-1] fmt))
(int (if dot [fmt 0..dot] fmt))
(fra (if dot [fmt (succ dot)..:] "")))
(let ((code (if (or minus plus (not zero))
@@ -80,7 +81,7 @@
([m^$ #/\~[~#<>\|\-+0.!]/ fmt] [fmt 1..2])
([m^$ #/\~./ fmt] (compile-error f "unrecognized escape sequence ~a" fmt))
([m^$ #/\~/ fmt] (compile-error f "incomplete ~~ escape"))
- ([m^$ #/[+\-]?0?#+([.!]#+)?/ fmt] (expand-pic-num fmt val))
+ ([m^$ #/[+\-]?0?#+([.!]#+|!)?/ fmt] (expand-pic-num fmt val))
([m^$ #/<+/ fmt] (expand-pic-align "<" fmt val))
([m^$ #/>+/ fmt] (expand-pic-align nil fmt val))
([m^$ #/\|+/ fmt] (expand-pic-align "^" fmt val))
@@ -89,7 +90,7 @@
(defmacro pic (:form f :env e bigfmt . args)
(unless (stringp bigfmt)
(compile-error f "~s is required to be a format string" bigfmt))
- (let* ((regex #/[+\-]?0?#+([.!]#+)?| \
+ (let* ((regex #/[+\-]?0?#+([.!]#+|!)?| \
<+| \
>+| \
\|+| \