diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2006-01-10 02:23:03 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2006-01-10 02:23:03 +0000 |
commit | d1a30f9ac26df67200218f8fe75e3ab84efe79c6 (patch) | |
tree | ef5fa9926bcb841ff1b4edeaeba7cecc7f7279d6 /lib/libc/stdlib | |
parent | b8af672ee635422fb4317936e30897a85f3cd535 (diff) |
Use localeconv() to get the locale-specific radix char like printf does.
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r-- | lib/libc/stdlib/gcvt.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libc/stdlib/gcvt.c b/lib/libc/stdlib/gcvt.c index 87bd843307b..9ba932e1237 100644 --- a/lib/libc/stdlib/gcvt.c +++ b/lib/libc/stdlib/gcvt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gcvt.c,v 1.7 2006/01/10 02:08:28 millert Exp $ */ +/* $OpenBSD: gcvt.c,v 1.8 2006/01/10 02:23:02 millert Exp $ */ /* * Copyright (c) 2002, 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -20,6 +20,7 @@ * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ +#include <locale.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -31,7 +32,9 @@ gcvt(double value, int ndigit, char *buf) { char *digits, *dst, *src; int i, decpt, sign; + struct lconv *lconv; + lconv = localeconv(); if (ndigit == 0) { buf[0] = '\0'; return (buf); @@ -57,7 +60,7 @@ gcvt(double value, int ndigit, char *buf) sign = 0; src = digits; *dst++ = *src++; - *dst++ = '.'; /* XXX - locale-specific */ + *dst++ = *lconv->decimal_point; while (*src != '\0') *dst++ = *src++; *dst++ = 'e'; @@ -90,7 +93,7 @@ gcvt(double value, int ndigit, char *buf) if (*src != '\0') { if (src == digits) *dst++ = '0'; /* zero before decimal point */ - *dst++ = '.'; /* XXX - locale-specific */ + *dst++ = *lconv->decimal_point; for (i = decpt; digits[i] != '\0'; i++) { *dst++ = digits[i]; } |