From: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
To: viro@ZenIV.linux.org.uk
Cc: jra@google.com, tytso@mit.edu, olaf@sgi.com,
darrick.wong@oracle.com, kernel@lists.collabora.co.uk,
linux-fsdevel@vger.kernel.org, david@fromorbit.com, jack@suse.cz,
linux-kernel@vger.kernel.org,
Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Subject: [PATCH v2 09/15] nls: Add optional normalization and casefold hooks
Date: Mon, 21 May 2018 14:36:11 -0300 [thread overview]
Message-ID: <20180521173617.31625-10-krisman@collabora.co.uk> (raw)
In-Reply-To: <20180521173617.31625-1-krisman@collabora.co.uk>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
---
include/linux/nls.h | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/include/linux/nls.h b/include/linux/nls.h
index 72698d524b42..efd3712f0e81 100644
--- a/include/linux/nls.h
+++ b/include/linux/nls.h
@@ -4,6 +4,7 @@
#include <linux/init.h>
#include <linux/string.h>
+#include <linux/errno.h>
/* Unicode has changed over the years. Unicode code points no longer
* fit into 16 bits; as of Unicode 5 valid code points range from 0
@@ -38,7 +39,12 @@ struct nls_ops {
unsigned int c);
unsigned char (*uppercase)(const struct nls_table *charset,
unsigned int c);
-
+ int (*casefold)(const struct nls_table *charset,
+ const unsigned char *str, size_t len,
+ unsigned char **folded);
+ int (*normalize)(const struct nls_table *charset,
+ const unsigned char *str, size_t len,
+ unsigned char **normalized);
};
struct nls_table {
@@ -156,6 +162,26 @@ static inline int nls_strnicmp(struct nls_table *t, const unsigned char *s1,
return nls_strncasecmp(t, s1, len, s2, len);
}
+static inline int nls_casefold(const struct nls_table *charset,
+ const unsigned char *str, size_t len,
+ unsigned char **folded)
+{
+ if (charset->ops->casefold)
+ return charset->ops->casefold(charset, str, len, folded);
+
+ return -ENOTSUPP;
+}
+
+static inline int nls_normalize(const struct nls_table *charset,
+ const unsigned char *str, size_t len,
+ unsigned char **normalized)
+{
+ if (charset->ops->normalize)
+ return charset->ops->normalize(charset, str, len, normalized);
+
+ return -ENOTSUPP;
+}
+
/*
* nls_nullsize - return length of null character for codepage
* @codepage - codepage for which to return length of NULL terminator
--
2.17.0
next prev parent reply other threads:[~2018-05-21 17:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 17:36 [PATCH v2 00/15] NLS refactor and UTF-8 normalization Gabriel Krisman Bertazi
2018-05-21 17:36 ` [PATCH v2 01/15] nls: Wrap uni2char/char2uni callers Gabriel Krisman Bertazi
2018-05-22 8:37 ` Jan Kara
2018-05-22 8:40 ` Jan Kara
2018-05-21 17:36 ` [PATCH v2 02/15] nls: Wrap charset field access Gabriel Krisman Bertazi
2018-05-21 17:36 ` [PATCH v2 03/15] nls: Wrap charset hooks in ops structure Gabriel Krisman Bertazi
2018-05-21 17:36 ` [PATCH v2 04/15] nls: Split default charset from NLS core Gabriel Krisman Bertazi
2018-05-21 17:36 ` [PATCH v2 05/15] nls: Split struct nls_charset from struct nls_table Gabriel Krisman Bertazi
2018-05-21 17:36 ` [PATCH v2 06/15] nls: Add support for multiple versions of an encoding Gabriel Krisman Bertazi
2018-05-21 17:36 ` [PATCH v2 07/15] nls: Add new interface for string comparisons Gabriel Krisman Bertazi
2018-05-21 17:36 ` [PATCH v2 08/15] nls: Let charsets define the behavior of tolower/toupper Gabriel Krisman Bertazi
2018-05-21 17:36 ` Gabriel Krisman Bertazi [this message]
2018-05-21 17:36 ` [PATCH v2 10/15] nls: utf8norm: Add unicode character database files Gabriel Krisman Bertazi
2018-05-21 17:36 ` [PATCH v2 11/15] scripts: add trie generator for UTF-8 Gabriel Krisman Bertazi
2018-05-21 17:36 ` [PATCH v2 12/15] nls: utf8norm: Introduce code for UTF-8 normalization Gabriel Krisman Bertazi
2018-05-31 5:47 ` kbuild test robot
2018-05-21 17:36 ` [PATCH v2 13/15] nls: utf8norm: reduce the size of utf8data[] Gabriel Krisman Bertazi
2018-05-21 17:36 ` [PATCH v2 14/15] nls: utf8norm: Integrate utf8norm code with NLS subsystem Gabriel Krisman Bertazi
2018-05-21 17:36 ` [PATCH v2 15/15] nls: utf8norm: Introduce test module for utf8norm implementation Gabriel Krisman Bertazi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180521173617.31625-10-krisman@collabora.co.uk \
--to=krisman@collabora.co.uk \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=jack@suse.cz \
--cc=jra@google.com \
--cc=kernel@lists.collabora.co.uk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olaf@sgi.com \
--cc=tytso@mit.edu \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).