Revert "Revert "Add locale aware APIs.""
This reverts commit 063e20c26943ec82ef1d53a544545e79054e93d3.
Change-Id: Ib8c9004efefe75a5346b3af50dfe37952d91eb21
diff --git a/libc/include/ctype.h b/libc/include/ctype.h
index 6e97326..19b1adf 100644
--- a/libc/include/ctype.h
+++ b/libc/include/ctype.h
@@ -41,6 +41,7 @@
#define _CTYPE_H_
#include <sys/cdefs.h>
+#include <xlocale.h>
#define _CTYPE_U 0x01
#define _CTYPE_L 0x02
@@ -72,6 +73,22 @@
int tolower(int);
int toupper(int);
+int isalnum_l(int, locale_t);
+int isalpha_l(int, locale_t);
+int isascii_l(int, locale_t);
+int isblank_l(int, locale_t);
+int iscntrl_l(int, locale_t);
+int isdigit_l(int, locale_t);
+int isgraph_l(int, locale_t);
+int islower_l(int, locale_t);
+int isprint_l(int, locale_t);
+int ispunct_l(int, locale_t);
+int isspace_l(int, locale_t);
+int isupper_l(int, locale_t);
+int isxdigit_l(int, locale_t);
+int tolower_l(int, locale_t);
+int toupper_l(int, locale_t);
+
#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE > 200112 \
|| __XPG_VISIBLE > 600
int isblank(int);
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 62b7a67..0dac650 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -75,6 +75,10 @@
extern float strtof(const char*, char**) __LIBC_ABI_PUBLIC__;
extern long double strtold(const char*, char**) __LIBC_ABI_PUBLIC__;
+extern long double strtold_l(const char *, char **, locale_t) __LIBC_ABI_PUBLIC__;
+extern long long strtoll_l(const char *, char **, size_t, locale_t) __LIBC_ABI_PUBLIC__;
+extern unsigned long long strtoull_l(const char *, char **, size_t, locale_t) __LIBC_ABI_PUBLIC__;
+
extern int atoi(const char*) __purefunc;
extern long atol(const char*) __purefunc;
extern long long atoll(const char*) __purefunc;
diff --git a/libc/include/string.h b/libc/include/string.h
index 7727c0e..af1c0c1 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -31,6 +31,7 @@
#include <sys/cdefs.h>
#include <stddef.h>
#include <malloc.h>
+#include <xlocale.h>
__BEGIN_DECLS
@@ -88,6 +89,9 @@
extern int strcoll(const char *, const char *) __purefunc;
extern size_t strxfrm(char* __restrict, const char* __restrict, size_t);
+extern int strcoll_l(const char *, const char *, locale_t) __purefunc;
+extern size_t strxfrm_l(char* __restrict, const char* __restrict, size_t, locale_t);
+
#if defined(__BIONIC_FORTIFY)
__errordecl(__memcpy_dest_size_error, "memcpy: prevented write past end of buffer");
diff --git a/libc/include/time.h b/libc/include/time.h
index 0587a2d..34a53b2 100644
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -31,6 +31,7 @@
#include <sys/cdefs.h>
#include <sys/time.h>
+#include <xlocale.h>
__BEGIN_DECLS
@@ -75,6 +76,7 @@
extern char* strptime(const char*, const char*, struct tm*) __LIBC_ABI_PUBLIC__;
extern size_t strftime(char*, size_t, const char*, const struct tm*) __LIBC_ABI_PUBLIC__;
+extern size_t strftime_l(char *, size_t, const char *, const struct tm *, locale_t) __LIBC_ABI_PUBLIC__;
extern char* ctime(const time_t*) __LIBC_ABI_PUBLIC__;
extern char* ctime_r(const time_t*, char*) __LIBC_ABI_PUBLIC__;
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index 014fed3..1898c7e 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -151,6 +151,13 @@
extern int wprintf(const wchar_t *, ...);
extern int wscanf(const wchar_t *, ...);
+extern long long wcstoll_l(const wchar_t *, wchar_t **, size_t, locale_t);
+extern unsigned long long wcstoull_l(const wchar_t *, wchar_t **, size_t, locale_t);
+extern long double wcstold_l(const wchar_t *, wchar_t **, locale_t );
+
+extern int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
+extern size_t wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t);
+
extern size_t wcslcat(wchar_t*, const wchar_t*, size_t);
extern size_t wcslcpy(wchar_t*, const wchar_t*, size_t);
diff --git a/libc/include/wctype.h b/libc/include/wctype.h
index b5f18a0..1a4a05e 100644
--- a/libc/include/wctype.h
+++ b/libc/include/wctype.h
@@ -1 +1,56 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _WCTYPE_H_
+#define _WCTYPE_H_
+
#include <wchar.h>
+
+__BEGIN_DECLS
+
+extern int iswalnum_l(wint_t, locale_t);
+extern int iswalpha_l(wint_t, locale_t);
+extern int iswblank_l(wint_t, locale_t);
+extern int iswcntrl_l(wint_t, locale_t);
+extern int iswdigit_l(wint_t, locale_t);
+extern int iswgraph_l(wint_t, locale_t);
+extern int iswlower_l(wint_t, locale_t);
+extern int iswprint_l(wint_t, locale_t);
+extern int iswpunct_l(wint_t, locale_t);
+extern int iswspace_l(wint_t, locale_t);
+extern int iswupper_l(wint_t, locale_t);
+extern int iswxdigit_l(wint_t, locale_t);
+extern int towlower_l(int, locale_t);
+extern int towupper_l(int, locale_t);
+
+extern int iswctype_l(wint_t, wctype_t, locale_t);
+extern wctype_t wctype_l(const char*, locale_t);
+
+__END_DECLS
+
+#endif /* _WCTYPE_H_ */