Module Name:    src
Committed By:   joerg
Date:           Thu Apr 18 21:54:11 UTC 2013

Modified Files:
        src/include: stdlib.h
        src/lib/libc/gdtoa: _strtof.c gdtoa.h strtod.c strtodg.c strtof.c
            strtof_vaxf.c strtold_subr.c strtopQ.c strtopx.c strtopxL.c
            strtord.c
        src/lib/libc/include: namespace.h

Log Message:
Add strtof_l, strtod_l and strtold_l.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/include/stdlib.h
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/gdtoa/_strtof.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/gdtoa/gdtoa.h
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gdtoa/strtod.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gdtoa/strtodg.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/gdtoa/strtof.c \
    src/lib/libc/gdtoa/strtopQ.c src/lib/libc/gdtoa/strtopx.c \
    src/lib/libc/gdtoa/strtopxL.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/gdtoa/strtof_vaxf.c
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/gdtoa/strtold_subr.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/gdtoa/strtord.c
cvs rdiff -u -r1.158 -r1.159 src/lib/libc/include/namespace.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/include/stdlib.h
diff -u src/include/stdlib.h:1.101 src/include/stdlib.h:1.102
--- src/include/stdlib.h:1.101	Tue Apr 16 21:44:06 2013
+++ src/include/stdlib.h	Thu Apr 18 21:54:10 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: stdlib.h,v 1.101 2013/04/16 21:44:06 joerg Exp $	*/
+/*	$NetBSD: stdlib.h,v 1.102 2013/04/18 21:54:10 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -334,6 +334,10 @@ qdiv_t	 qdiv(quad_t, quad_t);
 typedef struct _locale		*locale_t;
 #  define __LOCALE_T_DECLARED
 #  endif
+double		strtod_l(const char * __restrict, char ** __restrict, locale_t);
+float		strtof_l(const char * __restrict, char ** __restrict, locale_t);
+long double	strtold_l(const char * __restrict, char ** __restrict,
+			  locale_t);
 long	 strtol_l(const char * __restrict, char ** __restrict, int, locale_t);
 unsigned long
 	 strtoul_l(const char * __restrict, char ** __restrict, int, locale_t);

Index: src/lib/libc/gdtoa/_strtof.c
diff -u src/lib/libc/gdtoa/_strtof.c:1.2 src/lib/libc/gdtoa/_strtof.c:1.3
--- src/lib/libc/gdtoa/_strtof.c:1.2	Wed Oct 21 01:07:45 2009
+++ src/lib/libc/gdtoa/_strtof.c	Thu Apr 18 21:54:10 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: _strtof.c,v 1.2 2009/10/21 01:07:45 snj Exp $	*/
+/*	$NetBSD: _strtof.c,v 1.3 2013/04/18 21:54:10 joerg Exp $	*/
 
 /*
  * Copyright (c) 1996 Christos Zoulas.  All rights reserved.
@@ -26,15 +26,17 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _strtof.c,v 1.2 2009/10/21 01:07:45 snj Exp $");
+__RCSID("$NetBSD: _strtof.c,v 1.3 2013/04/18 21:54:10 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #if defined(__indr_reference)
 __indr_reference(_strtof, strtof)
+__indr_reference(_strtof_l, strtof_l)
 #else
 
 #include <stdlib.h>
 float	_strtof(const char * __restrict, char ** __restrict);
+float	_strtof_l(const char * __restrict, char ** __restrict, locale_t);
 
 float
 strtof(const char *nptr, char **endptr)
@@ -42,4 +44,11 @@ strtof(const char *nptr, char **endptr)
 
 	return _strtof(nptr, endptr);
 }
+
+float
+strtof_l(const char *nptr, char **endptr, locale_t loc)
+{
+
+	return _strtof_l(nptr, endptr, loc);
+}
 #endif

Index: src/lib/libc/gdtoa/gdtoa.h
diff -u src/lib/libc/gdtoa/gdtoa.h:1.9 src/lib/libc/gdtoa/gdtoa.h:1.10
--- src/lib/libc/gdtoa/gdtoa.h:1.9	Sun Mar 20 23:15:35 2011
+++ src/lib/libc/gdtoa/gdtoa.h	Thu Apr 18 21:54:10 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: gdtoa.h,v 1.9 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: gdtoa.h,v 1.10 2013/04/18 21:54:10 joerg Exp $ */
 
 /****************************************************************
 
@@ -38,6 +38,11 @@ THIS SOFTWARE.
 #include <stddef.h> /* for size_t */
 #include <stdint.h>
 
+#ifndef __LOCALE_T_DECLARED
+typedef struct _locale		*locale_t;
+#define __LOCALE_T_DECLARED
+#endif
+
 #ifndef Long
 #define Long int32_t
 #endif
@@ -133,7 +138,8 @@ extern char* gdtoa ANSI((FPI *fpi, int b
 extern void freedtoa ANSI((char*));
 extern float  strtof ANSI((CONST char *, char **));
 extern double strtod ANSI((CONST char *, char **));
-extern int strtodg ANSI((CONST char*, char**, CONST FPI*, Long*, ULong*));
+extern int strtodg ANSI((CONST char*, char**, CONST FPI*, Long*, ULong*,
+                         locale_t));
 
 extern char*	g_ddfmt  ANSI((char*, double*, int, size_t));
 extern char*	g_dfmt   ANSI((char*, double*, int, size_t));
@@ -148,7 +154,7 @@ extern int	strtoIf  ANSI((CONST char*, c
 extern int	strtoIQ  ANSI((CONST char*, char**, void*, void*));
 extern int	strtoIx  ANSI((CONST char*, char**, void*, void*));
 extern int	strtoIxL ANSI((CONST char*, char**, void*, void*));
-extern int	strtord  ANSI((CONST char*, char**, int, double*));
+extern int	strtord  ANSI((CONST char*, char**, int, double*, locale_t));
 extern int	strtordd ANSI((CONST char*, char**, int, double*));
 extern int	strtorf  ANSI((CONST char*, char**, int, float*));
 extern int	strtorQ  ANSI((CONST char*, char**, int, void*));
@@ -159,9 +165,9 @@ extern int	strtodI  ANSI((CONST char*, c
 extern int	strtopd  ANSI((CONST char*, char**, double*));
 extern int	strtopdd ANSI((CONST char*, char**, double*));
 extern int	strtopf  ANSI((CONST char*, char**, float*));
-extern int	strtopQ  ANSI((CONST char*, char**, void*));
-extern int	strtopx  ANSI((CONST char*, char**, void*));
-extern int	strtopxL ANSI((CONST char*, char**, void*));
+extern int	strtopQ  ANSI((CONST char*, char**, void*, locale_t));
+extern int	strtopx  ANSI((CONST char*, char**, void*, locale_t));
+extern int	strtopxL ANSI((CONST char*, char**, void*, locale_t));
 #else
 #define strtopd(s,se,x) strtord(s,se,1,x)
 #define strtopdd(s,se,x) strtordd(s,se,1,x)

Index: src/lib/libc/gdtoa/strtod.c
diff -u src/lib/libc/gdtoa/strtod.c:1.11 src/lib/libc/gdtoa/strtod.c:1.12
--- src/lib/libc/gdtoa/strtod.c:1.11	Thu Mar 22 15:34:14 2012
+++ src/lib/libc/gdtoa/strtod.c	Thu Apr 18 21:54:10 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.11 2012/03/22 15:34:14 christos Exp $ */
+/* $NetBSD: strtod.c,v 1.12 2013/04/18 21:54:10 joerg Exp $ */
 
 /****************************************************************
 
@@ -31,13 +31,15 @@ THIS SOFTWARE.
 /* Please send bug reports to David M. Gay (dmg at acm dot org,
  * with " at " changed at "@" and " dot " changed to ".").	*/
 
+#include "namespace.h"
 #include "gdtoaimp.h"
 #ifndef NO_FENV_H
 #include <fenv.h>
 #endif
 
 #ifdef USE_LOCALE
-#include "locale.h"
+#include <locale.h>
+#include "setlocale_local.h"
 #endif
 
 #ifdef IEEE_Arith
@@ -62,6 +64,8 @@ static CONST double tinytens[] = { 1e-16
 #ifndef __HAVE_LONG_DOUBLE
 __strong_alias(_strtold, strtod)
 __weak_alias(strtold, _strtold)
+__strong_alias(_strtold_l, strtod_l)
+__weak_alias(strtold_l, _strtold_l)
 #endif
 
 #ifdef Avoid_Underflow /*{*/
@@ -86,13 +90,8 @@ sulp
 	}
 #endif /*}*/
 
- double
-strtod
-#ifdef KR_headers
-	(s00, se) CONST char *s00; char **se;
-#else
-	(CONST char *s00, char **se)
-#endif
+static double
+_int_strtod_l(CONST char *s00, char **se, locale_t loc)
 {
 #ifdef Avoid_Underflow
 	int scale;
@@ -116,25 +115,8 @@ strtod
 	int inexact, oldinexact;
 #endif
 #ifdef USE_LOCALE /*{{*/
-#ifdef NO_LOCALE_CACHE
-	char *decimalpoint = localeconv()->decimal_point;
+	char *decimalpoint = localeconv_l(loc)->decimal_point;
 	size_t dplen = strlen(decimalpoint);
-#else
-	char *decimalpoint;
-	static char *decimalpoint_cache;
-	static size_t dplen;
-	if (!(s0 = decimalpoint_cache)) {
-		s0 = localeconv()->decimal_point;
-		if ((decimalpoint_cache = MALLOC(strlen(s0) + 1)) != NULL) {
-			strcpy(decimalpoint_cache, s0);
-			s0 = decimalpoint_cache;
-			}
-		dplen = strlen(s0);
-		}
-	decimalpoint = __UNCONST(s0);
-#endif /*NO_LOCALE_CACHE*/
-#else  /*USE_LOCALE}{*/
-#define dplen 1
 #endif /*USE_LOCALE}}*/
 
 #ifdef Honor_FLT_ROUNDS /*{*/
@@ -1118,3 +1100,20 @@ strtod
 	return sign ? -dval(&rv) : dval(&rv);
 	}
 
+double
+strtod(CONST char *s, char **sp)
+{
+	return _int_strtod_l(s, sp, *_current_locale());
+}
+
+#ifdef __weak_alias
+__weak_alias(strtod_l, _strtod_l)
+#endif
+
+double
+strtod_l(CONST char *s, char **sp, locale_t loc)
+{
+	if (loc == NULL)
+		loc = _C_locale;
+	return _int_strtod_l(s, sp, loc);
+}

Index: src/lib/libc/gdtoa/strtodg.c
diff -u src/lib/libc/gdtoa/strtodg.c:1.10 src/lib/libc/gdtoa/strtodg.c:1.11
--- src/lib/libc/gdtoa/strtodg.c:1.10	Thu Mar 22 13:09:12 2012
+++ src/lib/libc/gdtoa/strtodg.c	Thu Apr 18 21:54:10 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: strtodg.c,v 1.10 2012/03/22 13:09:12 he Exp $ */
+/* $NetBSD: strtodg.c,v 1.11 2013/04/18 21:54:10 joerg Exp $ */
 
 /****************************************************************
 
@@ -319,13 +319,8 @@ mantbits(U *d)
 #endif /* !VAX */
 
  int
-strtodg
-#ifdef KR_headers
-	(s00, se, fpi, expt, bits)
-	CONST char *s00; char **se; CONST FPI *fpi; Long *expt; ULong *bits;
-#else
-	(CONST char *s00, char **se, CONST FPI *fpi, Long *expt, ULong *bits)
-#endif
+strtodg(CONST char *s00, char **se, CONST FPI *fpi, Long *expt, ULong *bits,
+	locale_t loc)
 {
 	int abe, abits, asub;
 #ifdef INFNAN_CHECK
@@ -342,25 +337,8 @@ strtodg
 	ULong *b, *be, y, z;
 	Bigint *ab, *bb, *bb1, *bd, *bd0, *bs, *delta, *rvb, *rvb0;
 #ifdef USE_LOCALE /*{{*/
-#ifdef NO_LOCALE_CACHE
-	char *decimalpoint = localeconv()->decimal_point;
+	char *decimalpoint = localeconv_l(loc)->decimal_point;
 	size_t dplen = strlen(decimalpoint);
-#else
-	char *decimalpoint;
-	static char *decimalpoint_cache;
-	static size_t dplen;
-	if (!(s0 = decimalpoint_cache)) {
-		s0 = localeconv()->decimal_point;
-		if ((decimalpoint_cache = MALLOC(strlen(s0) + 1)) != NULL) {
-			strcpy(decimalpoint_cache, s0);
-			s0 = decimalpoint_cache;
-			}
-		dplen = strlen(s0);
-		}
-	decimalpoint = __UNCONST(s0);
-#endif /*NO_LOCALE_CACHE*/
-#else  /*USE_LOCALE}{*/
-#define dplen 1
 #endif /*USE_LOCALE}}*/
 
 	e2 = 0;	/* XXX gcc */

Index: src/lib/libc/gdtoa/strtof.c
diff -u src/lib/libc/gdtoa/strtof.c:1.5 src/lib/libc/gdtoa/strtof.c:1.6
--- src/lib/libc/gdtoa/strtof.c:1.5	Mon Jun 20 09:11:17 2011
+++ src/lib/libc/gdtoa/strtof.c	Thu Apr 18 21:54:11 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: strtof.c,v 1.5 2011/06/20 09:11:17 mrg Exp $ */
+/* $NetBSD: strtof.c,v 1.6 2013/04/18 21:54:11 joerg Exp $ */
 
 /****************************************************************
 
@@ -34,16 +34,16 @@ THIS SOFTWARE.
 #include "namespace.h"
 #include "gdtoaimp.h"
 
+#include <locale.h>
+#include "setlocale_local.h"
+
 #ifdef __weak_alias
 __weak_alias(strtof, _strtof)
+__weak_alias(strtof_l, _strtof_l)
 #endif
 
- float
-#ifdef KR_headers
-strtof(s, sp) CONST char *s; char **sp;
-#else
-strtof(CONST char *s, char **sp)
-#endif
+static float
+_int_strtof_l(CONST char *s, char **sp, locale_t loc)
 {
 	static CONST FPI fpi0 = { 24, 1-127-24+1,  254-127-24+1, 1, SI };
 	ULong bits[1];
@@ -56,7 +56,7 @@ strtof(CONST char *s, char **sp)
 #define fpi &fpi0
 #endif
 
-	k = strtodg(s, sp, fpi, &expt, bits);
+	k = strtodg(s, sp, fpi, &expt, bits, loc);
 	if (k == STRTOG_NoMemory) {
 		errno = ERANGE;
 		return HUGE_VALF;
@@ -92,3 +92,17 @@ strtof(CONST char *s, char **sp)
 		u.L[0] |= 0x80000000L;
 	return u.f;
 	}
+
+float
+strtof(CONST char *s, char **sp)
+{
+	return _int_strtof_l(s, sp, *_current_locale());
+}
+
+float
+strtof_l(CONST char *s, char **sp, locale_t loc)
+{
+	if (loc == NULL)
+		loc = _C_locale;
+	return _int_strtof_l(s, sp, loc);
+}
Index: src/lib/libc/gdtoa/strtopQ.c
diff -u src/lib/libc/gdtoa/strtopQ.c:1.5 src/lib/libc/gdtoa/strtopQ.c:1.6
--- src/lib/libc/gdtoa/strtopQ.c:1.5	Sun Mar 20 23:15:35 2011
+++ src/lib/libc/gdtoa/strtopQ.c	Thu Apr 18 21:54:11 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: strtopQ.c,v 1.5 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: strtopQ.c,v 1.6 2013/04/18 21:54:11 joerg Exp $ */
 
 /****************************************************************
 
@@ -52,11 +52,7 @@ THIS SOFTWARE.
 #endif
 
  int
-#ifdef KR_headers
-strtopQ(s, sp, V) CONST char *s; char **sp; void *V;
-#else
-strtopQ(CONST char *s, char **sp, void *V)
-#endif
+strtopQ(CONST char *s, char **sp, void *V, locale_t loc)
 {
 	static CONST FPI fpi0 = { 113, 1-16383-113+1, 32766 - 16383 - 113 + 1, 1, SI };
 	ULong bits[4];
@@ -69,7 +65,7 @@ strtopQ(CONST char *s, char **sp, void *
 #define fpi &fpi0
 #endif
 
-	k = strtodg(s, sp, fpi, &expt, bits);
+	k = strtodg(s, sp, fpi, &expt, bits, loc);
 	if (k == STRTOG_NoMemory)
 		return k;
 	switch(k & STRTOG_Retmask) {
Index: src/lib/libc/gdtoa/strtopx.c
diff -u src/lib/libc/gdtoa/strtopx.c:1.5 src/lib/libc/gdtoa/strtopx.c:1.6
--- src/lib/libc/gdtoa/strtopx.c:1.5	Sun Mar 20 23:15:35 2011
+++ src/lib/libc/gdtoa/strtopx.c	Thu Apr 18 21:54:11 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: strtopx.c,v 1.5 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: strtopx.c,v 1.6 2013/04/18 21:54:11 joerg Exp $ */
 
 /****************************************************************
 
@@ -54,11 +54,7 @@ THIS SOFTWARE.
 #endif
 
  int
-#ifdef KR_headers
-strtopx(s, sp, V) CONST char *s; char **sp; void *V;
-#else
-strtopx(CONST char *s, char **sp, void *V)
-#endif
+strtopx(CONST char *s, char **sp, void *V, locale_t loc)
 {
 	static const FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
 	ULong bits[2];
@@ -71,7 +67,7 @@ strtopx(CONST char *s, char **sp, void *
 #define fpi &fpi0
 #endif
 
-	k = strtodg(s, sp, fpi, &expt, bits);
+	k = strtodg(s, sp, fpi, &expt, bits, loc);
 	if (k == STRTOG_NoMemory)
 		return k;
 	switch(k & STRTOG_Retmask) {
Index: src/lib/libc/gdtoa/strtopxL.c
diff -u src/lib/libc/gdtoa/strtopxL.c:1.5 src/lib/libc/gdtoa/strtopxL.c:1.6
--- src/lib/libc/gdtoa/strtopxL.c:1.5	Sun Mar 20 23:15:35 2011
+++ src/lib/libc/gdtoa/strtopxL.c	Thu Apr 18 21:54:11 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: strtopxL.c,v 1.5 2011/03/20 23:15:35 christos Exp $ */
+/* $NetBSD: strtopxL.c,v 1.6 2013/04/18 21:54:11 joerg Exp $ */
 
 /****************************************************************
 
@@ -50,11 +50,7 @@ THIS SOFTWARE.
 #endif
 
  int
-#ifdef KR_headers
-strtopxL(s, sp, V) CONST char *s; char **sp; void *V;
-#else
-strtopxL(CONST char *s, char **sp, void *V)
-#endif
+strtopxL(CONST char *s, char **sp, void *V, locale_t loc)
 {
 	static CONST FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
 	ULong bits[2];
@@ -67,7 +63,7 @@ strtopxL(CONST char *s, char **sp, void 
 #define fpi &fpi0
 #endif
 
-	k = strtodg(s, sp, fpi, &expt, bits);
+	k = strtodg(s, sp, fpi, &expt, bits, loc);
 	if (k == STRTOG_NoMemory)
 		return k;
 	switch(k & STRTOG_Retmask) {

Index: src/lib/libc/gdtoa/strtof_vaxf.c
diff -u src/lib/libc/gdtoa/strtof_vaxf.c:1.6 src/lib/libc/gdtoa/strtof_vaxf.c:1.7
--- src/lib/libc/gdtoa/strtof_vaxf.c:1.6	Fri Jul  1 03:20:06 2011
+++ src/lib/libc/gdtoa/strtof_vaxf.c	Thu Apr 18 21:54:11 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: strtof_vaxf.c,v 1.6 2011/07/01 03:20:06 matt Exp $ */
+/* $NetBSD: strtof_vaxf.c,v 1.7 2013/04/18 21:54:11 joerg Exp $ */
 
 /****************************************************************
 
@@ -35,17 +35,16 @@ THIS SOFTWARE.
 
 #include "namespace.h"
 #include "gdtoaimp.h"
+#include <locale.h>
+#include "setlocale_local.h"
 
 #ifdef __weak_alias
 __weak_alias(strtof, _strtof)
+__weak_alias(strtof_l, _strtof_l)
 #endif
 
- float
-#ifdef KR_headers
-strtof(s, sp) CONST char *s; char **sp;
-#else
-strtof(CONST char *s, char **sp)
-#endif
+static float
+_int_strtof_l(CONST char *s, char **sp, locale_t loc)
 {
 	static CONST FPI fpi = { 24, 1-128-1-24+1,  255-128-1-24+1, 1, SI };
 	ULong bits[1];
@@ -53,7 +52,7 @@ strtof(CONST char *s, char **sp)
 	int k;
 	union { ULong L[1]; float f; } u;
 
-	k = strtodg(s, sp, &fpi, &expt, bits);
+	k = strtodg(s, sp, &fpi, &expt, bits, loc);
 	if (k == STRTOG_NoMemory) {
 		errno = ERANGE;
 		return HUGE_VALF;
@@ -80,3 +79,17 @@ strtof(CONST char *s, char **sp)
 		u.L[0] |= 0x00008000L;
 	return u.f;
 }
+
+float
+strtof(CONST char *s, char **sp)
+{
+	return _int_strtof_l(s, sp, *_current_locale());
+}
+
+float
+strtof_l(CONST char *s, char **sp, locale_t loc)
+{
+	if (loc == NULL)
+		loc = _C_locale;
+	return _int_strtof_l(s, sp, loc);
+}

Index: src/lib/libc/gdtoa/strtold_subr.c
diff -u src/lib/libc/gdtoa/strtold_subr.c:1.1 src/lib/libc/gdtoa/strtold_subr.c:1.2
--- src/lib/libc/gdtoa/strtold_subr.c:1.1	Wed Mar 15 17:35:18 2006
+++ src/lib/libc/gdtoa/strtold_subr.c	Thu Apr 18 21:54:11 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: strtold_subr.c,v 1.1 2006/03/15 17:35:18 kleink Exp $ */
+/* $NetBSD: strtold_subr.c,v 1.2 2013/04/18 21:54:11 joerg Exp $ */
 
 /*
  * Written by Klaus Klein <[email protected]>, November 16, 2005.
@@ -15,7 +15,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: strtold_subr.c,v 1.1 2006/03/15 17:35:18 kleink Exp $");
+__RCSID("$NetBSD: strtold_subr.c,v 1.2 2013/04/18 21:54:11 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -23,8 +23,12 @@ __RCSID("$NetBSD: strtold_subr.c,v 1.1 2
 #include <stdlib.h>
 #include "gdtoa.h"
 
+#include <locale.h>
+#include "setlocale_local.h"
+
 #ifdef __weak_alias
 __weak_alias(strtold, _strtold)
+__weak_alias(strtold_l, _strtold_l)
 #endif
 
 #ifndef __HAVE_LONG_DOUBLE
@@ -37,11 +41,25 @@ __weak_alias(strtold, _strtold)
 
 #define	STRTOP(x)	__CONCAT(strtop, x)
 
-long double
-strtold(const char *nptr, char **endptr)
+static long double
+_int_strtold_l(const char *nptr, char **endptr, locale_t loc)
 {
 	long double ld;
 
-	(void)STRTOP(GDTOA_LD_FMT)(nptr, endptr, &ld);
+	(void)STRTOP(GDTOA_LD_FMT)(nptr, endptr, &ld, loc);
 	return ld;
 }
+
+long double
+strtold(CONST char *s, char **sp)
+{
+	return _int_strtold_l(s, sp, *_current_locale());
+}
+
+long double
+strtold_l(CONST char *s, char **sp, locale_t loc)
+{
+	if (loc == NULL)
+		loc = _C_locale;
+	return _int_strtold_l(s, sp, loc);
+}

Index: src/lib/libc/gdtoa/strtord.c
diff -u src/lib/libc/gdtoa/strtord.c:1.4 src/lib/libc/gdtoa/strtord.c:1.5
--- src/lib/libc/gdtoa/strtord.c:1.4	Fri Mar 21 23:13:48 2008
+++ src/lib/libc/gdtoa/strtord.c	Thu Apr 18 21:54:11 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: strtord.c,v 1.4 2008/03/21 23:13:48 christos Exp $ */
+/* $NetBSD: strtord.c,v 1.5 2013/04/18 21:54:11 joerg Exp $ */
 
 /****************************************************************
 
@@ -73,11 +73,7 @@ ULtod(ULong *L, ULong *bits, Long expt, 
 	}
 
  int
-#ifdef KR_headers
-strtord(s, sp, rounding, d) CONST char *s; char **sp; int rounding; double *d;
-#else
-strtord(CONST char *s, char **sp, int rounding, double *d)
-#endif
+strtord(CONST char *s, char **sp, int rounding, double *d, locale_t loc)
 {
 	static CONST FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };
 	CONST FPI *fpi;
@@ -92,7 +88,7 @@ strtord(CONST char *s, char **sp, int ro
 		fpi1.rounding = rounding;
 		fpi = &fpi1;
 		}
-	k = strtodg(s, sp, fpi, &expt, bits);
+	k = strtodg(s, sp, fpi, &expt, bits, loc);
 	if (k == STRTOG_NoMemory)
 		return k; 
 	ULtod((/* LINTED */(U*)d)->L, bits, expt, k);

Index: src/lib/libc/include/namespace.h
diff -u src/lib/libc/include/namespace.h:1.158 src/lib/libc/include/namespace.h:1.159
--- src/lib/libc/include/namespace.h:1.158	Tue Apr 16 21:44:07 2013
+++ src/lib/libc/include/namespace.h	Thu Apr 18 21:54:11 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: namespace.h,v 1.158 2013/04/16 21:44:07 joerg Exp $	*/
+/*	$NetBSD: namespace.h,v 1.159 2013/04/18 21:54:11 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
@@ -59,10 +59,13 @@
 #define strerror_r	_strerror_r
 #define strlcat		_strlcat
 #define strlcpy		_strlcpy
+#define strtod_l	_strtod_l
 #define strtof		_strtof
+#define strtof_l	_strtof_l
 #define strtoimax	_strtoimax
 #define strtoimax_l	_strtoimax_l
 #define strtold		_strtold
+#define strtold_l	_strtold_l
 #define strtoll		_strtoll
 #define strtoll_l	_strtoll_l
 #define strtoull	_strtoull

Reply via email to