aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-03 11:50:30 +0200
committerMax Kellermann <max@duempel.org>2008-10-03 11:50:30 +0200
commit8b2ace4bc265abde352fcd386ce5f88b88461f4d (patch)
tree19ab87266a0f5bc0ba036e676746deab3776636e /src
parent12ad417fd296daeecff41671b9ab70a3252b4a19 (diff)
downloadmpd-8b2ace4bc265abde352fcd386ce5f88b88461f4d.tar.gz
mpd-8b2ace4bc265abde352fcd386ce5f88b88461f4d.tar.xz
mpd-8b2ace4bc265abde352fcd386ce5f88b88461f4d.zip
use g_ascii_strdown() instead of the custom lowerstr()
Don't duplicate code which is already provided by glib.
Diffstat (limited to 'src')
-rw-r--r--src/conf.c11
-rw-r--r--src/support.c30
-rw-r--r--src/support.h3
3 files changed, 17 insertions, 27 deletions
diff --git a/src/conf.c b/src/conf.c
index 05eb28ff7..ff627e0b6 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -332,14 +332,15 @@ check_screen_list(char *value)
i=0;
j=0;
while( tmp && tmp[i] ) {
- tmp[i] = lowerstr(tmp[i]);
- if (screen_lookup_name(tmp[i]) == NULL)
+ char *name = g_ascii_strdown(tmp[i], -1);
+ if (screen_lookup_name(name) == NULL) {
fprintf(stderr,
_("Error: Unsupported screen \"%s\"\n"),
- tmp[i]);
- else {
+ name);
+ free(name);
+ } else {
screen = g_realloc(screen, (j+2)*sizeof(char *));
- screen[j++] = g_strdup(tmp[i]);
+ screen[j++] = name;
screen[j] = NULL;
}
i++;
diff --git a/src/support.c b/src/support.c
index 3f30671f9..ca0266c1b 100644
--- a/src/support.c
+++ b/src/support.c
@@ -43,24 +43,6 @@ remove_trailing_slash(char *path)
return path;
}
-char *
-lowerstr(char *str)
-{
- gsize i;
- gsize len = strlen(str);
-
- if (str == NULL)
- return NULL;
-
- i = 0;
- while (i < len && str[i]) {
- str[i] = tolower(str[i]);
- i++;
- }
- return str;
-}
-
-
#ifndef HAVE_BASENAME
char *
basename(char *path)
@@ -84,13 +66,21 @@ basename(char *path)
#ifndef HAVE_STRCASESTR
-char *
+const char *
strcasestr(const char *haystack, const char *needle)
{
+ char *haystack2 = g_utf8_strdown(haystack, -1);
+ char *needle2 = g_utf8_strdown(needle, -1);
+ char *result;
+
assert(haystack != NULL);
assert(needle != NULL);
- return strstr(lowerstr(haystack), lowerstr(needle));
+ result = strstr(haystack2, needle2);
+ g_free(haystack2);
+ g_free(needle2);
+
+ return haystack + (result - haystack2);
}
#endif /* HAVE_STRCASESTR */
diff --git a/src/support.h b/src/support.h
index 0679ddc86..5d67b8fa7 100644
--- a/src/support.h
+++ b/src/support.h
@@ -14,8 +14,7 @@ char *basename(char *path);
#define IS_WHITESPACE(c) (c==' ' || c=='\t' || c=='\r' || c=='\n')
char *remove_trailing_slash(char *path);
-char *lowerstr(char *str);
-char *strcasestr(const char *haystack, const char *needle);
+const char *strcasestr(const char *haystack, const char *needle);
typedef struct {
gsize offset;