summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libc')
-rw-r--r--usr/src/lib/libc/port/print/doprnt.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/usr/src/lib/libc/port/print/doprnt.c b/usr/src/lib/libc/port/print/doprnt.c
index 0c0fe0cacb..b6e8ceef0a 100644
--- a/usr/src/lib/libc/port/print/doprnt.c
+++ b/usr/src/lib/libc/port/print/doprnt.c
@@ -195,11 +195,11 @@ static const wchar_t widenullstr[] = L"(null)";
#define CHAR 0x2000 /* hh for char */
#ifdef _WIDE
-static wchar_t *
-insert_thousands_sep(wchar_t *bp, wchar_t *ep);
+static wchar_t *insert_decimal_point(wchar_t *ep);
+static wchar_t *insert_thousands_sep(wchar_t *bp, wchar_t *ep);
#else /* _WIDE */
-static char *
-insert_thousands_sep(char *bp, char *ep);
+static char *insert_decimal_point(char *ep);
+static char *insert_thousands_sep(char *bp, char *ep);
#endif /* _WIDE */
static int _rec_scrswidth(wchar_t *, ssize_t);
@@ -571,8 +571,6 @@ _ndoprnt(const char *format, va_list in_args, FILE *iop, int prflag)
/* arglst[1] is the second arg, etc */
int starflg = 0; /* set to 1 if * format specifier seen */
- struct lconv *locptr = localeconv();
- char decimal_point = *locptr->decimal_point;
/*
* Initialize args and sargs to the start of the argument list.
@@ -1344,11 +1342,11 @@ _ndoprnt(const char *format, va_list in_args, FILE *iop, int prflag)
p = &buf[0];
*p++ = (*bp != '\0') ? *bp++ : '0';
- /* put in a decimal point if needed */
+ /* Put in a decimal point if needed */
if (prec != 0 || (flagword & FSHARP))
- *p++ = decimal_point;
+ p = insert_decimal_point(p);
- /* create the rest of the mantissa */
+ /* Create the rest of the mantissa */
rz = prec;
if (fcode == 'A') {
for (; rz > 0 && *bp != '\0'; --rz) {
@@ -1452,7 +1450,7 @@ _ndoprnt(const char *format, va_list in_args, FILE *iop, int prflag)
/* Put in a decimal point if needed */
if (prec != 0 || (flagword & FSHARP))
- *p++ = decimal_point;
+ p = insert_decimal_point(p);
/* Create the rest of the mantissa */
rz = prec;
@@ -1575,9 +1573,9 @@ _ndoprnt(const char *format, va_list in_args, FILE *iop, int prflag)
if (quote)
p = insert_thousands_sep(buf, p);
- /* Decide whether we need a decimal point */
- if ((flagword & FSHARP) || prec > 0)
- *p++ = decimal_point;
+ /* Put in a decimal point if needed */
+ if (prec != 0 || (flagword & FSHARP))
+ p = insert_decimal_point(p);
/* Digits (if any) after the decimal point */
nn = min(prec, MAXFCVT);
@@ -2662,6 +2660,28 @@ insert_thousands_sep(char *bp, char *ep)
return (ep);
}
+#ifdef _WIDE
+static wchar_t *
+insert_decimal_point(wchar_t *ep)
+#else
+static char *
+insert_decimal_point(char *ep)
+#endif
+{
+ struct lconv *locptr = localeconv();
+ char *dp = locptr->decimal_point;
+#ifdef _WIDE
+ wchar_t wdp;
+
+ (void) mbtowc(&wdp, dp, MB_CUR_MAX);
+ *ep = wdp;
+ return (ep + 1);
+#else
+ (void) memcpy(ep, dp, strlen(dp));
+ return (ep + strlen(dp));
+#endif
+}
+
/*
* Recovery scrswidth function -