This commit is contained in:
hyung-hwan 2007-12-25 08:33:52 +00:00
parent 73f73d81c6
commit d4d33cad65

View File

@ -41,10 +41,36 @@ ase_size_t ase_strxcpy (
ase_size_t ase_strncpy ( ase_size_t ase_strncpy (
ase_char_t* buf, const ase_char_t* str, ase_size_t len) ase_char_t* buf, const ase_char_t* str, ase_size_t len)
{ {
/*
const ase_char_t* end = str + len; const ase_char_t* end = str + len;
while (str < end) *buf++ = *str++; while (str < end) *buf++ = *str++;
*buf = ASE_T('\0'); *buf = ASE_T('\0');
return len; return len;
*/
if (len > 0)
{
ase_size_t n = (len-1) >> 3; /* (len-1) / 8 */
switch (len & 7) /* len % 8 */
{
repeat:
case 0: *buf++ = *str++;
case 7: *buf++ = *str++;
case 6: *buf++ = *str++;
case 5: *buf++ = *str++;
case 4: *buf++ = *str++;
case 3: *buf++ = *str++;
case 2: *buf++ = *str++;
case 1: *buf++ = *str++;
if (n <= 0) break;
n--;
goto repeat;
}
}
*buf = ASE_T('\0');
return len;
} }
ase_size_t ase_strxncpy ( ase_size_t ase_strxncpy (