summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/Symbol.map18
-rw-r--r--lib/libc/stdlib/atof.c14
-rw-r--r--lib/libc/stdlib/atoi.c14
-rw-r--r--lib/libc/stdlib/atol.c14
-rw-r--r--lib/libc/stdlib/atoll.c14
-rw-r--r--lib/libc/stdlib/strfmon.c43
-rw-r--r--lib/libc/stdlib/strtoimax.c17
-rw-r--r--lib/libc/stdlib/strtol.c22
-rw-r--r--lib/libc/stdlib/strtoll.c17
-rw-r--r--lib/libc/stdlib/strtoul.c16
-rw-r--r--lib/libc/stdlib/strtoull.c17
-rw-r--r--lib/libc/stdlib/strtoumax.c17
12 files changed, 203 insertions, 20 deletions
diff --git a/lib/libc/stdlib/Symbol.map b/lib/libc/stdlib/Symbol.map
index d159bed..c268ab9 100644
--- a/lib/libc/stdlib/Symbol.map
+++ b/lib/libc/stdlib/Symbol.map
@@ -92,6 +92,24 @@ FBSD_1.0 {
twalk;
};
+FBSD_1.3 {
+ atof_l;
+ atoi_l;
+ atol_l;
+ atoll_l;
+ strtod_l;
+ strtol_l;
+ strtoll_l;
+ strtof_l;
+ strtoimax_l;
+ strtold_l;
+ strtoq_l;
+ strtoul_l;
+ strtoull_l;
+ strtoumax_l;
+ strtouq_l;
+};
+
FBSDprivate_1.0 {
_malloc_thread_cleanup;
_malloc_prefork;
diff --git a/lib/libc/stdlib/atof.c b/lib/libc/stdlib/atof.c
index 51e482e..746ceac 100644
--- a/lib/libc/stdlib/atof.c
+++ b/lib/libc/stdlib/atof.c
@@ -2,6 +2,11 @@
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -34,6 +39,7 @@ static char sccsid[] = "@(#)atof.c 8.1 (Berkeley) 6/4/93";
__FBSDID("$FreeBSD$");
#include <stdlib.h>
+#include <xlocale.h>
double
atof(ascii)
@@ -41,3 +47,11 @@ atof(ascii)
{
return strtod(ascii, (char **)NULL);
}
+
+double
+atof_l(ascii, locale)
+ const char *ascii;
+ locale_t locale;
+{
+ return strtod_l(ascii, (char **)NULL, locale);
+}
diff --git a/lib/libc/stdlib/atoi.c b/lib/libc/stdlib/atoi.c
index 0ffcd03..31a8676 100644
--- a/lib/libc/stdlib/atoi.c
+++ b/lib/libc/stdlib/atoi.c
@@ -2,6 +2,11 @@
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -34,6 +39,7 @@ static char sccsid[] = "@(#)atoi.c 8.1 (Berkeley) 6/4/93";
__FBSDID("$FreeBSD$");
#include <stdlib.h>
+#include <xlocale.h>
int
atoi(str)
@@ -41,3 +47,11 @@ atoi(str)
{
return (int)strtol(str, (char **)NULL, 10);
}
+
+int
+atoi_l(str, locale)
+ const char *str;
+ locale_t locale;
+{
+ return (int)strtol_l(str, (char **)NULL, 10, locale);
+}
diff --git a/lib/libc/stdlib/atol.c b/lib/libc/stdlib/atol.c
index c9cf2e8..7ebbe01 100644
--- a/lib/libc/stdlib/atol.c
+++ b/lib/libc/stdlib/atol.c
@@ -2,6 +2,11 @@
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -34,6 +39,7 @@ static char sccsid[] = "@(#)atol.c 8.1 (Berkeley) 6/4/93";
__FBSDID("$FreeBSD$");
#include <stdlib.h>
+#include <xlocale.h>
long
atol(str)
@@ -41,3 +47,11 @@ atol(str)
{
return strtol(str, (char **)NULL, 10);
}
+
+long
+atol_l(str, locale)
+ const char *str;
+ locale_t locale;
+{
+ return strtol_l(str, (char **)NULL, 10, locale);
+}
diff --git a/lib/libc/stdlib/atoll.c b/lib/libc/stdlib/atoll.c
index 203c174..cbb5459 100644
--- a/lib/libc/stdlib/atoll.c
+++ b/lib/libc/stdlib/atoll.c
@@ -2,6 +2,11 @@
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -31,6 +36,7 @@
__FBSDID("$FreeBSD$");
#include <stdlib.h>
+#include <xlocale.h>
long long
atoll(str)
@@ -38,3 +44,11 @@ atoll(str)
{
return strtoll(str, (char **)NULL, 10);
}
+
+long long
+atoll_l(str, locale)
+ const char *str;
+ locale_t locale;
+{
+ return strtoll_l(str, (char **)NULL, 10, locale);
+}
diff --git a/lib/libc/stdlib/strfmon.c b/lib/libc/stdlib/strfmon.c
index 6c28254..b82797d 100644
--- a/lib/libc/stdlib/strfmon.c
+++ b/lib/libc/stdlib/strfmon.c
@@ -2,6 +2,11 @@
* Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
* All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -38,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "xlocale_private.h"
/* internal flags */
#define NEED_GROUPING 0x01 /* print digits grouped (default) */
@@ -92,11 +98,10 @@ static void __setup_vars(int, char *, char *, char *, char **);
static int __calc_left_pad(int, char *);
static char *__format_grouped_double(double, int *, int, int, int);
-ssize_t
-strfmon(char * __restrict s, size_t maxsize, const char * __restrict format,
- ...)
+static ssize_t
+vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
+ const char * __restrict format, va_list ap)
{
- va_list ap;
char *dst; /* output destination pointer */
const char *fmt; /* current format poistion pointer */
struct lconv *lc; /* pointer to lconv structure */
@@ -119,10 +124,10 @@ strfmon(char * __restrict s, size_t maxsize, const char * __restrict format,
char *tmpptr; /* temporary vars */
int sverrno;
+ FIX_LOCALE(loc);
- va_start(ap, format);
- lc = localeconv();
+ lc = localeconv_l(loc);
dst = s;
fmt = format;
asciivalue = NULL;
@@ -380,7 +385,6 @@ strfmon(char * __restrict s, size_t maxsize, const char * __restrict format,
}
PRINT('\0');
- va_end(ap);
free(asciivalue);
free(currency_symbol);
return (dst - s - 1); /* return size of put data except trailing '\0' */
@@ -399,9 +403,32 @@ end_error:
if (currency_symbol != NULL)
free(currency_symbol);
errno = sverrno;
- va_end(ap);
return (-1);
}
+ssize_t
+strfmon_l(char * __restrict s, size_t maxsize, locale_t loc, const char * __restrict format,
+ ...)
+{
+ size_t ret;
+ va_list ap;
+ va_start(ap, format);
+ ret = vstrfmon_l(s, maxsize, loc, format, ap);
+ va_end(ap);
+ return ret;
+}
+
+ssize_t
+strfmon(char * __restrict s, size_t maxsize, const char * __restrict format,
+ ...)
+{
+ size_t ret;
+ va_list ap;
+ va_start(ap, format);
+ ret = vstrfmon_l(s, maxsize, __get_locale(), format, ap);
+ va_end(ap);
+ return ret;
+}
+
static void
__setup_vars(int flags, char *cs_precedes, char *sep_by_space,
diff --git a/lib/libc/stdlib/strtoimax.c b/lib/libc/stdlib/strtoimax.c
index 4f0063c..9be773b 100644
--- a/lib/libc/stdlib/strtoimax.c
+++ b/lib/libc/stdlib/strtoimax.c
@@ -2,6 +2,11 @@
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -37,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <stdlib.h>
#include <inttypes.h>
+#include "xlocale_private.h"
/*
* Convert a string to an intmax_t integer.
@@ -45,13 +51,15 @@ __FBSDID("$FreeBSD$");
* alphabets and digits are each contiguous.
*/
intmax_t
-strtoimax(const char * __restrict nptr, char ** __restrict endptr, int base)
+strtoimax_l(const char * __restrict nptr, char ** __restrict endptr, int base,
+ locale_t locale)
{
const char *s;
uintmax_t acc;
char c;
uintmax_t cutoff;
int neg, any, cutlim;
+ FIX_LOCALE(locale);
/*
* Skip white space and pick up leading +/- sign if any.
@@ -61,7 +69,7 @@ strtoimax(const char * __restrict nptr, char ** __restrict endptr, int base)
s = nptr;
do {
c = *s++;
- } while (isspace((unsigned char)c));
+ } while (isspace_l((unsigned char)c, locale));
if (c == '-') {
neg = 1;
c = *s++;
@@ -138,3 +146,8 @@ noconv:
*endptr = (char *)(any ? s - 1 : nptr);
return (acc);
}
+intmax_t
+strtoimax(const char * __restrict nptr, char ** __restrict endptr, int base)
+{
+ return strtoimax_l(nptr, endptr, base, __get_locale());
+}
diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c
index 0d6f736..f80ecb4 100644
--- a/lib/libc/stdlib/strtol.c
+++ b/lib/libc/stdlib/strtol.c
@@ -2,6 +2,11 @@
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -37,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
+#include "xlocale_private.h"
/*
@@ -46,13 +52,15 @@ __FBSDID("$FreeBSD$");
* alphabets and digits are each contiguous.
*/
long
-strtol(const char * __restrict nptr, char ** __restrict endptr, int base)
+strtol_l(const char * __restrict nptr, char ** __restrict endptr, int base,
+ locale_t locale)
{
const char *s;
unsigned long acc;
char c;
unsigned long cutoff;
int neg, any, cutlim;
+ FIX_LOCALE(locale);
/*
* Skip white space and pick up leading +/- sign if any.
@@ -62,7 +70,7 @@ strtol(const char * __restrict nptr, char ** __restrict endptr, int base)
s = nptr;
do {
c = *s++;
- } while (isspace((unsigned char)c));
+ } while (isspace_l((unsigned char)c, locale));
if (c == '-') {
neg = 1;
c = *s++;
@@ -138,3 +146,13 @@ noconv:
*endptr = (char *)(any ? s - 1 : nptr);
return (acc);
}
+long
+strtol(const char * __restrict nptr, char ** __restrict endptr, int base)
+{
+ return strtol_l(nptr, endptr, base, __get_locale());
+}
+long double
+strtold(const char * __restrict nptr, char ** __restrict endptr)
+{
+ return strtold_l(nptr, endptr, __get_locale());
+}
diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c
index 2e5547d..6783327 100644
--- a/lib/libc/stdlib/strtoll.c
+++ b/lib/libc/stdlib/strtoll.c
@@ -2,6 +2,11 @@
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -37,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
+#include "xlocale_private.h"
/*
* Convert a string to a long long integer.
@@ -45,13 +51,15 @@ __FBSDID("$FreeBSD$");
* alphabets and digits are each contiguous.
*/
long long
-strtoll(const char * __restrict nptr, char ** __restrict endptr, int base)
+strtoll_l(const char * __restrict nptr, char ** __restrict endptr, int base,
+ locale_t locale)
{
const char *s;
unsigned long long acc;
char c;
unsigned long long cutoff;
int neg, any, cutlim;
+ FIX_LOCALE(locale);
/*
* Skip white space and pick up leading +/- sign if any.
@@ -61,7 +69,7 @@ strtoll(const char * __restrict nptr, char ** __restrict endptr, int base)
s = nptr;
do {
c = *s++;
- } while (isspace((unsigned char)c));
+ } while (isspace_l((unsigned char)c, locale));
if (c == '-') {
neg = 1;
c = *s++;
@@ -138,3 +146,8 @@ noconv:
*endptr = (char *)(any ? s - 1 : nptr);
return (acc);
}
+long long
+strtoll(const char * __restrict nptr, char ** __restrict endptr, int base)
+{
+ return strtoll_l(nptr, endptr, base, __get_locale());
+}
diff --git a/lib/libc/stdlib/strtoul.c b/lib/libc/stdlib/strtoul.c
index e8d1e11..0ae0661 100644
--- a/lib/libc/stdlib/strtoul.c
+++ b/lib/libc/stdlib/strtoul.c
@@ -2,6 +2,11 @@
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -37,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
+#include "xlocale_private.h"
/*
* Convert a string to an unsigned long integer.
@@ -45,13 +51,14 @@ __FBSDID("$FreeBSD$");
* alphabets and digits are each contiguous.
*/
unsigned long
-strtoul(const char * __restrict nptr, char ** __restrict endptr, int base)
+strtoul_l(const char * __restrict nptr, char ** __restrict endptr, int base, locale_t locale)
{
const char *s;
unsigned long acc;
char c;
unsigned long cutoff;
int neg, any, cutlim;
+ FIX_LOCALE(locale);
/*
* See strtol for comments as to the logic used.
@@ -59,7 +66,7 @@ strtoul(const char * __restrict nptr, char ** __restrict endptr, int base)
s = nptr;
do {
c = *s++;
- } while (isspace((unsigned char)c));
+ } while (isspace_l((unsigned char)c, locale));
if (c == '-') {
neg = 1;
c = *s++;
@@ -116,3 +123,8 @@ noconv:
*endptr = (char *)(any ? s - 1 : nptr);
return (acc);
}
+unsigned long
+strtoul(const char * __restrict nptr, char ** __restrict endptr, int base)
+{
+ return strtoul_l(nptr, endptr, base, __get_locale());
+}
diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c
index f11910c..4b7f1c9 100644
--- a/lib/libc/stdlib/strtoull.c
+++ b/lib/libc/stdlib/strtoull.c
@@ -2,6 +2,11 @@
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -37,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
+#include "xlocale_private.h"
/*
* Convert a string to an unsigned long long integer.
@@ -45,13 +51,15 @@ __FBSDID("$FreeBSD$");
* alphabets and digits are each contiguous.
*/
unsigned long long
-strtoull(const char * __restrict nptr, char ** __restrict endptr, int base)
+strtoull_l(const char * __restrict nptr, char ** __restrict endptr, int base,
+ locale_t locale)
{
const char *s;
unsigned long long acc;
char c;
unsigned long long cutoff;
int neg, any, cutlim;
+ FIX_LOCALE(locale);
/*
* See strtoq for comments as to the logic used.
@@ -59,7 +67,7 @@ strtoull(const char * __restrict nptr, char ** __restrict endptr, int base)
s = nptr;
do {
c = *s++;
- } while (isspace((unsigned char)c));
+ } while (isspace_l((unsigned char)c, locale));
if (c == '-') {
neg = 1;
c = *s++;
@@ -116,3 +124,8 @@ noconv:
*endptr = (char *)(any ? s - 1 : nptr);
return (acc);
}
+unsigned long long
+strtoull(const char * __restrict nptr, char ** __restrict endptr, int base)
+{
+ return strtoull_l(nptr, endptr, base, __get_locale());
+}
diff --git a/lib/libc/stdlib/strtoumax.c b/lib/libc/stdlib/strtoumax.c
index 23050c2..d4362bb 100644
--- a/lib/libc/stdlib/strtoumax.c
+++ b/lib/libc/stdlib/strtoumax.c
@@ -2,6 +2,11 @@
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -37,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <stdlib.h>
#include <inttypes.h>
+#include "xlocale_private.h"
/*
* Convert a string to a uintmax_t integer.
@@ -45,13 +51,15 @@ __FBSDID("$FreeBSD$");
* alphabets and digits are each contiguous.
*/
uintmax_t
-strtoumax(const char * __restrict nptr, char ** __restrict endptr, int base)
+strtoumax_l(const char * __restrict nptr, char ** __restrict endptr, int base,
+ locale_t locale)
{
const char *s;
uintmax_t acc;
char c;
uintmax_t cutoff;
int neg, any, cutlim;
+ FIX_LOCALE(locale);
/*
* See strtoimax for comments as to the logic used.
@@ -59,7 +67,7 @@ strtoumax(const char * __restrict nptr, char ** __restrict endptr, int base)
s = nptr;
do {
c = *s++;
- } while (isspace((unsigned char)c));
+ } while (isspace_l((unsigned char)c, locale));
if (c == '-') {
neg = 1;
c = *s++;
@@ -116,3 +124,8 @@ noconv:
*endptr = (char *)(any ? s - 1 : nptr);
return (acc);
}
+uintmax_t
+strtoumax(const char * __restrict nptr, char ** __restrict endptr, int base)
+{
+ return strtoumax_l(nptr, endptr, base, __get_locale());
+}
OpenPOWER on IntegriCloud