summaryrefslogtreecommitdiff
path: root/src/basic/string-util.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2016-01-11 21:31:53 +0100
committerTom Gundersen <teg@jklm.no>2016-01-11 21:31:53 +0100
commita41a7181c9af8f9ac93a85a2cf133294dd202c8e (patch)
tree89f17418bab87d1466023b124dcd96485cc4df59 /src/basic/string-util.c
parent81c5eb5b3dcaf889c678cd46b97e378e3be4743e (diff)
parenteee026a7ba16336b6493828a2a13ddc9908667ff (diff)
Merge pull request #2289 from poettering/dnssec13
Thirteenth DNSSEC patch set
Diffstat (limited to 'src/basic/string-util.c')
-rw-r--r--src/basic/string-util.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index 8178c7093f..849e457439 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -317,14 +317,33 @@ char *truncate_nl(char *s) {
return s;
}
+char ascii_tolower(char x) {
+
+ if (x >= 'A' && x <= 'Z')
+ return x - 'A' + 'a';
+
+ return x;
+}
+
char *ascii_strlower(char *t) {
char *p;
assert(t);
for (p = t; *p; p++)
- if (*p >= 'A' && *p <= 'Z')
- *p = *p - 'A' + 'a';
+ *p = ascii_tolower(*p);
+
+ return t;
+}
+
+char *ascii_strlower_n(char *t, size_t n) {
+ size_t i;
+
+ if (n <= 0)
+ return t;
+
+ for (i = 0; i < n; i++)
+ t[i] = ascii_tolower(t[i]);
return t;
}