From b8ea709c1e8f0ad031bae9d5f7b340bd642a8620 Mon Sep 17 00:00:00 2001 From: axel Date: Sun, 18 Dec 2005 07:32:05 +1000 Subject: [PATCH] Add autoconf checks for wide character string functions darcs-hash:20051217213205-ac50b-df9ea4cbc1a7e4235578bd4fc542ddb7788d41cc.gz --- common.c | 24 ++++++++++++++++++------ common.h | 14 +++++++++++++- configure.ac | 2 ++ doc_src/block.txt | 2 +- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/common.c b/common.c index 7819a31bd..7fc868a0f 100644 --- a/common.c +++ b/common.c @@ -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 ) { diff --git a/common.h b/common.h index 60b74c538..5176b4e40 100644 --- a/common.h +++ b/common.h @@ -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 b98c61741..68ac8a1ef 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 e5fe2ed24..8e38c04b9 100644 --- a/doc_src/block.txt +++ b/doc_src/block.txt @@ -13,7 +13,7 @@ \subsection block-example Example
block -g
-#Do something that should not be interrupted
+\#Do something that should not be interrupted
 block -e