From: <ny...@us...> - 2007-01-29 14:07:33
|
Revision: 295 http://svn.sourceforge.net/pmplib/?rev=295&view=rev Author: nyaochi Date: 2007-01-29 06:07:30 -0800 (Mon, 29 Jan 2007) Log Message: ----------- Implemented UCS-2 functions similar to ANSI C string routines. We won't implement strcoll(), strtok(), and strxfrm() though. Modified Paths: -------------- trunk/pmplib/include/ucs2char.h trunk/pmplib/lib/ucs2/ucs2char.c Modified: trunk/pmplib/include/ucs2char.h =================================================================== --- trunk/pmplib/include/ucs2char.h 2007-01-28 22:46:02 UTC (rev 294) +++ trunk/pmplib/include/ucs2char.h 2007-01-29 14:07:30 UTC (rev 295) @@ -69,29 +69,35 @@ UCS2API int isucs2space(ucs2char_t c); UCS2API int isucs2digit(ucs2char_t c); +UCS2API ucs2char_t* ucs2cat(ucs2char_t* dst, const ucs2char_t* src); +UCS2API ucs2char_t* ucs2chr(const ucs2char_t* string, ucs2char_t c); +UCS2API int ucs2cmp(const ucs2char_t* x, const ucs2char_t* y); +UCS2API ucs2char_t* ucs2cpy(ucs2char_t* dst, const ucs2char_t* src); +UCS2API size_t ucs2cspn(const ucs2char_t *str, const ucs2char_t *charset); +UCS2API ucs2char_t* ucs2dup(const ucs2char_t* src); UCS2API size_t ucs2len(const ucs2char_t* string); -UCS2API ucs2char_t* ucs2cpy(ucs2char_t* dst, const ucs2char_t* src); +UCS2API ucs2char_t* ucs2ncat(ucs2char_t *dst, const ucs2char_t *src, size_t count); +UCS2API int ucs2ncmp(const ucs2char_t* x, const ucs2char_t* y, size_t n); UCS2API ucs2char_t* ucs2ncpy(ucs2char_t* dst, const ucs2char_t* src, size_t count); -UCS2API ucs2char_t* ucs2cat(ucs2char_t* dst, const ucs2char_t* src); - -UCS2API ucs2char_t* ucs2chr(const ucs2char_t* string, ucs2char_t c); +UCS2API ucs2char_t* ucs2pbrk(const ucs2char_t *str, const ucs2char_t *search); UCS2API ucs2char_t* ucs2rchr(const ucs2char_t* string, ucs2char_t c); - +UCS2API size_t ucs2spn(const ucs2char_t *str, const ucs2char_t *charset); UCS2API ucs2char_t* ucs2str(const ucs2char_t* str, const ucs2char_t* search); + + + + UCS2API ucs2char_t ucs2lower(ucs2char_t c); UCS2API ucs2char_t* ucs2lwr(ucs2char_t* str); UCS2API ucs2char_t ucs2upper(ucs2char_t c); UCS2API ucs2char_t* ucs2upr(ucs2char_t* str); -UCS2API ucs2char_t* ucs2dup(const ucs2char_t* src); UCS2API ucs2char_t* ucs2ndup(const ucs2char_t* src, size_t length); UCS2API ucs2char_t* ucs2strip(ucs2char_t* str); -UCS2API int ucs2cmp(const ucs2char_t* x, const ucs2char_t* y); -UCS2API int ucs2ncmp(const ucs2char_t* x, const ucs2char_t* y, size_t n); UCS2API int ucs2icmp(const ucs2char_t* x, const ucs2char_t* y); UCS2API int ucs2incmp(const ucs2char_t* x, const ucs2char_t* y, size_t n); Modified: trunk/pmplib/lib/ucs2/ucs2char.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char.c 2007-01-28 22:46:02 UTC (rev 294) +++ trunk/pmplib/lib/ucs2/ucs2char.c 2007-01-29 14:07:30 UTC (rev 295) @@ -103,6 +103,63 @@ return dst; } +size_t ucs2cspn(const ucs2char_t *str, const ucs2char_t *charset) +{ + const ucs2char_t *p, *q; + + for (p = str;*p;++p) { + for (q = charset;*q;++q) { + if (*p == *q) { + return (p - str); + } + } + } + return (p - str); +} + +size_t ucs2spn(const ucs2char_t *str, const ucs2char_t *charset) +{ + const ucs2char_t *p, *q; + + for (p = str;*p;++p) { + for (q = charset;*q;++q) { + if (*p != *q) { + return (p - str); + } + } + } + return (p - str); +} + +ucs2char_t* ucs2pbrk(const ucs2char_t *str, const ucs2char_t *search) +{ + const ucs2char_t *p, *q; + + for (p = str;*p;++p) { + for (q = search;*q;++q) { + if (*p == *q) { + return (ucs2char_t*)p; + } + } + } + return NULL; +} + +ucs2char_t* ucs2ncat(ucs2char_t *dst, const ucs2char_t *src, size_t count) +{ + size_t i; + ucs2char_t *p = dst + ucs2len(dst); + for (i = 0;i < count;i++) { + *p = *src; + if (!*src) { + break; + } + p++; + src++; + } + return dst; +} + ucs2char_t* ucs2ncpy(ucs2char_t* dst, const ucs2char_t* src, size_t count) { size_t i; @@ -118,6 +175,7 @@ return dst; } + ucs2char_t* ucs2chr(const ucs2char_t* string, ucs2char_t c) { ucs2char_t* ret = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |