From d1a30f9ac26df67200218f8fe75e3ab84efe79c6 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 10 Jan 2006 02:23:03 +0000 Subject: Use localeconv() to get the locale-specific radix char like printf does. --- lib/libc/stdlib/gcvt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/libc/stdlib') 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 @@ -20,6 +20,7 @@ * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ +#include #include #include #include @@ -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]; } -- cgit v1.2.3