Hello
Pritpal Bedi wrote:
>
> char * hb_xstrncpy( char * pDest, const char * pSource, ULONG ulLen )
> {
> char *pBuf = pDest;
>
> pDest[ ulLen ] ='\0';
>
> while( ulLen && ( *pDest++ = *pSource++ ) != '\0' )
> ulLen--;
>
> while( ulLen-- )
> *pDest++ = '\0';
>
> return pBuf;
> }
>
And this works:
char * hb_xstrncpy( char * pDest, const char * pSource, ULONG ulLen )
{
char *pBuf = pDest;
ULONG ulDst, ulSrc;
pBuf[ ulLen ] ='\0';
ulDst = strlen( pDest );
if( ulDst < ulLen )
{
ulSrc = strlen( pSource );
if( ulDst + ulSrc > ulLen )
ulSrc = ulLen - ulDst;
memcpy( &pDest[ ulDst ], pSource, ulSrc );
pDest[ ulDst + ulSrc ] = 0;
}
return pDest;
}
I am wondering nobody used hb_strncpy() as before.
Should I commit ?
Regards
Pritpal Bedi
--
View this message in context:
http://www.nabble.com/C-and-Unicode-compliant-string-conversions-tp20721945p20726059.html
Sent from the Harbour - Dev mailing list archive at Nabble.com.
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour