blob: 2fd676897bdbed866856030d28e2f107aff87ec9 [file] [log] [blame] [raw]
Add support of C.<encoding> LANG variable in C library, such as C.UTF-8.
Backported from FreeBSD base r340144.
diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/lib/libc/locale/collate.c freebsd-11.1/usr/src/lib/libc/locale/collate.c
--- /usr/src/lib/libc/locale/collate.c 2017-07-21 07:41:40.000000000 +0800
+++ freebsd-11.1/usr/src/lib/libc/locale/collate.c 2019-03-22 16:46:30.464970000 +0800
@@ -82,7 +82,8 @@
void *
__collate_load(const char *encoding, __unused locale_t unused)
{
- if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) {
+ if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0 ||
+ strncmp(encoding, "C.", 2) == 0) {
return &__xlocale_C_collate;
}
struct xlocale_collate *table = calloc(sizeof(struct xlocale_collate), 1);
diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/lib/libc/locale/ldpart.c freebsd-11.1/usr/src/lib/libc/locale/ldpart.c
--- /usr/src/lib/libc/locale/ldpart.c 2017-07-21 07:41:40.000000000 +0800
+++ freebsd-11.1/usr/src/lib/libc/locale/ldpart.c 2019-03-22 16:46:30.465950000 +0800
@@ -61,7 +61,8 @@
size_t namesize, bufsize;
/* 'name' must be already checked. */
- if (strcmp(name, "C") == 0 || strcmp(name, "POSIX") == 0) {
+ if (strcmp(name, "C") == 0 || strcmp(name, "POSIX") == 0 ||
+ strncmp(name, "C.", 2) == 0) {
*using_locale = 0;
return (_LDP_CACHE);
}