From: <ny...@us...> - 2007-01-30 15:43:37
|
Revision: 296 http://svn.sourceforge.net/pmplib/?rev=296&view=rev Author: nyaochi Date: 2007-01-30 07:43:25 -0800 (Tue, 30 Jan 2007) Log Message: ----------- Removed unused functions in libucs2. Modified Paths: -------------- trunk/pmplib/include/ucs2char.h trunk/pmplib/lib/ucs2/ucs2char.c trunk/pmplib/lib/ucs2/ucs2char_iconv.c Modified: trunk/pmplib/include/ucs2char.h =================================================================== --- trunk/pmplib/include/ucs2char.h 2007-01-29 14:07:30 UTC (rev 295) +++ trunk/pmplib/include/ucs2char.h 2007-01-30 15:43:25 UTC (rev 296) @@ -38,12 +38,23 @@ #endif/*__cplusplus*/ /** - * \addtogroup ucs2 + * \addtogroup ucs2 PMPlib UCS-2 API. * @{ */ +/** + * Type definition of a UCS-2 character. + */ typedef uint16_t ucs2char_t; + + + +/** + * @defgroup ucs2_conv Charaset conversion routines. + * @{ + */ + struct tag_ucs2conv { const char *from; const char *to; @@ -51,24 +62,53 @@ typedef struct tag_ucs2conv ucs2conv_t; UCS2API int ucs2init(const char *encoding); -UCS2API int ucs2check(ucs2conv_t* conv); UCS2API int ucs2set_encoding(const char *encoding, ucs2conv_t* conv); UCS2API int ucs2set_encoding_music(const char *encoding, ucs2conv_t* conv); UCS2API void ucs2set_codepage(int cp); +UCS2API size_t ucs2tombs(char *mbstr, size_t mbs_size, const ucs2char_t *ucs2str, size_t ucs_size); +UCS2API size_t mbstoucs2(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); +UCS2API size_t mbstoucs2_music(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); +UCS2API size_t utf8toucs2(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); + +UCS2API ucs2char_t* mbsdupucs2(const char *mbstr); +UCS2API ucs2char_t* utf8dupucs2(const char *utf8str); +UCS2API ucs2char_t* mbsdupucs2_music(const char *mbstr); +UCS2API char *ucs2dupmbs(const ucs2char_t *ucs2str); + +/** + * @} + */ + + + UCS2API void ucs2big2little(ucs2char_t* value); +/** + * @defgroup ucs2_memory Memory allocation routines. + * @{ + */ + UCS2API void *ucs2malloc(size_t size); UCS2API void *ucs2calloc(size_t size); UCS2API void *ucs2realloc(void *ptr, size_t size); UCS2API void ucs2free(void* str); +/** + * @} + */ + UCS2API int is_ucs2surrogate(ucs2char_t c); UCS2API int isucs2space(ucs2char_t c); UCS2API int isucs2digit(ucs2char_t c); +/** + * @defgroup ucs2_string_ansi ANSI C compatible string routines. + * @{ + */ + 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); @@ -84,46 +124,38 @@ UCS2API size_t ucs2spn(const ucs2char_t *str, const ucs2char_t *charset); UCS2API ucs2char_t* ucs2str(const ucs2char_t* str, const ucs2char_t* search); +/** + * @} + */ +/** + * @defgroup ucs2_string_ansi ANSI C compatible string routines. + * @{ + */ +UCS2API ucs2char_t* ucs2ndup(const ucs2char_t* src, size_t length); +UCS2API ucs2char_t* ucs2lwr(ucs2char_t* str); +UCS2API ucs2char_t* ucs2upr(ucs2char_t* str); +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); +/** + * @} + */ + 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* ucs2ndup(const ucs2char_t* src, size_t length); UCS2API ucs2char_t* ucs2strip(ucs2char_t* str); -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); -UCS2API int ucs2memcmp(const ucs2char_t* buf1, const ucs2char_t* buf2, size_t count); -UCS2API const ucs2char_t *ucs2memchr(const ucs2char_t* buf, ucs2char_t c, size_t count); -UCS2API ucs2char_t *ucs2memmove(ucs2char_t *dest, const ucs2char_t *src, size_t count); -UCS2API ucs2char_t *ucs2memcpy(ucs2char_t *dest, const ucs2char_t *src, size_t count); -UCS2API ucs2char_t *ucs2memset(ucs2char_t *dest, ucs2char_t c, size_t count); - -UCS2API ucs2char_t* ucs2righttoleft_encode(ucs2char_t* str); -UCS2API ucs2char_t* ucs2righttoleft_decode(ucs2char_t* str); - UCS2API int ucs2toi(const ucs2char_t* str); UCS2API ucs2char_t* itoucs2(int value, ucs2char_t *string, int radix); -UCS2API size_t ucs2tombs(char *mbstr, size_t mbs_size, const ucs2char_t *ucs2str, size_t ucs_size); -UCS2API size_t mbstoucs2(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); -UCS2API size_t mbstoucs2_music(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); -UCS2API size_t utf8toucs2(ucs2char_t *ucs2str, size_t ucs_size, const char *mbstr, size_t mbs_size); - -UCS2API ucs2char_t* mbsdupucs2(const char *mbstr); -UCS2API ucs2char_t* utf8dupucs2(const char *utf8str); -UCS2API ucs2char_t* mbsdupucs2_music(const char *mbstr); -UCS2API char *ucs2dupmbs(const ucs2char_t *ucs2str); - UCS2API time_t ucs2stat_mtime(const ucs2char_t *filename); UCS2API uint32_t ucs2stat_size(const ucs2char_t *filename); UCS2API int ucs2stat_is_dir(const ucs2char_t *filename); Modified: trunk/pmplib/lib/ucs2/ucs2char.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char.c 2007-01-29 14:07:30 UTC (rev 295) +++ trunk/pmplib/lib/ucs2/ucs2char.c 2007-01-30 15:43:25 UTC (rev 296) @@ -269,52 +269,6 @@ return COMP(ucs2upper(*x), ucs2upper(*y)); } -int ucs2memcmp(const ucs2char_t* buf1, const ucs2char_t* buf2, size_t count) -{ - size_t i; - for (i = 0;i < count-1;i++) { - if (!*buf1 || !*buf2 || *buf1 != *buf2) { - break; - } - buf1++; - buf2++; - } - return COMP(*buf1, *buf2); -} - -const ucs2char_t *ucs2memchr(const ucs2char_t* buf, ucs2char_t c, size_t count) -{ - size_t i; - for (i = 0;i < count;++i) { - if (*buf == c) { - return buf; - } - buf++; - } - return NULL; -} - -ucs2char_t *ucs2memmove(ucs2char_t *dest, const ucs2char_t *src, size_t count) -{ - memmove(dest, src, sizeof(ucs2char_t) * count); - return dest; -} - -ucs2char_t *ucs2memcpy(ucs2char_t *dest, const ucs2char_t *src, size_t count) -{ - memcpy(dest, src, sizeof(ucs2char_t) * count); - return dest; -} - -ucs2char_t *ucs2memset(ucs2char_t *dest, ucs2char_t c, size_t count) -{ - size_t i; - for (i = 0;i < count;++i) { - *dest++ = c; - } - return dest; -} - ucs2char_t* ucs2dup(const ucs2char_t* src) { ucs2char_t* dst = (ucs2char_t*)malloc((ucs2len(src)+1) * sizeof(ucs2char_t)); @@ -456,47 +410,3 @@ } return dst; } - - -#define TEST_RIGHTTOLEFT - -#ifndef TEST_RIGHTTOLEFT - -ucs2char_t* ucs2righttoleft_encode(ucs2char_t* str) -{ - /* Requiement: we must not increase the length of a string. */ - /* To be implemented. */ - return str; -} - -ucs2char_t* ucs2righttoleft_decode(ucs2char_t* str) -{ - /* Requiement: we must not increase the length of a string. */ - /* To be implemented. */ - return str; -} - -#else - -ucs2char_t* ucs2righttoleft_encode(ucs2char_t* str) -{ - if (str) { - ucs2char_t* p = str; - ucs2char_t* q = str + ucs2len(str) - 1; - for (;p < q;p++, q--) { - ucs2char_t tmp = *p; - *p = *q; - *q = tmp; - } - } - return str; -} - -ucs2char_t* ucs2righttoleft_decode(ucs2char_t* str) -{ - return ucs2righttoleft_encode(str); -} - -/** @} */ - -#endif Modified: trunk/pmplib/lib/ucs2/ucs2char_iconv.c =================================================================== --- trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-01-29 14:07:30 UTC (rev 295) +++ trunk/pmplib/lib/ucs2/ucs2char_iconv.c 2007-01-30 15:43:25 UTC (rev 296) @@ -92,23 +92,8 @@ strcpy(g_encoding_music, encoding); } -int ucs2set_encoding(const char *encoding, ucs2conv_t* conv) +static int ucs2check(ucs2conv_t* conv) { - strncpy(g_encoding, encoding, sizeof(g_encoding)); - strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); - return ucs2check(conv); -} - -int ucs2set_encoding_music(const char *encoding, ucs2conv_t* conv) -{ - strncpy(g_encoding_music, encoding, sizeof(g_encoding_music)); - strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); - return ucs2check(conv); -} - - -int ucs2check(ucs2conv_t* conv) -{ int i = 0; iconv_t cd; const static char *charsets[] = { @@ -142,6 +127,21 @@ return 0; } +int ucs2set_encoding(const char *encoding, ucs2conv_t* conv) +{ + strncpy(g_encoding, encoding, sizeof(g_encoding)); + strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); + return ucs2check(conv); +} + +int ucs2set_encoding_music(const char *encoding, ucs2conv_t* conv) +{ + strncpy(g_encoding_music, encoding, sizeof(g_encoding_music)); + strncpy(g_ucs2encoding, get_ucs2encoding(), sizeof(g_ucs2encoding)); + return ucs2check(conv); +} + + void ucs2big2little(ucs2char_t* value) { if (is_bigendian()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |