From 5074333deda53992b8523d9a96ae9187f8ca2c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 6 Nov 2008 11:26:01 +0000 Subject: [PATCH] * Updating glob() actually broke it, since Haiku does have broken mbrtowc(), and wcrtomb() functions. I worked around the issue, and added a build warning so that we don't forget to change it back once we have working versions of those. * This lets apps like "ftp", and "sftp" work again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28531 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/posix/glob.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/system/libroot/posix/glob.c b/src/system/libroot/posix/glob.c index 8575f70527..a931e345f7 100644 --- a/src/system/libroot/posix/glob.c +++ b/src/system/libroot/posix/glob.c @@ -109,7 +109,7 @@ static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; #define SLASH '/' #define COMMA ',' -#ifndef DEBUG +#if !defined(DEBUG) && !defined(__HAIKU__) #define M_QUOTE 0x8000000000ULL #define M_PROTECT 0x4000000000ULL @@ -164,6 +164,30 @@ static int match(Char *, Char *, Char *); static void qprintf(const char *, Char *); #endif +#ifdef __HAIKU__ +# warning glob() wants to use wide character functions + +static size_t +my_wcrtomb(char* to, char wchar, mbstate_t* state) +{ + *to = wchar; + return 1; +} + +static size_t +my_mbrtowc(wchar_t* to, const char* string, size_t len, mbstate_t* state) +{ + if (!string[0]) + return 0; + *to = *string; + return 1; +} + +# define wcrtomb my_wcrtomb +# define mbrtowc my_mbrtowc +#endif + + int glob(const char *pattern, int flags, int (*errfunc)(const char *, int), glob_t *pglob) {