diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-07-19 20:43:54 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-07-21 11:37:58 +0200 |
commit | 846b8fc30d52a63dd6a010e497aa80164fea31d8 (patch) | |
tree | 187b22bdb92f928ab94cec3785d55eedb7f76145 /src/basic/string-util.c | |
parent | fdc1af0a8ac1801a32192d2ad5d7e1245cecc34b (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/string-util.c')
-rw-r--r-- | src/basic/string-util.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c index 293a15f9c0..e9856b90d3 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; |