Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add wcstof_l, wcstod_l and wcstold_l.
details: https://anonhg.NetBSD.org/src/rev/15a9a32c45db
branches: trunk
changeset: 786182:15a9a32c45db
user: joerg <joerg%NetBSD.org@localhost>
date: Thu Apr 18 22:23:17 2013 +0000
description:
Add wcstof_l, wcstod_l and wcstold_l.
diffstat:
include/wchar.h | 6 +++++-
lib/libc/include/namespace.h | 5 ++++-
lib/libc/locale/_wcstod.h | 38 ++++++++++++++++++++++++++++++--------
lib/libc/locale/wcstod.c | 6 +++---
lib/libc/locale/wcstof.c | 6 +++---
lib/libc/locale/wcstold.c | 6 +++---
6 files changed, 48 insertions(+), 19 deletions(-)
diffs (216 lines):
diff -r f648b7db6e89 -r 15a9a32c45db include/wchar.h
--- a/include/wchar.h Thu Apr 18 22:22:20 2013 +0000
+++ b/include/wchar.h Thu Apr 18 22:23:17 2013 +0000
@@ -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 @@
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,
diff -r f648b7db6e89 -r 15a9a32c45db lib/libc/include/namespace.h
--- a/lib/libc/include/namespace.h Thu Apr 18 22:22:20 2013 +0000
+++ b/lib/libc/include/namespace.h Thu Apr 18 22:23:17 2013 +0000
@@ -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
diff -r f648b7db6e89 -r 15a9a32c45db lib/libc/locale/_wcstod.h
--- a/lib/libc/locale/_wcstod.h Thu Apr 18 22:22:20 2013 +0000
+++ b/lib/libc/locale/_wcstod.h Thu Apr 18 22:23:17 2013 +0000
@@ -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 @@
/* 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 @@
* 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 @@
/* 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 @@
*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_*/
diff -r f648b7db6e89 -r 15a9a32c45db lib/libc/locale/wcstod.c
--- a/lib/libc/locale/wcstod.c Thu Apr 18 22:22:20 2013 +0000
+++ b/lib/libc/locale/wcstod.c Thu Apr 18 22:23:17 2013 +0000
@@ -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 @@
#define _FUNCNAME wcstod
#define _RETURN_TYPE double
-#define _STRTOD_FUNC strtod
+#define _STRTOD_FUNC strtod_l
#include "_wcstod.h"
diff -r f648b7db6e89 -r 15a9a32c45db lib/libc/locale/wcstof.c
--- a/lib/libc/locale/wcstof.c Thu Apr 18 22:22:20 2013 +0000
+++ b/lib/libc/locale/wcstof.c Thu Apr 18 22:23:17 2013 +0000
@@ -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 @@
#define _FUNCNAME wcstof
#define _RETURN_TYPE float
-#define _STRTOD_FUNC strtof
+#define _STRTOD_FUNC strtof_l
#include "_wcstod.h"
diff -r f648b7db6e89 -r 15a9a32c45db lib/libc/locale/wcstold.c
--- a/lib/libc/locale/wcstold.c Thu Apr 18 22:22:20 2013 +0000
+++ b/lib/libc/locale/wcstold.c Thu Apr 18 22:23:17 2013 +0000
@@ -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 @@
#define _FUNCNAME wcstold
#define _RETURN_TYPE long double
-#define _STRTOD_FUNC strtold
+#define _STRTOD_FUNC strtold_l
#include "_wcstod.h"
- Prev by Date:
[src/trunk]: src Add wcscoll_l, wcsxfrm_l, wcsncasecmp_l, wcscasecmp_l, btowc_l,
- Next by Date:
[src/trunk]: src/doc wm(4): Add support for I210 and I211.
- Previous by Thread:
[src/trunk]: src Add wcscoll_l, wcsxfrm_l, wcsncasecmp_l, wcscasecmp_l, btowc_l,
- Next by Thread:
[src/trunk]: src/doc wm(4): Add support for I210 and I211.
- Indexes:
Home |
Main Index |
Thread Index |
Old Index