📄 mbsncpy.c
字号:
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/mbstring/mbsncpy.c
* PURPOSE: Copies a string to a maximum of n bytes or characters
* PROGRAMER: Ariadne
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <mbstring.h>
/*
* @implemented
*/
unsigned char* _mbsncpy(unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
if (n == 0)
return 0;
do {
if (*s2 == 0)
break;
if ( !_ismbblead(*s2) ) {
*s1 = *s2;
s1 += 1;
s2 += 1;
n--;
}
else {
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
*short_s1 = *short_s2;
s1 += 2;
s2 += 2;
n--;
}
} while (n > 0);
return str1;
}
/*
* The _mbsnbcpy function copies count bytes from src to dest. If src is shorter
* than dest, the string is padded with null characters. If dest is less than or
* equal to count it is not terminated with a null character.
*
* @implemented
*/
unsigned char * _mbsnbcpy(unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
if (n == 0)
return 0;
do {
if (*s2 == 0) {
*s1 = *s2;
break;
}
if ( !_ismbblead(*s2) ) {
*s1 = *s2;
s1 += 1;
s2 += 1;
n--;
}
else {
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
*short_s1 = *short_s2;
s1 += 2;
s2 += 2;
n-=2;
}
} while (n > 0);
return str1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -