diff options
-rw-r--r-- | common.c | 24 | ||||
-rw-r--r-- | common.h | 14 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | doc_src/block.txt | 2 |
4 files changed, 34 insertions, 8 deletions
@@ -574,6 +574,7 @@ wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz) /* count does not include NUL */ } +#ifndef HAVE_WCSDUP wchar_t *wcsdup( const wchar_t *in ) { size_t len=wcslen(in); @@ -587,10 +588,20 @@ wchar_t *wcsdup( const wchar_t *in ) return out; } +#endif -/** - Fallback implementation if missing from libc -*/ +#ifndef HAVE_WCSLEN +size_t wcslen(const wchar_t *in) +{ + const wchar_t *end=in; + while( *end ) + end++; + return end-in; +} +#endif + + +#ifndef HAVE_WCSCASECMP int wcscasecmp( const wchar_t *a, const wchar_t *b ) { if( *a == 0 ) @@ -607,10 +618,10 @@ int wcscasecmp( const wchar_t *a, const wchar_t *b ) else return wcscasecmp( a+1,b+1); } +#endif -/** - Fallback implementation if missing from libc -*/ + +#ifndef HAVE_WCSNCASECMP int wcsncasecmp( const wchar_t *a, const wchar_t *b, int count ) { if( count == 0 ) @@ -630,6 +641,7 @@ int wcsncasecmp( const wchar_t *a, const wchar_t *b, int count ) else return wcsncasecmp( a+1,b+1, count-1); } +#endif int wcsvarname( wchar_t *str ) { @@ -134,6 +134,7 @@ wchar_t *wcsdupcat( const wchar_t *a, const wchar_t *b ); */ wchar_t *wcsdupcat2( const wchar_t *a, ... ); +#ifndef HAVE_WCSNDUP /** Returns a newly allocated wide character string wich is a copy of the string in, but of length c or shorter. The returned string is @@ -141,6 +142,7 @@ wchar_t *wcsdupcat2( const wchar_t *a, ... ); length. */ wchar_t *wcsndup( const wchar_t *in, int c ); +#endif /** Converts from wide char to digit in the specified base. If d is not @@ -183,12 +185,19 @@ size_t wcslcat( wchar_t *dst, const wchar_t *src, size_t siz ); */ size_t wcslcpy( wchar_t *dst, const wchar_t *src, size_t siz ); +#ifndef HAVE_WCSDUP /** - Create a dublicate string. Wide string version of strdup. Will + Create a duplicate string. Wide string version of strdup. Will automatically exit if out of memory. */ wchar_t *wcsdup(const wchar_t *in); +#endif + +#ifndef HAVE_WCSLEN +size_t wcslen(const wchar_t *in); +#endif +#ifndef HAVE_WCSCASECMP /** Case insensitive string compare function. Wide string version of strcasecmp. @@ -201,7 +210,9 @@ wchar_t *wcsdup(const wchar_t *in); a user-supplied string should be considered a bug. */ int wcscasecmp( const wchar_t *a, const wchar_t *b ); +#endif +#ifndef HAVE_WCSNCASECMP /** Case insensitive string compare function. Wide string version of strncasecmp. @@ -214,6 +225,7 @@ int wcscasecmp( const wchar_t *a, const wchar_t *b ); a user-supplied string should be considered a bug. */ int wcsncasecmp( const wchar_t *a, const wchar_t *b, int count ); +#endif /** Test if the given string is a valid variable name diff --git a/configure.ac b/configure.ac index b98c6174..68ac8a1e 100644 --- a/configure.ac +++ b/configure.ac @@ -120,6 +120,8 @@ fi AC_CHECK_LIB(socket, connect) AC_CHECK_LIB(rt, nanosleep) +AC_CHECK_FUNCS(wcsdup wcsndup wcslen wcscasecmp wcsncasecmp) + # Check if we have ncurses, and use it rather than curses if possible. AC_CHECK_HEADERS([ncurses.h],[AC_SUBST(CURSESLIB,[ncurses]) AC_DEFINE(HAVE_NCURSES_H)],[AC_SUBST(CURSESLIB,[curses])]) diff --git a/doc_src/block.txt b/doc_src/block.txt index e5fe2ed2..8e38c04b 100644 --- a/doc_src/block.txt +++ b/doc_src/block.txt @@ -13,7 +13,7 @@ \subsection block-example Example <pre>block -g -#Do something that should not be interrupted +\#Do something that should not be interrupted block -e </pre> |