summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--stream.c4
-rw-r--r--txr.115
2 files changed, 16 insertions, 3 deletions
diff --git a/stream.c b/stream.c
index 48738bb7..d5886336 100644
--- a/stream.c
+++ b/stream.c
@@ -3259,7 +3259,7 @@ val formatv(val stream_in, val fmtstr, struct args *al)
vformat_str(stream, lit("#<bad-float>"), width, align, 0);
continue;
}
- precision = 0;
+ precision = (width ? width - 1 : 0);
goto output_num;
}
case 'd':
@@ -3348,7 +3348,7 @@ val formatv(val stream_in, val fmtstr, struct args *al)
continue;
}
- precision = 0;
+ precision = (width ? width - 1 : 0);
goto output_num;
default:
if (width != 0 || precision_p) {
diff --git a/txr.1 b/txr.1
index 22d0b3cb..3dd53160 100644
--- a/txr.1
+++ b/txr.1
@@ -40493,7 +40493,11 @@ or
.codn s )
is used. The details are
documented in the description of each of these, below. The leading zero flag is
-ignored for floating-point values regardless of the conversion specifier.
+also taken into account for floating-point values, and treated uniformly by
+these directives. If the flag is present, then the printed value's integer
+part will be padded with leading zeros up to the width of the field such that
+one character of unused space remains in the field, in case a positive or
+negative sign needs also to be rendered.
For integer or floating-point arguments, if the precision specifier has a
.code +
@@ -40560,6 +40564,15 @@ Floating point values which are integers are
printed without a trailing
.code .0
(point zero).
+The
+.code +
+flag in the precision is honored for rendering an explicit
+.code +
+sign on non-negative values.
+If a leading zero is specified in the precision, and a nonzero width is
+specified, then the printed value's integer part will be padded with leading
+zeros up to one less than the field width. These zeros are placed before the
+sign.
.coIP s
Prints any object in a standard way, as if by the