[PATCH 1/4] Allow litint with nontrivial start
[Thread Prev] | [Thread Next]
- Subject: [PATCH 1/4] Allow litint with nontrivial start
- From: "S. Gilles" <sgilles@xxxxxxxxxxxx>
- Reply-to: myrddin-dev@xxxxxxxxxxxxxx
- Date: Thu, 26 Oct 2017 21:06:42 -0400
- To: "myrddin-dev" <myrddin-dev@xxxxxxxxxxxxxx>
- Cc: "S. Gilles" <sgilles@xxxxxxxxxxxx>
---
test/tifmt.myr | 8 ++++++++
tifmt.myr | 3 ++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/test/tifmt.myr b/test/tifmt.myr
index 01a3fbb..cd02fd5 100644
--- a/test/tifmt.myr
+++ b/test/tifmt.myr
@@ -20,6 +20,14 @@ const main = {
checkfmt(ctx, "%i%p1%d-%p2%d-%p3%s", params, "124-244-abc")
}],
+ /* literals */
+ [.name="litint-1", .fn={ctx
+ checkfmt(ctx, "%{5}%d", [`termdraw.Int 9][:], "5")
+ }],
+ [.name="litint-2", .fn={ctx
+ checkfmt(ctx, "%{5}%{6}%d", [`termdraw.Int 9][:], "6")
+ }],
+
/* numeric */
[.name="arith-add", .fn={ctx; binop(ctx, 'd', '+', 10, 21, "31")}],
[.name="arith-sub", .fn={ctx; binop(ctx, 'd', '-', 21, 10, "-11")}],
diff --git a/tifmt.myr b/tifmt.myr
index 9168be8..29f0831 100644
--- a/tifmt.myr
+++ b/tifmt.myr
@@ -324,6 +324,7 @@ const strfmt = {f, sb, lpad, width, prec, str
const scannum = {s : byte[:], start
var i, c
+ var begin = start#
i = start
while true
@@ -333,7 +334,7 @@ const scannum = {s : byte[:], start
;;
i# += std.charlen(c)
;;
- match std.intparse(s[:i#])
+ match std.intparse(s[begin:i#])
| `std.Some n: -> n
| `std.None: -> 0
;;
--
2.14.3
| [PATCH 0/4] Fixes to allow using terminfo for colors on st | "S. Gilles" <sgilles@xxxxxxxxxxxx> |
- Prev by Date: [PATCH 0/4] Fixes to allow using terminfo for colors on st
- Next by Date: [PATCH 2/4] Reorder binary operations
- Previous by thread: [PATCH 0/4] Fixes to allow using terminfo for colors on st
- Next by thread: [PATCH 2/4] Reorder binary operations
- Index(es):