| version 1.1, 2003/10/16 17:57:09 | version 1.5, 2004/02/18 02:03:36 | 
| Line 1 | Line 1 | 
 | #include        "compiler.h" | #include        "compiler.h" | 
 |  |  | 
 |  |  | 
| BOOL milstr_cmp(const char *str, const char *cmp) { |  | 
|  | // ---- ANK | 
|  |  | 
|  | #if defined(SUPPORT_ANK) | 
|  | int milank_cmp(const char *str, const char *cmp) { | 
 |  |  | 
 | int             s; | int             s; | 
 | int             c; | int             c; | 
 |  |  | 
| while(1) { | do { | 
|  | s = (BYTE)*str++; | 
|  | if (((s - 'a') & 0xff) < 26) { | 
|  | s -= 0x20; | 
|  | } | 
|  | c = (BYTE)*cmp++; | 
|  | if (((c - 'a') & 0xff) < 26) { | 
|  | c -= 0x20; | 
|  | } | 
|  | if (s != c) { | 
|  | return((s > c)?1:-1); | 
|  | } | 
|  | } while(s); | 
|  | return(0); | 
|  | } | 
|  |  | 
|  | int milank_memcmp(const char *str, const char *cmp) { | 
|  |  | 
|  | int             s; | 
|  | int             c; | 
|  |  | 
|  | do { | 
|  | c = (BYTE)*cmp++; | 
|  | if (c == 0) { | 
|  | return(0); | 
|  | } | 
|  | if (((c - 'a') & 0xff) < 26) { | 
|  | c -= 0x20; | 
|  | } | 
|  | s = (BYTE)*str++; | 
|  | if (((s - 'a') & 0xff) < 26) { | 
|  | s -= 0x20; | 
|  | } | 
|  | } while(s == c); | 
|  | return((s > c)?1:-1); | 
|  | } | 
|  |  | 
|  | void milank_ncpy(char *dst, const char *src, int maxlen) { | 
|  |  | 
|  | int             i; | 
|  |  | 
|  | if (maxlen > 0) { | 
|  | maxlen--; | 
|  | for (i=0; i<maxlen && src[i]; i++) { | 
|  | dst[i] = src[i]; | 
|  | } | 
|  | dst[i] = '\0'; | 
|  | } | 
|  | } | 
|  |  | 
|  | void milank_ncat(char *dst, const char *src, int maxlen) { | 
|  |  | 
|  | int             i; | 
|  | int             j; | 
|  |  | 
|  | if (maxlen > 0) { | 
|  | maxlen--; | 
|  | for (i=0; i<maxlen; i++) { | 
|  | if (!dst[i]) { | 
|  | break; | 
|  | } | 
|  | } | 
|  | for (j=0; i<maxlen && src[j]; i++, j++) { | 
|  | dst[i] = src[j]; | 
|  | } | 
|  | dst[i] = '\0'; | 
|  | } | 
|  | } | 
|  | #endif | 
|  |  | 
|  |  | 
|  | // ---- Shift-JIS | 
|  |  | 
|  | #if defined(SUPPORT_SJIS) | 
|  | int milsjis_cmp(const char *str, const char *cmp) { | 
|  |  | 
|  | int             s; | 
|  | int             c; | 
|  |  | 
|  | do { | 
 | s = (BYTE)*str++; | s = (BYTE)*str++; | 
 | if ((((s ^ 0x20) - 0xa1) & 0xff) < 0x3c) { | if ((((s ^ 0x20) - 0xa1) & 0xff) < 0x3c) { | 
| if (s != (BYTE)*cmp++) { | c = (BYTE)*cmp++; | 
|  | if (s != c) { | 
 | goto mscp_err; | goto mscp_err; | 
 | } | } | 
 | s = (BYTE)*str++; | s = (BYTE)*str++; | 
 | c = (BYTE)*cmp++; | c = (BYTE)*cmp++; | 
 | } | } | 
 | else { | else { | 
| if (((s - 'A') & 0xff) < 0x1a) { | if (((s - 'a') & 0xff) < 26) { | 
| s |= 0x20; | s -= 0x20; | 
 | } | } | 
 | c = (BYTE)*cmp++; | c = (BYTE)*cmp++; | 
| if (((c - 'A') & 0xff) < 0x1a) { | if (((c - 'a') & 0xff) < 26) { | 
| c |= 0x20; | c -= 0x20; | 
 | } | } | 
 | } | } | 
 | if (s != c) { | if (s != c) { | 
 | goto mscp_err; | goto mscp_err; | 
 | } | } | 
| if (!s) { | } while(s); | 
| break; |  | 
| } |  | 
| } |  | 
 | return(0); | return(0); | 
 |  |  | 
 | mscp_err: | mscp_err: | 
| return(1); | return((s > c)?1:-1); | 
 | } | } | 
 |  |  | 
| BOOL milstr_memcmp(const char *str, const char *cmp) { | int milsjis_memcmp(const char *str, const char *cmp) { | 
 |  |  | 
 | int             s; | int             s; | 
 | int             c; | int             c; | 
| Line 45  BOOL milstr_memcmp(const char *str, cons | Line 126  BOOL milstr_memcmp(const char *str, cons | 
 | do { | do { | 
 | c = (BYTE)*cmp++; | c = (BYTE)*cmp++; | 
 | if ((((c ^ 0x20) - 0xa1) & 0xff) < 0x3c) { | if ((((c ^ 0x20) - 0xa1) & 0xff) < 0x3c) { | 
| if (c != (BYTE)*str++) { | s = (BYTE)*str++; | 
|  | if (c != s) { | 
 | break; | break; | 
 | } | } | 
 | c = (BYTE)*cmp++; | c = (BYTE)*cmp++; | 
 | s = (BYTE)*str++; | s = (BYTE)*str++; | 
 | } | } | 
 | else if (c) { | else if (c) { | 
| if (((c - 'A') & 0xff) < 26) { | if (((c - 'a') & 0xff) < 26) { | 
| c |= 0x20; | c &= ~0x20; | 
 | } | } | 
 | s = (BYTE)*str++; | s = (BYTE)*str++; | 
| if (((s - 'A') & 0xff) < 26) { | if (((s - 'a') & 0xff) < 26) { | 
| s |= 0x20; | s &= ~0x20; | 
 | } | } | 
 | } | } | 
 | else { | else { | 
 | return(0); | return(0); | 
 | } | } | 
 | } while(s == c); | } while(s == c); | 
| return(1); | return((s > c)?1:-1); | 
 | } | } | 
 |  |  | 
| BOOL milstr_extendcmp(const char *str, const char *cmp) { | int milsjis_kanji1st(const char *str, int pos) { | 
 |  |  | 
| char    c, s = '\0'; | int             ret; | 
 |  |  | 
| while(*cmp) { | ret = 0; | 
| while(*cmp) { | while((pos >= 0) && | 
| s = *cmp++; | ((((str[pos--] ^ 0x20) - 0xa1) & 0xff) < 0x3c)) { | 
| if (!s) { | ret ^= 1; | 
| return(0); | } | 
|  | return(ret); | 
|  | } | 
|  |  | 
|  | int milsjis_kanji2nd(const char *str, int pos) { | 
|  |  | 
|  | int             ret = 0; | 
|  |  | 
|  | while((pos > 0) && ((((str[--pos] ^ 0x20) - 0xa1) & 0xff) < 0x3c)) { | 
|  | ret ^= 1; | 
|  | } | 
|  | return(ret); | 
|  | } | 
|  |  | 
|  | void milsjis_ncpy(char *dst, const char *src, int maxlen) { | 
|  |  | 
|  | int             i; | 
|  |  | 
|  | if (maxlen > 0) { | 
|  | maxlen--; | 
|  | for (i=0; i<maxlen && src[i]; i++) { | 
|  | dst[i] = src[i]; | 
|  | } | 
|  | if (i) { | 
|  | if (milsjis_kanji1st(src, i-1)) { | 
|  | i--; | 
 | } | } | 
| if ((s >= '0') && (s <= '9')) { | } | 
|  | dst[i] = '\0'; | 
|  | } | 
|  | } | 
|  |  | 
|  | void milsjis_ncat(char *dst, const char *src, int maxlen) { | 
|  |  | 
|  | int             i; | 
|  | int             j; | 
|  |  | 
|  | if (maxlen > 0) { | 
|  | maxlen--; | 
|  | for (i=0; i<maxlen; i++) { | 
|  | if (!dst[i]) { | 
 | break; | break; | 
 | } | } | 
| s &= 0xdf; | } | 
| if ((s >= 'A') && (s <= 'Z')) { | for (j=0; i<maxlen && src[j]; i++, j++) { | 
| break; | dst[i] = src[j]; | 
|  | } | 
|  | if ((i > 0) && (j > 0)) { | 
|  | if (milsjis_kanji1st(dst, i-1)) { | 
|  | i--; | 
 | } | } | 
 | } | } | 
| while(1) { | dst[i] = '\0'; | 
| c = *str++; | } | 
| if (!c) { | } | 
| return(1); | #endif | 
|  |  | 
|  |  | 
|  | // ---- EUC | 
|  |  | 
|  | #if defined(SUPPORT_EUC) | 
|  | int mileuc_cmp(const char *str, const char *cmp) { | 
|  |  | 
|  | int             s; | 
|  | int             c; | 
|  |  | 
|  | do { | 
|  | s = (BYTE)*str++; | 
|  | if (((s - 0xa1) & 0xff) < 0x5d) { | 
|  | c = (BYTE)*cmp++; | 
|  | if (s != c) { | 
|  | goto mscp_err; | 
 | } | } | 
| if ((c >= '0') && (c <= '9')) { | s = (BYTE)*str++; | 
| break; | c = (BYTE)*cmp++; | 
|  | } | 
|  | else { | 
|  | if (((s - 'a') & 0xff) < 26) { | 
|  | s -= 0x20; | 
 | } | } | 
| c &= 0xdf; | c = (BYTE)*cmp++; | 
| if ((c >= 'A') && (c <= 'Z')) { | if (((c - 'a') & 0xff) < 26) { | 
| break; | c -= 0x20; | 
 | } | } | 
 | } | } | 
| if (c != s) { | if (s != c) { | 
| return(1); | goto mscp_err; | 
 | } | } | 
| } | } while(s); | 
 | return(0); | return(0); | 
 |  |  | 
 |  | mscp_err: | 
 |  | return((s > c)?1:-1); | 
 |  | } | 
 |  |  | 
 |  | int mileuc_memcmp(const char *str, const char *cmp) { | 
 |  |  | 
 |  | int             s; | 
 |  | int             c; | 
 |  |  | 
 |  | do { | 
 |  | c = (BYTE)*cmp++; | 
 |  | if (((c - 0xa1) & 0xff) < 0x5d) { | 
 |  | s = (BYTE)*str++; | 
 |  | if (c != s) { | 
 |  | break; | 
 |  | } | 
 |  | c = (BYTE)*cmp++; | 
 |  | s = (BYTE)*str++; | 
 |  | } | 
 |  | else if (c) { | 
 |  | if (((c - 'a') & 0xff) < 26) { | 
 |  | c -= 0x20; | 
 |  | } | 
 |  | s = (BYTE)*str++; | 
 |  | if (((s - 'a') & 0xff) < 26) { | 
 |  | s -= 0x20; | 
 |  | } | 
 |  | } | 
 |  | else { | 
 |  | return(0); | 
 |  | } | 
 |  | } while(s == c); | 
 |  | return((s > c)?1:-1); | 
 | } | } | 
 |  |  | 
| int milstr_kanji1st(const char *str, int pos) { | int mileuc_kanji1st(const char *str, int pos) { | 
 |  |  | 
 | int             ret; | int             ret; | 
 |  |  | 
 | ret = 0; | ret = 0; | 
 | while((pos >= 0) && | while((pos >= 0) && | 
| ((((str[pos--] ^ 0x20) - 0xa1) & 0xff) < 0x3c)) { | (((str[pos--] - 0xa1) & 0xff) < 0x5d)) { | 
 | ret ^= 1; | ret ^= 1; | 
 | } | } | 
 | return(ret); | return(ret); | 
 | } | } | 
 |  |  | 
| int milstr_kanji2nd(const char *str, int pos) { | int mileuc_kanji2nd(const char *str, int pos) { | 
 |  |  | 
 | int             ret = 0; | int             ret = 0; | 
 |  |  | 
| while((pos) && ((((str[--pos] ^ 0x20) - 0xa1) & 0xff) < 0x3c)) { | while((pos > 0) && (((str[--pos] - 0xa1) & 0xff) < 0x5d)) { | 
 | ret ^= 1; | ret ^= 1; | 
 | } | } | 
 | return(ret); | return(ret); | 
 | } | } | 
 |  |  | 
| void milstr_ncpy(char *dst, const char *src, int maxlen) { | void mileuc_ncpy(char *dst, const char *src, int maxlen) { | 
 |  |  | 
 | int             i; | int             i; | 
 |  |  | 
| if (maxlen--) { | if (maxlen > 0) { | 
|  | maxlen--; | 
 | for (i=0; i<maxlen && src[i]; i++) { | for (i=0; i<maxlen && src[i]; i++) { | 
 | dst[i] = src[i]; | dst[i] = src[i]; | 
 | } | } | 
 | if (i) { | if (i) { | 
| if (milstr_kanji1st(src, i-1)) { | if (mileuc_kanji1st(src, i-1)) { | 
 | i--; | i--; | 
 | } | } | 
 | } | } | 
| Line 144  void milstr_ncpy(char *dst, const char * | Line 323  void milstr_ncpy(char *dst, const char * | 
 | } | } | 
 | } | } | 
 |  |  | 
| void milstr_ncat(char *dst, const char *src, int maxlen) { | void mileuc_ncat(char *dst, const char *src, int maxlen) { | 
 |  |  | 
 | int             i; | int             i; | 
 | int             j; | int             j; | 
 |  |  | 
| if (maxlen--) { | if (maxlen > 0) { | 
|  | maxlen--; | 
 | for (i=0; i<maxlen; i++) { | for (i=0; i<maxlen; i++) { | 
| if (!dst[i]) break; | if (!dst[i]) { | 
|  | break; | 
|  | } | 
 | } | } | 
 | for (j=0; i<maxlen && src[j]; i++, j++) { | for (j=0; i<maxlen && src[j]; i++, j++) { | 
 | dst[i] = src[j]; | dst[i] = src[j]; | 
 | } | } | 
| if ((i) && (j)) { | if ((i > 0) && (j > 0)) { | 
| if (milstr_kanji1st(dst, i-1)) { | if (mileuc_kanji1st(dst, i-1)) { | 
 | i--; | i--; | 
 | } | } | 
 | } | } | 
 | dst[i] = '\0'; | dst[i] = '\0'; | 
 | } | } | 
 | } | } | 
 |  | #endif | 
 |  |  | 
 |  |  | 
 |  | // ---- other | 
 |  |  | 
 |  | int milstr_extendcmp(const char *str, const char *cmp) { | 
 |  |  | 
 |  | int             c; | 
 |  | int             s; | 
 |  |  | 
 |  | do { | 
 |  | while(1) { | 
 |  | c = (BYTE)*cmp++; | 
 |  | if (!c) { | 
 |  | return(0); | 
 |  | } | 
 |  | if (((c - '0') & 0xff) < 10) { | 
 |  | break; | 
 |  | } | 
 |  | c |= 0x20; | 
 |  | if (((c - 'a') & 0xff) < 26) { | 
 |  | break; | 
 |  | } | 
 |  | } | 
 |  | while(1) { | 
 |  | s = *str++; | 
 |  | if (!s) { | 
 |  | break; | 
 |  | } | 
 |  | if (((s - '0') & 0xff) < 10) { | 
 |  | break; | 
 |  | } | 
 |  | s |= 0x20; | 
 |  | if (((s - 'a') & 0xff) < 26) { | 
 |  | break; | 
 |  | } | 
 |  | } | 
 |  | } while(s == c); | 
 |  | return((s > c)?1:-1); | 
 |  | } | 
 |  |  | 
 | int milstr_getarg(char *str, char *arg[], int maxarg) { | int milstr_getarg(char *str, char *arg[], int maxarg) { | 
 |  |  | 
| Line 255  long milstr_solveINT(const char *str) { | Line 477  long milstr_solveINT(const char *str) { | 
 | return(ret * s); | return(ret * s); | 
 | } | } | 
 |  |  | 
 |  |  | 
 |  | const char *milstr_list(const char *lststr, UINT pos) { | 
 |  |  | 
 |  | while(pos) { | 
 |  | pos--; | 
 |  | while(*lststr++ != '\0') { | 
 |  | } | 
 |  | } | 
 |  | return(lststr); | 
 |  | } | 
 |  |  |