aboutsummaryrefslogtreecommitdiff
path: root/libsylph/utils.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-09-21 11:07:51 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-09-21 11:07:51 +0000
commitf9f8dd90bd443d43855c8a673100d199a1ac6560 (patch)
treedcd78f6ff33d83e00bc56825eb07ba2b1584c774 /libsylph/utils.c
parent1eb9f56ddbd870069cd77a20d7150ac82961042c (diff)
removed mbs/wcs functions which are no longer required.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@596 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/utils.c')
-rw-r--r--libsylph/utils.c211
1 files changed, 1 insertions, 210 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c
index 09632f64..5c0ba893 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -29,11 +29,6 @@
#include <string.h>
#include <ctype.h>
#include <errno.h>
-
-#if (HAVE_WCTYPE_H && HAVE_WCHAR_H)
-# include <wchar.h>
-# include <wctype.h>
-#endif
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -46,6 +41,7 @@
#include <time.h>
#ifdef G_OS_WIN32
+# include <wchar.h>
# include <direct.h>
# include <io.h>
#endif
@@ -429,211 +425,6 @@ gchar *strncpy2(gchar *dest, const gchar *src, size_t n)
return dest;
}
-#if !HAVE_ISWALNUM
-int iswalnum(wint_t wc)
-{
- return g_ascii_isalnum((int)wc);
-}
-#endif
-
-#if !HAVE_ISWSPACE
-int iswspace(wint_t wc)
-{
- return g_ascii_isspace((int)wc);
-}
-#endif
-
-#if !HAVE_TOWLOWER
-wint_t towlower(wint_t wc)
-{
- if (wc >= L'A' && wc <= L'Z')
- return wc + L'a' - L'A';
-
- return wc;
-}
-#endif
-
-#if !HAVE_WCSLEN
-size_t wcslen(const wchar_t *s)
-{
- size_t len = 0;
-
- while (*s != L'\0')
- ++len, ++s;
-
- return len;
-}
-#endif
-
-#if !HAVE_WCSCPY
-/* Copy SRC to DEST. */
-wchar_t *wcscpy(wchar_t *dest, const wchar_t *src)
-{
- wint_t c;
- wchar_t *s = dest;
-
- do {
- c = *src++;
- *dest++ = c;
- } while (c != L'\0');
-
- return s;
-}
-#endif
-
-#if !HAVE_WCSNCPY
-/* Copy no more than N wide-characters of SRC to DEST. */
-wchar_t *wcsncpy (wchar_t *dest, const wchar_t *src, size_t n)
-{
- wint_t c;
- wchar_t *s = dest;
-
- do {
- c = *src++;
- *dest++ = c;
- if (--n == 0)
- return s;
- } while (c != L'\0');
-
- /* zero fill */
- do
- *dest++ = L'\0';
- while (--n > 0);
-
- return s;
-}
-#endif
-
-/* Duplicate S, returning an identical malloc'd string. */
-wchar_t *wcsdup(const wchar_t *s)
-{
- wchar_t *new_str;
-
- if (s) {
- new_str = g_new(wchar_t, wcslen(s) + 1);
- wcscpy(new_str, s);
- } else
- new_str = NULL;
-
- return new_str;
-}
-
-/* Duplicate no more than N wide-characters of S,
- returning an identical malloc'd string. */
-wchar_t *wcsndup(const wchar_t *s, size_t n)
-{
- wchar_t *new_str;
-
- if (s) {
- new_str = g_new(wchar_t, n + 1);
- wcsncpy(new_str, s, n);
- new_str[n] = (wchar_t)0;
- } else
- new_str = NULL;
-
- return new_str;
-}
-
-wchar_t *strdup_mbstowcs(const gchar *s)
-{
- wchar_t *new_str;
-
- if (s) {
- new_str = g_new(wchar_t, strlen(s) + 1);
- if (mbstowcs(new_str, s, strlen(s) + 1) < 0) {
- g_free(new_str);
- new_str = NULL;
- } else
- new_str = g_realloc(new_str,
- sizeof(wchar_t) * (wcslen(new_str) + 1));
- } else
- new_str = NULL;
-
- return new_str;
-}
-
-gchar *strdup_wcstombs(const wchar_t *s)
-{
- gchar *new_str;
- size_t len;
-
- if (s) {
- len = wcslen(s) * MB_CUR_MAX + 1;
- new_str = g_new(gchar, len);
- if (wcstombs(new_str, s, len) < 0) {
- g_free(new_str);
- new_str = NULL;
- } else
- new_str = g_realloc(new_str, strlen(new_str) + 1);
- } else
- new_str = NULL;
-
- return new_str;
-}
-
-/* Compare S1 and S2, ignoring case. */
-gint wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
-{
- wint_t c1;
- wint_t c2;
-
- while (n--) {
- c1 = towlower(*s1++);
- c2 = towlower(*s2++);
- if (c1 != c2)
- return c1 - c2;
- else if (c1 == 0 && c2 == 0)
- break;
- }
-
- return 0;
-}
-
-/* Find the first occurrence of NEEDLE in HAYSTACK, ignoring case. */
-wchar_t *wcscasestr(const wchar_t *haystack, const wchar_t *needle)
-{
- register size_t haystack_len, needle_len;
-
- haystack_len = wcslen(haystack);
- needle_len = wcslen(needle);
-
- if (haystack_len < needle_len || needle_len == 0)
- return NULL;
-
- while (haystack_len >= needle_len) {
- if (!wcsncasecmp(haystack, needle, needle_len))
- return (wchar_t *)haystack;
- else {
- haystack++;
- haystack_len--;
- }
- }
-
- return NULL;
-}
-
-gint get_mbs_len(const gchar *s)
-{
- const gchar *p = s;
- gint mb_len;
- gint len = 0;
-
- if (!p)
- return -1;
-
- while (*p != '\0') {
- mb_len = g_utf8_skip[*(guchar *)p];
- if (mb_len == 0)
- break;
- else
- len++;
-
- p += mb_len;
- }
-
- return len;
-}
-
/* Examine if next block is non-ASCII string */
gboolean is_next_nonascii(const gchar *s)
{