diff options
author | Andreas Schneider <asn@samba.org> | 2022-03-23 12:45:37 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2022-12-23 13:23:29 +0000 |
commit | a8f6fa03ef68f086e46539af4d4594b35e638e37 (patch) | |
tree | 4cc7019d94c16cf4672a5094eb8851ee61e875e5 /lib | |
parent | 78ca66a1a54ede649ca9726e81b420993234b1cf (diff) | |
download | samba-a8f6fa03ef68f086e46539af4d4594b35e638e37.tar.gz |
lib:ldb: Add ldb_ascii_toupper()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15248
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ldb/common/ldb_utf8.c | 4 | ||||
-rw-r--r-- | lib/ldb/include/ldb_private.h | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/ldb/common/ldb_utf8.c b/lib/ldb/common/ldb_utf8.c index a3a328310a7..0184222d126 100644 --- a/lib/ldb/common/ldb_utf8.c +++ b/lib/ldb/common/ldb_utf8.c @@ -134,3 +134,7 @@ int ldb_attr_dn(const char *attr) } return -1; } + +_PRIVATE_ char ldb_ascii_toupper(char c) { + return ('a' <= c && c <= 'z') ? c ^ 0x20 : toupper(c); +} diff --git a/lib/ldb/include/ldb_private.h b/lib/ldb/include/ldb_private.h index bcf7770ea93..7d9a47c8ef3 100644 --- a/lib/ldb/include/ldb_private.h +++ b/lib/ldb/include/ldb_private.h @@ -317,4 +317,17 @@ int ldb_match_message(struct ldb_context *ldb, const struct ldb_parse_tree *tree, enum ldb_scope scope, bool *matched); +/** + * @brief Convert a character to uppercase with ASCII precedence. + * + * This will convert a character to uppercase. If the character is an ASCII + * character it will convert it to uppercase ASCII first and then fallback to + * localized toupper() from libc. + * + * @param c The character to convert. + * + * @return The converted character or c if the conversion was not possible. + */ +char ldb_ascii_toupper(char c); + #endif |