blob: 86fe3f40c4afa08715a9debe89ad71064b34b3df [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 /var/archive3/public/freebsd-releng-10.4-src/lib/libc/locale/collate.c freebsd-10.4/lib/libc/locale/collate.c
--- /var/archive3/public/freebsd-releng-10.4-src/lib/libc/locale/collate.c 2017-09-29 08:20:12.000000000 +0800
+++ freebsd-10.4/lib/libc/locale/collate.c 2019-08-18 00:16:05.265159319 +0800
@@ -89,7 +89,8 @@
void *
__collate_load(const char *encoding, 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 /var/archive3/public/freebsd-releng-10.4-src/lib/libc/locale/ldpart.c freebsd-10.4/lib/libc/locale/ldpart.c
--- /var/archive3/public/freebsd-releng-10.4-src/lib/libc/locale/ldpart.c 2017-09-29 08:20:12.000000000 +0800
+++ freebsd-10.4/lib/libc/locale/ldpart.c 2019-08-18 00:16:05.265159319 +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);
}