+2005-06-27 Hrvoje Niksic <hniksic@xemacs.org>
+
+ * utils.c (with_thousand_seps): Handle negative numbers.
+
2005-06-26 Hrvoje Niksic <hniksic@xemacs.org>
* progress.c (create_image): Mark the "eta" string for translation.
*grouping = cached_grouping;
}
-
/* Return a printed representation of N with thousand separators.
This should respect locale settings, with the exception of the "C"
locale which mandates no separator, but we use one anyway.
int i = 0, groupsize;
const char *atgroup;
+ bool negative = n < 0;
+
/* Initialize grouping data. */
get_grouping_data (&sep, &grouping);
seplen = strlen (sep);
atgroup = grouping;
groupsize = *atgroup++;
+ /* This will overflow on WGINT_MIN, but we're not using this to
+ print negative numbers anyway. */
+ if (negative)
+ n = -n;
+
/* Write the number into the buffer, backwards, inserting the
separators as necessary. */
*--p = '\0';
groupsize = *atgroup++;
}
}
+ if (negative)
+ *--p = '-';
+
return p;
}