shithub: mc

Download patch

ref: adbf59398978f304071df1e933e0e01a9d6027b7
parent: 6042e40dd30c9e04934e635274a013f989695eb7
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jun 30 20:09:17 EDT 2018

Fix escaping of closing '}' in fmt.

--- a/6/gengas.c
+++ b/6/gengas.c
@@ -171,8 +171,7 @@
 		/* %-formating */
 		p++;
 		idx = i;
-again
-:
+again:
 		switch (*p) {
 		case '\0':
 			goto done; /* skip the final p++ */
--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -195,9 +195,11 @@
 				nbuf = 0
 			;;
 		| (`Copy, '}'):
-			if i < fmt.len && (fmt[i] : char) == '}'
-				sbputb(sb, ('}' : byte))
+			if i == fmt.len || (fmt[i] : char) != '}'
+				die("unescaped '}'\n")
 			;;
+			sbputb(sb, ('}' : byte))
+			i++
 		| (`Copy, _):
 			sbputb(sb, b)