Browse Source

Use localeconv() to get the locale-specific radix char like printf does.

OPENBSD_3_9
millert 19 years ago
parent
commit
63f4612853
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      src/lib/libc/stdlib/gcvt.c

+ 6
- 3
src/lib/libc/stdlib/gcvt.c View File

@ -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];
}


Loading…
Cancel
Save