--- strfmon.c.orig 2003-05-20 15:23:25.000000000 -0700
-+++ strfmon.c 2005-02-27 11:52:19.000000000 -0800
++++ strfmon.c 2005-04-27 23:34:08.000000000 -0700
@@ -28,6 +28,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/stdlib/strfmon.c,v 1.14 2003/03/20 08:18:55 ache Exp $");
}
/* Conversion Characters */
-@@ -239,21 +238,21 @@
+@@ -219,8 +218,10 @@
+
+ if (flags & USE_INTL_CURRENCY) {
+ currency_symbol = strdup(lc->int_curr_symbol);
+- if (currency_symbol != NULL)
++ if (currency_symbol != NULL) {
+ space_char = *(currency_symbol+3);
++ currency_symbol[3] = '\0';
++ }
+ } else
+ currency_symbol = strdup(lc->currency_symbol);
+
+@@ -239,21 +240,21 @@
/* fill left_prec with amount of padding chars */
if (left_prec >= 0) {
pad_size = __calc_left_pad((flags ^ IS_NEGATIVE),
/*
* Description of some LC_MONETARY's values:
-@@ -366,7 +365,6 @@
+@@ -313,8 +314,11 @@
+ } else if (sep_by_space == 1)
+ PRINT(space_char);
+ }
+- } else if (sign_posn == 1)
++ } else if (sign_posn == 1) {
+ PRINTS(signstr);
++ if (sep_by_space == 2)
++ PRINT(' ');
++ }
+
+ PRINTS(asciivalue);
+
+@@ -348,8 +352,12 @@
+ PRINTS(signstr);
+ }
+
+- if (sign_posn == 0 && (flags & IS_NEGATIVE))
+- PRINT(')');
++ if (sign_posn == 0) {
++ if (flags & IS_NEGATIVE)
++ PRINT(')');
++ else if (left_prec >= 0)
++ PRINT(' ');
++ }
+
+ if (dst - tmpptr < width) {
+ if (flags & LEFT_JUSTIFY) {
+@@ -366,7 +374,6 @@
}
PRINT('\0');
free(asciivalue);
free(currency_symbol);
return (dst - s - 1); /* return size of put data except trailing '\0' */
-@@ -385,15 +383,12 @@
+@@ -385,15 +392,12 @@
if (currency_symbol != NULL)
free(currency_symbol);
errno = sverrno;
if ((flags & IS_NEGATIVE) && (flags & USE_INTL_CURRENCY)) {
*cs_precedes = lc->int_n_cs_precedes;
-@@ -429,12 +424,12 @@
+@@ -429,12 +433,12 @@
}
static int
if (cs_precedes != 0) {
left_chars += strlen(cur_symb);
-@@ -480,7 +475,7 @@
+@@ -443,6 +447,10 @@
+ }
+
+ switch (sign_posn) {
++ case 0:
++ if (flags & IS_NEGATIVE)
++ left_chars++;
++ break;
+ case 1:
+ left_chars += strlen(signstr);
+ break;
+@@ -478,9 +486,11 @@
+ }
+
/* convert double to ASCII */
++__private_extern__ const char *__fix_nogrouping(const char *);
++
static char *
__format_grouped_double(double value, int *flags,
- int left_prec, int right_prec, int pad_char) {
char *rslt;
char *avalue;
-@@ -492,7 +487,6 @@
+@@ -492,14 +502,13 @@
int padded;
char *grouping;
char decimal_point;
char thousands_sep;
-@@ -526,9 +520,9 @@
+
+ int groups = 0;
+
+- grouping = lc->mon_grouping;
++ grouping = __fix_nogrouping(lc->mon_grouping);
+ decimal_point = *lc->mon_decimal_point;
+ if (decimal_point == '\0')
+ decimal_point = *lc->decimal_point;
+@@ -526,9 +535,9 @@
left_prec += get_groups(left_prec, grouping);
/* convert to string */
if (avalue_size < 0)
return (NULL);
-@@ -601,3 +595,30 @@
+@@ -601,3 +610,30 @@
free(avalue);
return (rslt);
}