X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/a091c28b416f83aa46dcb0bd0da81ca1d3b8a7f9..947cb661f6188abf5d1128c30b61090f58d5d3fd:/sbr/fmt_scan.c diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 8e59669d..075b7dd6 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -67,8 +67,13 @@ match (char *str, char *sub) * copy a number to the destination subject to a maximum width */ void -cpnumber(charstring_t dest, int num, unsigned int wid, char fill, size_t max) { - if (wid < (num >= 0 ? max : max-1)) { +cpnumber(charstring_t dest, int num, int wid, char fill, size_t max) { + /* Maybe we should handle left padding at some point? */ + if (wid == 0) + return; + if (wid < 0) + wid = -wid; /* OK because wid originally a short. */ + if ((size_t)wid < (num >= 0 ? max : max-1)) { /* Build up the string representation of num in reverse. */ charstring_t rev = charstring_create (0); int i = num >= 0 ? num : -num;