From 5054492c6aba3b73f147921c3a328702ec6ba07e Mon Sep 17 00:00:00 2001 From: axel Date: Thu, 26 Jan 2006 19:57:06 +1000 Subject: [PATCH] Fixes to make fish work on Cygwin. Firstly a bunch of minor fixes fo the wcs* fallback functions, secondly MSG_DONTWAIT (a socket flag) is set to zero if it isn't already defined darcs-hash:20060126095706-ac50b-766c1e2c0408dc51fc7379af38005352f7603b1e.gz --- fishd.c | 9 +++++++++ wutil.c | 16 ++++++++-------- wutil.h | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/fishd.c b/fishd.c index ae4f74b32..7afc11874 100644 --- a/fishd.c +++ b/fishd.c @@ -73,6 +73,15 @@ time the original barrier request was sent have been received. #define UNIX_PATH_MAX 100 #endif +/** + Fallback if MSG_DONTWAIT isn't defined. That's actually prerry bad, + and may lead to strange fishd behaviour, but at least it should + work most of the time. +*/ +#ifndef MSG_DONTWAIT +#define MSG_DONTWAIT 0 +#endif + /** Small greeting to show that fishd is running */ diff --git a/wutil.c b/wutil.c index eb5e17698..b7d115934 100644 --- a/wutil.c +++ b/wutil.c @@ -715,7 +715,7 @@ int wprintf( const wchar_t *filter, ... ) wint_t fgetwc(FILE *stream) { wchar_t res=0; - mbstate_t state=0; + mbstate_t state; memset (&state, '\0', sizeof (state)); while(1) @@ -763,10 +763,10 @@ wint_t getwc(FILE *stream) wint_t fputwc(wchar_t wc, FILE *stream) { int res; - char *s[MB_CUR_MAX+1]; + char s[MB_CUR_MAX+1]; memset( s, 0, MB_CUR_MAX+1 ); wctomb( s, wc ); - res = fputs( sm stream ); + res = fputs( s, stream ); return res==EOF?WEOF:wc; } @@ -782,7 +782,7 @@ wint_t putwc(wchar_t wc, FILE *stream) /* Used by fallback wcstok. Borrowed from glibc */ -static size_t wcsspn (const wchar_t *wcs, +static size_t fish_wcsspn (const wchar_t *wcs, const wchar_t *accept ) { register const wchar_t *p; @@ -806,7 +806,7 @@ static size_t wcsspn (const wchar_t *wcs, /* Used by fallback wcstok. Borrowed from glibc */ -static wchar_t *wcspbrk (const wchar_t *wcs, const wchar_t *accept) +static wchar_t *fish_wcspbrk (const wchar_t *wcs, const wchar_t *accept) { while (*wcs != L'\0') if (wcschr (accept, *wcs) == NULL) @@ -819,7 +819,7 @@ static wchar_t *wcspbrk (const wchar_t *wcs, const wchar_t *accept) /* Fallback wcstok implementation. Borrowed from glibc. */ -wchar_t *wcstok(wchar_t *wcs, const wchar_t *delim, wchar_t **ptr) +wchar_t *wcstok(wchar_t *wcs, const wchar_t *delim, wchar_t **save_ptr) { wchar_t *result; @@ -835,7 +835,7 @@ wchar_t *wcstok(wchar_t *wcs, const wchar_t *delim, wchar_t **ptr) } /* Scan leading delimiters. */ - wcs += wcsspn (wcs, delim); + wcs += fish_wcsspn (wcs, delim); if (*wcs == L'\0') { @@ -846,7 +846,7 @@ wchar_t *wcstok(wchar_t *wcs, const wchar_t *delim, wchar_t **ptr) /* Find the end of the token. */ result = wcs; - wcs = wcspbrk (result, delim); + wcs = fish_wcspbrk (result, delim); if (wcs == NULL) { diff --git a/wutil.h b/wutil.h index 27dacc29b..72a8b2ab1 100644 --- a/wutil.h +++ b/wutil.h @@ -12,7 +12,7 @@ #include #include #include - +#include /** Call this function on startup to create internal wutil