summaryrefslogtreecommitdiff
path: root/common/compat.c
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2018-05-24 11:01:33 +0200
committerDaiki Ueno <ueno@gnu.org>2018-05-25 12:50:54 +0200
commit117b35db99af4331daad4279eadfb9280e0c1325 (patch)
tree981b85e10f2b1606f57386b2272e793eeb799331 /common/compat.c
parente42dcf5283a5537c196147c9a2468ee537b9da7b (diff)
common: Make case conversion locale independent
The tolower()/toupper() functions take into account of the current locale settings, which p11-kit doesn't want. Add replacement functions that work as if they are called under the C locale.
Diffstat (limited to 'common/compat.c')
-rw-r--r--common/compat.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/common/compat.c b/common/compat.c
index 1e17230..2e559c7 100644
--- a/common/compat.c
+++ b/common/compat.c
@@ -953,3 +953,19 @@ fdwalk (int (* cb) (void *data, int fd),
#endif /* HAVE_FDWALK */
#endif /* OS_UNIX */
+
+int
+p11_ascii_tolower (int c)
+{
+ if (c >= 'A' && c <= 'Z')
+ return 'a' + (c - 'A');
+ return c;
+}
+
+int
+p11_ascii_toupper (int c)
+{
+ if (c >= 'a' && c <= 'z')
+ return 'A' + (c - 'a');
+ return c;
+}