summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-07-19 20:43:54 +0200
committerSven Eden <yamakuzure@gmx.net>2017-07-05 08:50:49 +0200
commit844d57fd5de46b45d8610d296dc5e20d749eff11 (patch)
treece54aadd8bafcc58bc4d45c7fd275e0c55f9460f /src/basic
parentc1d93f2a0a009a95440778c53d89aa693bc6787e (diff)
bootctl: move toupper() implementation to string-util.h
We already have tolower() calls there, hence let's unify this at one place. Also, update the code to only use ASCII operations, so that we don't end up being locale dependant.
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/string-util.c19
-rw-r--r--src/basic/string-util.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index 293a15f9c..e9856b90d 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -323,6 +323,14 @@ char ascii_tolower(char x) {
return x;
}
+char ascii_toupper(char x) {
+
+ if (x >= 'a' && x <= 'z')
+ return x - 'a' + 'A';
+
+ return x;
+}
+
char *ascii_strlower(char *t) {
char *p;
@@ -334,6 +342,17 @@ char *ascii_strlower(char *t) {
return t;
}
+char *ascii_strupper(char *t) {
+ char *p;
+
+ assert(t);
+
+ for (p = t; *p; p++)
+ *p = ascii_toupper(*p);
+
+ return t;
+}
+
char *ascii_strlower_n(char *t, size_t n) {
size_t i;
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index 1209e1e2e..b75aba63c 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -137,6 +137,9 @@ char ascii_tolower(char x);
char *ascii_strlower(char *s);
char *ascii_strlower_n(char *s, size_t n);
+char ascii_toupper(char x);
+char *ascii_strupper(char *s);
+
int ascii_strcasecmp_n(const char *a, const char *b, size_t n);
int ascii_strcasecmp_nn(const char *a, size_t n, const char *b, size_t m);