From ba4307ca7897333e882a99e0964b1bdfb23d2492 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Sun, 11 Oct 2015 10:24:59 +0200
Subject: [PATCH] string_builder_sprintf: Fixed '+' for floats.

The floating point renderer used the wrong flag to indicate that
a sign was always wanted.

Also adds some comments about what string_builder_sprintf() supports.
---
 src/stralloc.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/src/stralloc.c b/src/stralloc.c
index f11c604c4d..3235b071e8 100644
--- a/src/stralloc.c
+++ b/src/stralloc.c
@@ -2868,6 +2868,44 @@ static LONGEST pike_va_int(VA_LIST_PTR args, int flags)
   return 0;
 }
 
+/* Standard formats supported by string_builder_{v,}sprintf():
+ *
+ *   '%'	Insert %.
+ *   'a'	Insert double.
+ *   'c'	Insert character.
+ *   'd'	Insert decimal integer.
+ *   'e'	Insert double.
+ *   'f'	Insert double.
+ *   'g'	Insert double.
+ *   'o'	Insert octal integer.
+ *   's'	Insert string.
+ *   'u'	Insert unsigned decimal integer.
+ *   'x'	Insert lower-case hexadecimal integer.
+ *   'E'	Insert double.
+ *   'G'	Insert double.
+ *   'X'	Insert upper-case hexadecimal integer.
+ *
+ * Format modifiers supported by string_builder_{v,}sprintf():
+ *
+ *   '+'	Explicit sign for non-negative numeric values.
+ *   '-'	Align left.
+ *   '0'	Zero pad.
+ *   '0'..'9'	Field width.
+ *   '.'	Precision field width follows.
+ *   'h'	Half-width input.
+ *   'l'	Long(-er) input.
+ *   't'	Pointer-width input (ptrdiff_t).
+ *   'w'	Wide input (same as 'l', but only for strings).
+ *   'z'	Pointer-width input (size_t).
+ *
+ * Extended formats supported by string_builder_{v,}sprintf():
+ *
+ *   'b'	Insert binary integer.
+ *   'O'	Insert description of svalue.
+ *   'S'	Insert pike_string.
+ *   'T'	Insert pike_type.
+ */
+
 /* Values used internally in string_builder_vsprintf() */
 #define STATE_MIN_WIDTH	1
 #define STATE_PRECISION 2
@@ -3079,7 +3117,7 @@ PMOD_EXPORT void string_builder_vsprintf(struct string_builder *s,
 	    if (val < 0.0) {
 	      string_builder_putchar(s, '-');
 	      val = -val;
-	    } else if (flags & APPEND_SIGNED) {
+	    } else if (flags & APPEND_POSITIVE) {
 	      string_builder_putchar(s, '+');
 	    }
 	    if ((val+val == val) && (val > 0.0)) {
-- 
GitLab