From cf3b5ee2cff8f100e553bdcc1a9ab5083c29f73a Mon Sep 17 00:00:00 2001 From: solar Date: Fri, 31 Dec 2010 08:47:37 +0000 Subject: [PATCH] I am not sure I understood strcoll() and strxfrm() correctly, but this is it for now. git-svn-id: https://srv7.svn-repos.de/dev34/pdclib/trunk@510 546481bc-9713-0410-bf18-d3337bbf4a3e --- functions/string/strcoll.c | 10 ++++++++-- functions/string/strxfrm.c | 5 +++-- platform/example/functions/_PDCLIB/stdinit.c | 3 ++- platform/example/internals/_PDCLIB_config.h | 7 +++++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/functions/string/strcoll.c b/functions/string/strcoll.c index 58814d6..16a5680 100644 --- a/functions/string/strcoll.c +++ b/functions/string/strcoll.c @@ -10,10 +10,16 @@ #ifndef REGTEST -/* TODO: Dummy function, PDCLib does not support locales yet. */ +#include + int strcoll( const char * s1, const char * s2 ) { - return strcmp( s1, s2 ); + while ( ( *s1 ) && ( _PDCLIB_lconv.ctype[(unsigned char)*s1].collation == _PDCLIB_lconv.ctype[(unsigned char)*s2].collation ) ) + { + ++s1; + ++s2; + } + return ( _PDCLIB_lconv.ctype[(unsigned char)*s1].collation == _PDCLIB_lconv.ctype[(unsigned char)*s2].collation ); } #endif diff --git a/functions/string/strxfrm.c b/functions/string/strxfrm.c index 2f8f7a6..4f5e4a0 100644 --- a/functions/string/strxfrm.c +++ b/functions/string/strxfrm.c @@ -10,7 +10,8 @@ #ifndef REGTEST -/* TODO: Dummy function, no locale support yet. */ +#include + size_t strxfrm( char * _PDCLIB_restrict s1, const char * _PDCLIB_restrict s2, size_t n ) { size_t len = strlen( s2 ); @@ -19,7 +20,7 @@ size_t strxfrm( char * _PDCLIB_restrict s1, const char * _PDCLIB_restrict s2, si /* Cannot use strncpy() here as the filling of s1 with '\0' is not part of the spec. */ - while ( n-- && ( *s1++ = *s2++ ) ); + while ( n-- && ( *s1++ = _PDCLIB_lconv.ctype[(unsigned char)*s2++].collation ) ); } return len; } diff --git a/platform/example/functions/_PDCLIB/stdinit.c b/platform/example/functions/_PDCLIB/stdinit.c index 9467077..2554e9f 100644 --- a/platform/example/functions/_PDCLIB/stdinit.c +++ b/platform/example/functions/_PDCLIB/stdinit.c @@ -310,7 +310,8 @@ struct lconv _PDCLIB_lconv = { { /* no error */ (char *)"", /* ERANGE */ (char *)"ERANGE (Range error)", - /* EDOM */ (char *)"EDOM (Domain error)" + /* EDOM */ (char *)"EDOM (Domain error)", + /* EILSEQ */ (char *)"EILSEQ (Illegal sequence)" }, /* decimal_point */ (char *)".", /* thousands_sep */ (char *)"", diff --git a/platform/example/internals/_PDCLIB_config.h b/platform/example/internals/_PDCLIB_config.h index 0059a7f..64cc98d 100644 --- a/platform/example/internals/_PDCLIB_config.h +++ b/platform/example/internals/_PDCLIB_config.h @@ -37,8 +37,8 @@ /* strerror() and perror() functions. (If you change this value because you */ /* are using additional errno values, you *HAVE* to provide appropriate error */ /* messages for *ALL* locales.) */ -/* Default is 2 (0, ERANGE, EDOM). */ -#define _PDCLIB_ERRNO_MAX 3 +/* Default is 4 (0, ERANGE, EDOM, EILSEQ). */ +#define _PDCLIB_ERRNO_MAX 4 /* -------------------------------------------------------------------------- */ /* Integers */ @@ -341,6 +341,9 @@ typedef int _PDCLIB_fd_t; an uppercase 'E', and there is no mechanics in to unmask that particular value (for exactly that reason). + There also is no error message available for this value through either the + strerror() or perror() functions. It is being reported as "unknown" error. + The idea is that you scan the source of PDCLib for occurrences of this macro and replace _PDCLIB_ERROR with whatever additional errno value you came up with for your platform. -- 2.30.2