mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-30 13:13:43 +08:00
f5117c6504
Support a new directive 'codepoint_collation' in the LC_COLLATE section of a locale source file. This new directive causes all collation rules to be dropped and instead STRCMP (strcmp or wcscmp) is used for collation of the input character set. This is required to allow for a C.UTF-8 that contains zero collation rules (minimal size) and sorts using code point sorting. To date the only implementation of a locale with zero collation rules is the C/POSIX locale. The C/POSIX locale provides identity tables for _NL_COLLATE_COLLSEQMB and _NL_COLLATE_COLLSEQWC that map to ASCII even though it has zero rules. This has lead to existing fnmatch, regexec, and regcomp implementations that require these tables. It is not correct to use these tables when nrules == 0, but the conservative fix is to provide these tables when nrules == 0. This assures that existing static applications using a new C.UTF-8 locale with 'codepoint_collation' at least have functional range expressions with ASCII e.g. [0-9] or [a-z]. Such static applications would not have the fixes to fnmatch, regexec and regcomp that avoid the use of the tables when nrules == 0. Future fixes to fnmatch, regexec, and regcomp would allow range expressions to use the full set of code points for such ranges. Tested on x86_64 and i686 without regression. Reviewed-by: Florian Weimer <fweimer@redhat.com>
73 lines
2.1 KiB
C
73 lines
2.1 KiB
C
/* Copyright (C) 1995-2021 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
#include <endian.h>
|
|
#include <stdint.h>
|
|
#include "localeinfo.h"
|
|
|
|
#include "C-collate-seq.c"
|
|
|
|
const struct __locale_data _nl_C_LC_COLLATE attribute_hidden =
|
|
{
|
|
_nl_C_name,
|
|
NULL, 0, 0, /* no file mapped */
|
|
{ NULL, }, /* no cached data */
|
|
UNDELETABLE,
|
|
0,
|
|
19,
|
|
{
|
|
/* _NL_COLLATE_NRULES */
|
|
{ .word = 0 },
|
|
/* _NL_COLLATE_RULESETS */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_TABLEMB */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_WEIGHTMB */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_EXTRAMB */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_INDIRECTMB */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_GAP1 */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_GAP2 */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_GAP3 */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_TABLEWC */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_WEIGHTWC */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_EXTRAWC */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_INDIRECTWC */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_SYMB_HASH_SIZEMB */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_SYMB_TABLEMB */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_SYMB_EXTRAMB */
|
|
{ .string = NULL },
|
|
/* _NL_COLLATE_COLLSEQMB */
|
|
{ .string = collseqmb },
|
|
/* _NL_COLLATE_COLLSEQWC */
|
|
{ .string = (const char *) collseqwc },
|
|
/* _NL_COLLATE_CODESET */
|
|
{ .string = _nl_C_codeset }
|
|
}
|
|
};
|