--- np2/common/milstr.c 2004/02/18 02:03:36 1.5 +++ np2/common/milstr.c 2004/06/19 17:54:19 1.7 @@ -5,6 +5,11 @@ // ---- ANK #if defined(SUPPORT_ANK) +int milank_charsize(const char *str) { + + return((str[0] != '\0')?1:0); +} + int milank_cmp(const char *str, const char *cmp) { int s; @@ -78,12 +83,36 @@ void milank_ncat(char *dst, const char * dst[i] = '\0'; } } + +char *milank_chr(const char *str, int c) { + + int s; + + if (str) { + do { + s = *str; + if (s == c) { + return((char *)str); + } + str++; + } while(s); + } + return(NULL); +} #endif // ---- Shift-JIS #if defined(SUPPORT_SJIS) +int milsjis_charsize(const char *str) { + + int pos; + + pos = ((((str[0] ^ 0x20) - 0xa1) & 0xff) < 0x3c)?1:0; + return((str[pos] != '\0')?(pos+1):0); +} + int milsjis_cmp(const char *str, const char *cmp) { int s; @@ -212,12 +241,40 @@ void milsjis_ncat(char *dst, const char dst[i] = '\0'; } } + +char *milsjis_chr(const char *str, int c) { + + int s; + + if (str) { + do { + s = *str; + if (s == c) { + return((char *)str); + } + if ((((s ^ 0x20) - 0xa1) & 0xff) < 0x3c) { + str++; + s = *str; + } + str++; + } while(s); + } + return(NULL); +} #endif // ---- EUC -#if defined(SUPPORT_EUC) +#if defined(SUPPORT_EUC) // あれ 半角カナ忘れてるぞ? +int mileuc_charsize(const char *str) { + + int pos; + + pos = (((str[0] - 0xa1) & 0xff) < 0x5d)?1:0; + return((str[pos] != '\0')?(pos+1):0); +} + int mileuc_cmp(const char *str, const char *cmp) { int s; @@ -346,6 +403,26 @@ void mileuc_ncat(char *dst, const char * dst[i] = '\0'; } } + +char *mileuc_chr(const char *str, int c) { + + int s; + + if (str) { + do { + s = *str; + if (s == c) { + return((char *)str); + } + if (((s - 0xa1) & 0xff) < 0x5d) { + str++; + s = *str; + } + str++; + } while(s); + } + return(NULL); +} #endif @@ -387,6 +464,16 @@ int milstr_extendcmp(const char *str, co return((s > c)?1:-1); } +char *milstr_nextword(const char *str) { + + if (str) { + while(!(((*str) - 1) & 0xe0)) { + str++; + } + } + return((char *)str); +} + int milstr_getarg(char *str, char *arg[], int maxarg) { int ret = 0; @@ -477,14 +564,15 @@ long milstr_solveINT(const char *str) { return(ret * s); } +char *milstr_list(const char *lststr, UINT pos) { -const char *milstr_list(const char *lststr, UINT pos) { - - while(pos) { - pos--; - while(*lststr++ != '\0') { + if (lststr) { + while(pos) { + pos--; + while(*lststr++ != '\0') { + } } } - return(lststr); + return((char *)lststr); }