X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrxfrm.c;h=a971e38d572ada95e9a5a7168ccb4365a0465566;hb=refs%2Ftags%2FOLD;hp=6f8a59e9af966ea11ba89894fe96c3d6daafdc89;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec;p=pdclib diff --git a/functions/string/strxfrm.c b/functions/string/strxfrm.c index 6f8a59e..a971e38 100644 --- a/functions/string/strxfrm.c +++ b/functions/string/strxfrm.c @@ -1,8 +1,23 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- - -size_t strxfrm( char * restrict s1, const char * restrict s2, size_t n ) { /* TODO */ }; +/* ---------------------------------------------------------------------------- + * $Id$ + * ---------------------------------------------------------------------------- + * Public Domain C Library - http://pdclib.sourceforge.net + * This code is Public Domain. Use, modify, and redistribute at will. + * --------------------------------------------------------------------------*/ + +#include <__size_t.h> + +/* TODO: Dummy function, no locale support yet. */ + +size_t strlen( const char * src ); +char * strncpy( char * restrict dest, const char * restrict src, size_t n ); + +size_t strxfrm( char * restrict dest, const char * restrict src, size_t n ) +{ + size_t len = strlen( src ); + if ( len < n ) + { + strncpy( dest, src, len ); + } + return len; +}