[RFA] wcscoll

J. Johnston jjohnstn@redhat.com
Wed Apr 2 21:16:00 GMT 2003


Ok if you add some form of comment in the doc comments to denote that the
current implementation simply uses wcscmp() and does not support
any language-specific sorting.

-- Jeff J.

Corinna Vinschen wrote:
> On Wed, Apr 02, 2003 at 01:19:48PM +0200, Corinna Vinschen wrote:
> 
>>Hi,
>>
>>I've implemented wcscoll() by calling wcscmp() as strcoll() is implemented
>>by calling strcmp().
>>
>>Ok to commit?
> 
> 
> Oops, I forgot the necessary patch to wchar.h.
> 
> New patch attached.
> 
> Corinna
> 
> 2001-04-02  Corinna Vinschen  <corinna@vinschen.de>
> 
> 	* libc/include/wchar.h: Add definition for wcscoll.
> 	* libc/string/Makefile.am: Add wcscoll.c.
> 	* libc/string/Makefile.in: Regenerated.
> 	* libc/string/wcscoll.c: New file.
> 	* libc/string/wcstrings.tex: Add wcscoll.
> 
> Index: libc/include/wchar.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/wchar.h,v
> retrieving revision 1.8
> diff -p -u -r1.8 wchar.h
> --- libc/include/wchar.h	7 Nov 2002 00:44:31 -0000	1.8
> +++ libc/include/wchar.h	2 Apr 2003 11:22:38 -0000
> @@ -49,6 +49,7 @@ size_t	_EXFUN(wcsrtombs, (char * , const
>  wchar_t	*_EXFUN(wcscat, (wchar_t * , const wchar_t *));
>  wchar_t	*_EXFUN(wcschr, (const wchar_t *, wchar_t));
>  int	_EXFUN(wcscmp, (const wchar_t *, const wchar_t *));
> +int	_EXFUN(wcscoll, (const wchar_t *, const wchar_t *));
>  wchar_t	*_EXFUN(wcscpy, (wchar_t * , const wchar_t *));
>  size_t	_EXFUN(wcscspn, (const wchar_t *, const wchar_t *));
>  size_t	_EXFUN(wcslcat, (wchar_t *, const wchar_t *, size_t));
> Index: libc/string/Makefile.am
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/string/Makefile.am,v
> retrieving revision 1.10
> diff -p -u -r1.10 Makefile.am
> --- libc/string/Makefile.am	29 Aug 2002 19:47:43 -0000	1.10
> +++ libc/string/Makefile.am	2 Apr 2003 11:22:38 -0000
> @@ -48,6 +48,7 @@ GENERAL_SOURCES = \
>  	wcscat.c \
>  	wcschr.c \
>  	wcscmp.c \
> +	wcscoll.c \
>  	wcscpy.c \
>  	wcscspn.c \
>  	wcslcat.c \
> @@ -104,7 +105,8 @@ memchr.def	strcat.def	strerror.def	strer
>  memcmp.def	strchr.def	strlen.def	strnlen.def strspn.def \
>  strcasecmp.def	strncasecmp.def strlwr.def	strupr.def  memccpy.def \
>  mempcpy.def \
> -wcscat.def	wcschr.def	wcscmp.def	wcscpy.def wcscspn.def \
> +wcscat.def	wcschr.def	wcscmp.def	wcscoll.def \
> +wcscpy.def wcscspn.def \
>  wcslcat.def	wcslcpy.def	wcslen.def	wcsncat.def wcsncmp.def \
>  wcsncpy.def	wcspbrk.def	wcsrchr.def	wcsspn.def wcsstr.def \
>  wmemchr.def	wmemcmp.def	wmemcpy.def	wmemmove.def wmemset.def
> Index: libc/string/Makefile.in
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/string/Makefile.in,v
> retrieving revision 1.14
> diff -p -u -r1.14 Makefile.in
> --- libc/string/Makefile.in	29 Aug 2002 19:47:43 -0000	1.14
> +++ libc/string/Makefile.in	2 Apr 2003 11:22:38 -0000
> @@ -154,6 +154,7 @@ GENERAL_SOURCES = \
>  	wcscat.c \
>  	wcschr.c \
>  	wcscmp.c \
> +	wcscoll.c \
>  	wcscpy.c \
>  	wcscspn.c \
>  	wcslcat.c \
> @@ -202,7 +203,8 @@ memchr.def	strcat.def	strerror.def	strer
>  memcmp.def	strchr.def	strlen.def	strnlen.def strspn.def \
>  strcasecmp.def	strncasecmp.def strlwr.def	strupr.def  memccpy.def \
>  mempcpy.def \
> -wcscat.def	wcschr.def	wcscmp.def	wcscpy.def wcscspn.def \
> +wcscat.def	wcschr.def	wcscmp.def	wcscoll.def \
> +wcscpy.def wcscspn.def \
>  wcslcat.def	wcslcpy.def	wcslen.def	wcsncat.def wcsncmp.def \
>  wcsncpy.def	wcspbrk.def	wcsrchr.def	wcsspn.def wcsstr.def \
>  wmemchr.def	wmemcmp.def	wmemcpy.def	wmemmove.def wmemset.def
> @@ -239,8 +241,8 @@ LIBS = @LIBS@
>  @USE_LIBTOOL_FALSE@strspn.$(OBJEXT) strtok.$(OBJEXT) strtok_r.$(OBJEXT) \
>  @USE_LIBTOOL_FALSE@strupr.$(OBJEXT) strxfrm.$(OBJEXT) strstr.$(OBJEXT) \
>  @USE_LIBTOOL_FALSE@swab.$(OBJEXT) u_strerr.$(OBJEXT) wcscat.$(OBJEXT) \
> -@USE_LIBTOOL_FALSE@wcschr.$(OBJEXT) wcscmp.$(OBJEXT) wcscpy.$(OBJEXT) \
> -@USE_LIBTOOL_FALSE@wcscspn.$(OBJEXT) wcslcat.$(OBJEXT) \
> +@USE_LIBTOOL_FALSE@wcschr.$(OBJEXT) wcscmp.$(OBJEXT) wcscoll.$(OBJEXT) \
> +@USE_LIBTOOL_FALSE@wcscpy.$(OBJEXT) wcscspn.$(OBJEXT) wcslcat.$(OBJEXT) \
>  @USE_LIBTOOL_FALSE@wcslcpy.$(OBJEXT) wcslen.$(OBJEXT) wcsncat.$(OBJEXT) \
>  @USE_LIBTOOL_FALSE@wcsncmp.$(OBJEXT) wcsncpy.$(OBJEXT) \
>  @USE_LIBTOOL_FALSE@wcspbrk.$(OBJEXT) wcsrchr.$(OBJEXT) wcsspn.$(OBJEXT) \
> @@ -258,10 +260,10 @@ LTLIBRARIES =  $(noinst_LTLIBRARIES)
>  @USE_LIBTOOL_TRUE@strncmp.lo strncpy.lo strnlen.lo strpbrk.lo \
>  @USE_LIBTOOL_TRUE@strrchr.lo strsep.lo strspn.lo strtok.lo strtok_r.lo \
>  @USE_LIBTOOL_TRUE@strupr.lo strxfrm.lo strstr.lo swab.lo u_strerr.lo \
> -@USE_LIBTOOL_TRUE@wcscat.lo wcschr.lo wcscmp.lo wcscpy.lo wcscspn.lo \
> -@USE_LIBTOOL_TRUE@wcslcat.lo wcslcpy.lo wcslen.lo wcsncat.lo wcsncmp.lo \
> -@USE_LIBTOOL_TRUE@wcsncpy.lo wcspbrk.lo wcsrchr.lo wcsspn.lo wcsstr.lo \
> -@USE_LIBTOOL_TRUE@wmemchr.lo wmemcmp.lo wmemcpy.lo wmemmove.lo \
> +@USE_LIBTOOL_TRUE@wcscat.lo wcschr.lo wcscmp.lo wcscoll.lo wcscpy.lo \
> +@USE_LIBTOOL_TRUE@wcscspn.lo wcslcat.lo wcslcpy.lo wcslen.lo wcsncat.lo \
> +@USE_LIBTOOL_TRUE@wcsncmp.lo wcsncpy.lo wcspbrk.lo wcsrchr.lo wcsspn.lo \
> +@USE_LIBTOOL_TRUE@wcsstr.lo wmemchr.lo wmemcmp.lo wmemcpy.lo wmemmove.lo \
>  @USE_LIBTOOL_TRUE@wmemset.lo
>  CFLAGS = @CFLAGS@
>  COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
> Index: libc/string/wcscoll.c
> ===================================================================
> RCS file: libc/string/wcscoll.c
> diff -N libc/string/wcscoll.c
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ libc/string/wcscoll.c	2 Apr 2003 11:22:38 -0000
> @@ -0,0 +1,45 @@
> +/*
> +FUNCTION
> +	<<wcscoll>>---locale specific wide-character string compare
> +	
> +INDEX
> +	wcscoll
> +
> +ANSI_SYNOPSIS
> +	#include <string.h>
> +	int wcscoll(const char *<[stra]>, const char * <[strb]>);
> +
> +TRAD_SYNOPSIS
> +	#include <string.h>
> +	int wcscoll(<[stra]>, <[strb]>)
> +	char *<[stra]>;
> +	char *<[strb]>;
> +
> +DESCRIPTION
> +	<<wcscoll>> compares the wide-character string pointed to by
> +	<[stra]> to the wide-character string pointed to by <[strb]>,
> +	using an interpretation appropriate to the current <<LC_COLLATE>>
> +	state.
> +
> +RETURNS
> +	If the first string is greater than the second string,
> +	<<wcscoll>> returns a number greater than zero.  If the two
> +	strings are equivalent, <<wcscoll>> returns zero.  If the first
> +	string is less than the second string, <<wcscoll>> returns a
> +	number less than zero.
> +
> +PORTABILITY
> +<<wcscoll>> is ISO/IEC 9899/AMD1:1995 (ISO C).
> +*/
> +
> +#include <_ansi.h>
> +#include <wchar.h>
> +
> +int
> +_DEFUN (wcscoll, (a, b),
> +	_CONST wchar_t *a _AND
> +	_CONST wchar_t *b)
> +
> +{
> +  return wcscmp (a, b);
> +}
> Index: libc/string/wcstrings.tex
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/string/wcstrings.tex,v
> retrieving revision 1.1
> diff -p -u -r1.1 wcstrings.tex
> --- libc/string/wcstrings.tex	29 Aug 2002 19:47:43 -0000	1.1
> +++ libc/string/wcstrings.tex	2 Apr 2003 11:22:38 -0000
> @@ -14,6 +14,7 @@ declarations are in @file{wchar.h}.
>  * wcscat::      Concatenate wide-character strings
>  * wcschr::      Search for wide-character in string
>  * wcscmp::      Wide-character string compare
> +* wcscoll::     Locale specific Wide-character string compare
>  * wcscpy::      Copy wide-character string
>  * wcscspn::     Count wide-chars not in string
>  * wcslcat::     Concatenate wide-character strings to specified length
> @@ -51,6 +52,9 @@ declarations are in @file{wchar.h}.
>  
>  @page
>  @include string/wcscmp.def
> +
> +@page
> +@include string/wcscoll.def
>  
>  @page
>  @include string/wcscpy.def
> 




More information about the Newlib mailing list