From d4d33cad656338adee2ec6643e4ed5a03dc76d3b Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 25 Dec 2007 08:33:52 +0000 Subject: [PATCH] --- ase/cmn/str.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ase/cmn/str.c b/ase/cmn/str.c index 881edf65..1e09c4c3 100644 --- a/ase/cmn/str.c +++ b/ase/cmn/str.c @@ -41,10 +41,36 @@ ase_size_t ase_strxcpy ( ase_size_t ase_strncpy ( ase_char_t* buf, const ase_char_t* str, ase_size_t len) { + /* const ase_char_t* end = str + len; while (str < end) *buf++ = *str++; *buf = ASE_T('\0'); 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 (