shithub: mc

Download patch

ref: 9b7397fb8de58d9c9af0a6458d54f635e8415f65
parent: a0d80034b4b6a66839a8a8c0e325e747879648e8
author: Ori Bernstein <[email protected]>
date: Fri Jan 24 15:20:20 EST 2014

Fix formatting consecutive integers.

    There was a bug in the formatting code that made the base
    and signedness specifiers sticky, so, eg,

        put("%xi %i", a, b)

    would format both 'a' and 'b' as hex unsigned values Now we
    reset the state on each loop.

--- a/libstd/fmt.myr
+++ b/libstd/fmt.myr
@@ -142,11 +142,11 @@
 	var f_val : float64, F_val : float32
 
 	n = 0
-	base = 10
-	signed = true
 	while fmt.len
 		(c, fmt) = striter(fmt)
 		if c == '%'
+			base = 10
+			signed = true
 			(c, fmt) = striter(fmt)
 			/* modifiers */
 			if fmt.len > 0