Module Name: src
Committed By: joerg
Date: Thu Apr 18 22:23:18 UTC 2013
Modified Files:
src/include: wchar.h
src/lib/libc/include: namespace.h
src/lib/libc/locale: _wcstod.h wcstod.c wcstof.c wcstold.c
Log Message:
Add wcstof_l, wcstod_l and wcstold_l.
To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/include/wchar.h
cvs rdiff -u -r1.159 -r1.160 src/lib/libc/include/namespace.h
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/_wcstod.h
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/locale/wcstod.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/locale/wcstof.c \
src/lib/libc/locale/wcstold.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/include/wchar.h
diff -u src/include/wchar.h:1.32 src/include/wchar.h:1.33
--- src/include/wchar.h:1.32 Tue Apr 16 16:52:13 2013
+++ src/include/wchar.h Thu Apr 18 22:23:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: wchar.h,v 1.32 2013/04/16 16:52:13 joerg Exp $ */
+/* $NetBSD: wchar.h,v 1.33 2013/04/18 22:23:17 joerg Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@@ -211,6 +211,10 @@ __END_DECLS
typedef struct _locale *locale_t;
# define __LOCALE_T_DECLARED
# endif
+float wcstof_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t);
+double wcstod_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t);
+long double wcstold_l(const wchar_t * __restrict, wchar_t ** __restrict,
+ locale_t);
long int wcstol_l(const wchar_t * __restrict, wchar_t ** __restrict, int,
locale_t);
unsigned long int wcstoul_l(const wchar_t * __restrict,
Index: src/lib/libc/include/namespace.h
diff -u src/lib/libc/include/namespace.h:1.159 src/lib/libc/include/namespace.h:1.160
--- src/lib/libc/include/namespace.h:1.159 Thu Apr 18 21:54:11 2013
+++ src/lib/libc/include/namespace.h Thu Apr 18 22:23:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: namespace.h,v 1.159 2013/04/18 21:54:11 joerg Exp $ */
+/* $NetBSD: namespace.h,v 1.160 2013/04/18 22:23:17 joerg Exp $ */
/*-
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
@@ -707,8 +707,11 @@
#define wcsdup _wcsdup
#define wcsncasecmp _wcsncasecmp
#define wcstof _wcstof
+#define wcstof_l _wcstof_l
#define wcstod _wcstod
+#define wcstod_l _wcstod_l
#define wcstold _wcstold
+#define wcstold_l _wcstold_l
#define wcwidth _wcwidth
#define wcwidth_l _wcwidth_l
#define xdr_accepted_reply _xdr_accepted_reply
Index: src/lib/libc/locale/_wcstod.h
diff -u src/lib/libc/locale/_wcstod.h:1.2 src/lib/libc/locale/_wcstod.h:1.3
--- src/lib/libc/locale/_wcstod.h:1.2 Thu Dec 16 17:42:27 2010
+++ src/lib/libc/locale/_wcstod.h Thu Apr 18 22:23:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: _wcstod.h,v 1.2 2010/12/16 17:42:27 wiz Exp $ */
+/* $NetBSD: _wcstod.h,v 1.3 2013/04/18 22:23:17 joerg Exp $ */
/*-
* Copyright (c) 2002 Tim J. Robbins
@@ -6,7 +6,7 @@
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
- * are met:
+ * aINre met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@@ -41,6 +41,11 @@
#ifndef __WCSTOD_H_
#define __WCSTOD_H_
+#include <locale.h>
+#include "setlocale_local.h"
+#define INT_NAME_(pre, middle, post) pre ## middle ## post
+#define INT_NAME(pre, middle, post) INT_NAME_(pre, middle, post)
+
/*
* Convert a string to a double-precision number.
*
@@ -51,8 +56,9 @@
* This assumes that the multibyte encoding is compatible with ASCII
* for at least the digits, radix character and letters.
*/
-_RETURN_TYPE
-_FUNCNAME(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr)
+static _RETURN_TYPE
+INT_NAME(_int_, _FUNCNAME, _l)(const wchar_t * __restrict nptr,
+ wchar_t ** __restrict endptr, locale_t loc)
{
const wchar_t *src, *start;
_RETURN_TYPE val;
@@ -63,7 +69,7 @@ _FUNCNAME(const wchar_t * __restrict npt
/* endptr may be null */
src = nptr;
- while (iswspace((wint_t)*src) != 0)
+ while (iswspace_l((wint_t)*src, loc) != 0)
++src;
if (*src == L'\0')
goto no_convert;
@@ -79,7 +85,7 @@ _FUNCNAME(const wchar_t * __restrict npt
* slows down the most common cases.
*/
start = src;
- len = wcstombs(NULL, src, 0);
+ len = wcstombs_l(NULL, src, 0, loc);
if (len == (size_t)-1)
/* errno = EILSEQ */
goto no_convert;
@@ -92,13 +98,13 @@ _FUNCNAME(const wchar_t * __restrict npt
/* errno = ENOMEM */
goto no_convert;
- len = wcstombs(buf, src, bufsiz + 1);
+ len = wcstombs_l(buf, src, bufsiz + 1, loc);
_DIAGASSERT(len == bufsiz);
_DIAGASSERT(buf[len] == '\0');
/* Let strto{f,d,ld}() do most of the work for us. */
- val = _STRTOD_FUNC(buf, &end);
+ val = _STRTOD_FUNC(buf, &end, loc);
if (buf == end) {
free(buf);
goto no_convert;
@@ -123,4 +129,20 @@ no_convert:
*endptr = __UNCONST(nptr);
return 0;
}
+
+_RETURN_TYPE
+INT_NAME(, _FUNCNAME, )(const wchar_t * __restrict nptr,
+ wchar_t ** __restrict endptr)
+{
+ return INT_NAME(_int_, _FUNCNAME, _l)(nptr, endptr, *_current_locale());
+}
+
+_RETURN_TYPE
+INT_NAME(, _FUNCNAME, _l)(const wchar_t * __restrict nptr,
+ wchar_t ** __restrict endptr, locale_t loc)
+{
+ if (loc == NULL)
+ loc = _C_locale;
+ return INT_NAME(_int_, _FUNCNAME, _l)(nptr, endptr, loc);
+}
#endif /*__WCSTOD_H_*/
Index: src/lib/libc/locale/wcstod.c
diff -u src/lib/libc/locale/wcstod.c:1.14 src/lib/libc/locale/wcstod.c:1.15
--- src/lib/libc/locale/wcstod.c:1.14 Fri Apr 25 16:43:00 2008
+++ src/lib/libc/locale/wcstod.c Thu Apr 18 22:23:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: wcstod.c,v 1.14 2008/04/25 16:43:00 christos Exp $ */
+/* $NetBSD: wcstod.c,v 1.15 2013/04/18 22:23:17 joerg Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcstod.c,v 1.14 2008/04/25 16:43:00 christos Exp $");
+__RCSID("$NetBSD: wcstod.c,v 1.15 2013/04/18 22:23:17 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -45,6 +45,6 @@ __weak_alias(wcstod,_wcstod)
#define _FUNCNAME wcstod
#define _RETURN_TYPE double
-#define _STRTOD_FUNC strtod
+#define _STRTOD_FUNC strtod_l
#include "_wcstod.h"
Index: src/lib/libc/locale/wcstof.c
diff -u src/lib/libc/locale/wcstof.c:1.3 src/lib/libc/locale/wcstof.c:1.4
--- src/lib/libc/locale/wcstof.c:1.3 Fri Apr 25 16:43:00 2008
+++ src/lib/libc/locale/wcstof.c Thu Apr 18 22:23:18 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: wcstof.c,v 1.3 2008/04/25 16:43:00 christos Exp $ */
+/* $NetBSD: wcstof.c,v 1.4 2013/04/18 22:23:18 joerg Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcstof.c,v 1.3 2008/04/25 16:43:00 christos Exp $");
+__RCSID("$NetBSD: wcstof.c,v 1.4 2013/04/18 22:23:18 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -45,6 +45,6 @@ __weak_alias(wcstof,_wcstof)
#define _FUNCNAME wcstof
#define _RETURN_TYPE float
-#define _STRTOD_FUNC strtof
+#define _STRTOD_FUNC strtof_l
#include "_wcstod.h"
Index: src/lib/libc/locale/wcstold.c
diff -u src/lib/libc/locale/wcstold.c:1.3 src/lib/libc/locale/wcstold.c:1.4
--- src/lib/libc/locale/wcstold.c:1.3 Tue Jul 8 00:23:28 2008
+++ src/lib/libc/locale/wcstold.c Thu Apr 18 22:23:18 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: wcstold.c,v 1.3 2008/07/08 00:23:28 gmcgarry Exp $ */
+/* $NetBSD: wcstold.c,v 1.4 2013/04/18 22:23:18 joerg Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcstold.c,v 1.3 2008/07/08 00:23:28 gmcgarry Exp $");
+__RCSID("$NetBSD: wcstold.c,v 1.4 2013/04/18 22:23:18 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -45,6 +45,6 @@ __weak_alias(wcstold,_wcstold)
#define _FUNCNAME wcstold
#define _RETURN_TYPE long double
-#define _STRTOD_FUNC strtold
+#define _STRTOD_FUNC strtold_l
#include "_wcstod.h"