diff options
| author | gary.li.wenchao.4 <[email protected]> | 2010-02-23 04:44:04 +0000 |
|---|---|---|
| committer | gary.li.wenchao.4 <[email protected]> | 2010-02-23 04:44:04 +0000 |
| commit | d014c0d6da7bfd922674d29cd5e7d027c887f85c (patch) | |
| tree | 7f4f16a445b01cdf2737adb6fa68ae5a59812bf0 | |
| parent | 2c279290f6ba3a5a67a6c22e32979b4eabecb0d4 (diff) | |
add strncmp
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@437 bbd45198-f89e-11dd-88c7-29a3b14d5316
| -rw-r--r-- | libc/minilibc/string.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libc/minilibc/string.c b/libc/minilibc/string.c index 7edba9fc80..0b1d893f2a 100644 --- a/libc/minilibc/string.c +++ b/libc/minilibc/string.c @@ -41,6 +41,25 @@ int strcmp (const char *s1, const char *s2) return (*s1 - *s2); } +/** + * strncmp - Compare two length-limited strings + * @cs: One string + * @ct: Another string + * @count: The maximum number of bytes to compare + */ +int strncmp(const char * cs,const char * ct,rt_ubase_t count) +{ + register signed char __res = 0; + + while (count) { + if ((__res = *cs - *ct++) != 0 || !*cs++) + break; + count--; + } + + return __res; +} + char* strcat(register char* s,register const char* t) { char *dest = s; |
