diff --git a/src/support.c b/src/support.c
index 3f30671f9758d25d52c1bb91a09b39c4300fdc82..8d9d0d01079fa61b8069d14f9f074911f1ebccc3 100644 (file)
--- a/src/support.c
+++ b/src/support.c
-/*
- * $Id$
- *
+/*
* (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
#include <ctype.h>
#include <string.h>
-#define BUFSIZE 1024
-
-char *
-remove_trailing_slash(char *path)
-{
- int len;
-
- if (path == NULL)
- return NULL;
-
- len = strlen(path);
- if (len > 1 && path[len - 1] == '/')
- path[len - 1] = '\0';
-
- 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)
-{
- char *end;
-
- assert(path != NULL);
-
- path = remove_trailing_slash(path);
- end = path + strlen(path);
-
- while (end > path && *end != '/')
- end--;
-
- if (*end == '/' && end != path)
- return end+1;
-
- return path;
-}
-#endif /* HAVE_BASENAME */
-
-
#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 */