unicode: cache the normalization tables in struct unicode_map

Instead of repeatedly looking up the version add pointers to the
NFD and NFD+CF tables to struct unicode_map, and pass a
unicode_map plus index to the functions using the normalization
tables.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
This commit is contained in:
Christoph Hellwig
2021-09-15 09:00:04 +02:00
committed by Gabriel Krisman Bertazi
parent fbc59d6505
commit 6ca99ce756
5 changed files with 99 additions and 96 deletions

View File

@@ -5,6 +5,8 @@
#include <linux/init.h>
#include <linux/dcache.h>
struct utf8data;
#define UNICODE_MAJ_SHIFT 16
#define UNICODE_MIN_SHIFT 8
@@ -28,8 +30,25 @@ static inline u8 unicode_rev(unsigned int age)
return age & 0xff;
}
/*
* Two normalization forms are supported:
* 1) NFDI
* - Apply unicode normalization form NFD.
* - Remove any Default_Ignorable_Code_Point.
* 2) NFDICF
* - Apply unicode normalization form NFD.
* - Remove any Default_Ignorable_Code_Point.
* - Apply a full casefold (C + F).
*/
enum utf8_normalization {
UTF8_NFDI = 0,
UTF8_NFDICF,
UTF8_NMAX,
};
struct unicode_map {
unsigned int version;
const struct utf8data *ntab[UTF8_NMAX];
};
int utf8_validate(const struct unicode_map *um, const struct qstr *str);