Eigenstate: myrddin-dev mailing list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/4] Allow litint with nontrivial start


---
 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


References:
[PATCH 0/4] Fixes to allow using terminfo for colors on st"S. Gilles" <sgilles@xxxxxxxxxxxx>