]> diplodocus.org Git - nmh/blobdiff - sbr/fmt_scan.c
cppflags.m4: Don't trample CFLAGS and CPPFLAGS.
[nmh] / sbr / fmt_scan.c
index 8e59669da598d93e25768c9bdadd2fe7b435f0b1..075b7dd6db3e944a5c1a1e4c14feb41a7d5ca3f5 100644 (file)
@@ -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;