|
|
| version 1.8, 2004/06/20 01:03:04 | version 1.11, 2004/06/23 16:06:12 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| // ---- ANK / UCS2 / UCS4 | |
| // ---- ANK | |
| #if defined(SUPPORT_ANK) | #if defined(SUPPORT_ANK) |
| int milank_charsize(const char *str) { | int milank_charsize(const OEMCHAR *str) { |
| return((str[0] != '\0')?1:0); | return((str[0] != '\0')?1:0); |
| } | } |
| int milank_cmp(const char *str, const char *cmp) { | int milank_cmp(const OEMCHAR *str, const OEMCHAR *cmp) { |
| int s; | int s; |
| int c; | int c; |
| do { | do { |
| s = (BYTE)*str++; | s = *str++; |
| if (((s - 'a') & 0xff) < 26) { | if ((s >= 'a') && (s <= 'z')) { |
| s -= 0x20; | s -= 0x20; |
| } | } |
| c = (BYTE)*cmp++; | c = *cmp++; |
| if (((c - 'a') & 0xff) < 26) { | if ((c >= 'a') && (c <= 'z')) { |
| c -= 0x20; | c -= 0x20; |
| } | } |
| if (s != c) { | if (s != c) { |
| Line 31 int milank_cmp(const char *str, const ch | Line 30 int milank_cmp(const char *str, const ch |
| return(0); | return(0); |
| } | } |
| int milank_memcmp(const char *str, const char *cmp) { | int milank_memcmp(const OEMCHAR *str, const OEMCHAR *cmp) { |
| int s; | int s; |
| int c; | int c; |
| do { | do { |
| c = (BYTE)*cmp++; | c = *cmp++; |
| if (c == 0) { | if (c == 0) { |
| return(0); | return(0); |
| } | } |
| if (((c - 'a') & 0xff) < 26) { | if ((c >= 'a') && (c <= 'z')) { |
| c -= 0x20; | c -= 0x20; |
| } | } |
| s = (BYTE)*str++; | s = *str++; |
| if (((s - 'a') & 0xff) < 26) { | if ((s >= 'a') && (s <= 'z')) { |
| s -= 0x20; | s -= 0x20; |
| } | } |
| } while(s == c); | } while(s == c); |
| return((s > c)?1:-1); | return((s > c)?1:-1); |
| } | } |
| void milank_ncpy(char *dst, const char *src, int maxlen) { | void milank_ncpy(OEMCHAR *dst, const OEMCHAR *src, int maxlen) { |
| int i; | int i; |
| Line 65 void milank_ncpy(char *dst, const char * | Line 64 void milank_ncpy(char *dst, const char * |
| } | } |
| } | } |
| void milank_ncat(char *dst, const char *src, int maxlen) { | void milank_ncat(OEMCHAR *dst, const OEMCHAR *src, int maxlen) { |
| int i; | int i; |
| int j; | int j; |
| Line 84 void milank_ncat(char *dst, const char * | Line 83 void milank_ncat(char *dst, const char * |
| } | } |
| } | } |
| char *milank_chr(const char *str, int c) { | OEMCHAR *milank_chr(const OEMCHAR *str, int c) { |
| int s; | int s; |
| Line 92 char *milank_chr(const char *str, int c) | Line 91 char *milank_chr(const char *str, int c) |
| do { | do { |
| s = *str; | s = *str; |
| if (s == c) { | if (s == c) { |
| return((char *)str); | return((OEMCHAR *)str); |
| } | } |
| str++; | str++; |
| } while(s); | } while(s); |
| Line 119 int milsjis_cmp(const char *str, const c | Line 118 int milsjis_cmp(const char *str, const c |
| int c; | int c; |
| do { | do { |
| s = (BYTE)*str++; | s = (UINT8)*str++; |
| if ((((s ^ 0x20) - 0xa1) & 0xff) < 0x3c) { | if ((((s ^ 0x20) - 0xa1) & 0xff) < 0x3c) { |
| c = (BYTE)*cmp++; | c = (UINT8)*cmp++; |
| if (s != c) { | if (s != c) { |
| goto mscp_err; | goto mscp_err; |
| } | } |
| s = (BYTE)*str++; | s = (UINT8)*str++; |
| c = (BYTE)*cmp++; | c = (UINT8)*cmp++; |
| } | } |
| else { | else { |
| if (((s - 'a') & 0xff) < 26) { | if (((s - 'a') & 0xff) < 26) { |
| s -= 0x20; | s -= 0x20; |
| } | } |
| c = (BYTE)*cmp++; | c = (UINT8)*cmp++; |
| if (((c - 'a') & 0xff) < 26) { | if (((c - 'a') & 0xff) < 26) { |
| c -= 0x20; | c -= 0x20; |
| } | } |
| Line 153 int milsjis_memcmp(const char *str, cons | Line 152 int milsjis_memcmp(const char *str, cons |
| int c; | int c; |
| do { | do { |
| c = (BYTE)*cmp++; | c = (UINT8)*cmp++; |
| if ((((c ^ 0x20) - 0xa1) & 0xff) < 0x3c) { | if ((((c ^ 0x20) - 0xa1) & 0xff) < 0x3c) { |
| s = (BYTE)*str++; | s = (UINT8)*str++; |
| if (c != s) { | if (c != s) { |
| break; | break; |
| } | } |
| c = (BYTE)*cmp++; | c = (UINT8)*cmp++; |
| s = (BYTE)*str++; | s = (UINT8)*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 = (UINT8)*str++; |
| if (((s - 'a') & 0xff) < 26) { | if (((s - 'a') & 0xff) < 26) { |
| s &= ~0x20; | s &= ~0x20; |
| } | } |
| Line 192 int milsjis_kanji1st(const char *str, in | Line 191 int milsjis_kanji1st(const char *str, in |
| int milsjis_kanji2nd(const char *str, int pos) { | int milsjis_kanji2nd(const char *str, int pos) { |
| int ret = 0; | int ret; |
| ret = 0; | |
| while((pos > 0) && ((((str[--pos] ^ 0x20) - 0xa1) & 0xff) < 0x3c)) { | while((pos > 0) && ((((str[--pos] ^ 0x20) - 0xa1) & 0xff) < 0x3c)) { |
| ret ^= 1; | ret ^= 1; |
| } | } |
| Line 271 int mileuc_charsize(const char *str) { | Line 271 int mileuc_charsize(const char *str) { |
| int pos; | int pos; |
| pos = (((str[0] - 0xa1) & 0xff) < 0x5d)?1:0; | pos = (str[0] & 0x80)?1:0; |
| return((str[pos] != '\0')?(pos+1):0); | return((str[pos] != '\0')?(pos+1):0); |
| } | } |
| Line 281 int mileuc_cmp(const char *str, const ch | Line 281 int mileuc_cmp(const char *str, const ch |
| int c; | int c; |
| do { | do { |
| s = (BYTE)*str++; | s = (UINT8)*str++; |
| if (((s - 0xa1) & 0xff) < 0x5d) { | if (s & 0x80) { |
| c = (BYTE)*cmp++; | c = (UINT8)*cmp++; |
| if (s != c) { | if (s != c) { |
| goto mscp_err; | goto mscp_err; |
| } | } |
| s = (BYTE)*str++; | s = (UINT8)*str++; |
| c = (BYTE)*cmp++; | c = (UINT8)*cmp++; |
| } | } |
| else { | else { |
| if (((s - 'a') & 0xff) < 26) { | if (((s - 'a') & 0xff) < 26) { |
| s -= 0x20; | s -= 0x20; |
| } | } |
| c = (BYTE)*cmp++; | c = (UINT8)*cmp++; |
| if (((c - 'a') & 0xff) < 26) { | if (((c - 'a') & 0xff) < 26) { |
| c -= 0x20; | c -= 0x20; |
| } | } |
| Line 315 int mileuc_memcmp(const char *str, const | Line 315 int mileuc_memcmp(const char *str, const |
| int c; | int c; |
| do { | do { |
| c = (BYTE)*cmp++; | c = (UINT8)*cmp++; |
| if (((c - 0xa1) & 0xff) < 0x5d) { | if (c & 0x80) { |
| s = (BYTE)*str++; | s = (UINT8)*str++; |
| if (c != s) { | if (c != s) { |
| break; | break; |
| } | } |
| c = (BYTE)*cmp++; | c = (UINT8)*cmp++; |
| s = (BYTE)*str++; | s = (UINT8)*str++; |
| } | } |
| else if (c) { | else if (c) { |
| if (((c - 'a') & 0xff) < 26) { | if (((c - 'a') & 0xff) < 26) { |
| Line 345 int mileuc_kanji1st(const char *str, int | Line 345 int mileuc_kanji1st(const char *str, int |
| int ret; | int ret; |
| ret = 0; | ret = 0; |
| while((pos >= 0) && | while((pos >= 0) && (str[pos--] & 0x80)) { |
| (((str[pos--] - 0xa1) & 0xff) < 0x5d)) { | |
| ret ^= 1; | ret ^= 1; |
| } | } |
| return(ret); | return(ret); |
| Line 354 int mileuc_kanji1st(const char *str, int | Line 353 int mileuc_kanji1st(const char *str, int |
| int mileuc_kanji2nd(const char *str, int pos) { | int mileuc_kanji2nd(const char *str, int pos) { |
| int ret = 0; | int ret; |
| while((pos > 0) && (((str[--pos] - 0xa1) & 0xff) < 0x5d)) { | ret = 0; |
| while((pos > 0) && (str[--pos] & 0x80)) { | |
| ret ^= 1; | ret ^= 1; |
| } | } |
| return(ret); | return(ret); |
| Line 414 char *mileuc_chr(const char *str, int c) | Line 414 char *mileuc_chr(const char *str, int c) |
| if (s == c) { | if (s == c) { |
| return((char *)str); | return((char *)str); |
| } | } |
| if (((s - 0xa1) & 0xff) < 0x5d) { | if (s & 0x80) { |
| str++; | str++; |
| s = *str; | s = *str; |
| } | } |
| Line 437 int milutf8_charsize(const char *str) { | Line 437 int milutf8_charsize(const char *str) { |
| else if (!(str[0] & 0x80)) { | else if (!(str[0] & 0x80)) { |
| return(1); | return(1); |
| } | } |
| else if ((src[0] & 0xe0) == 0xc0) { | else if ((str[0] & 0xe0) == 0xc0) { |
| if ((src[1] & 0xc0) == 0x80) { | if ((str[1] & 0xc0) == 0x80) { |
| return(2); | return(2); |
| } | } |
| } | } |
| else if ((src[0] & 0xf0) == 0xe0) { | else if ((str[0] & 0xf0) == 0xe0) { |
| if (((src[1] & 0xc0) == 0x80) || | if (((str[1] & 0xc0) == 0x80) || |
| ((src[2] & 0xc0) == 0x80)) { | ((str[2] & 0xc0) == 0x80)) { |
| return(3); | return(3); |
| } | } |
| } | } |
| Line 512 void milutf8_ncpy(char *dst, const char | Line 512 void milutf8_ncpy(char *dst, const char |
| for (i=0; i<maxlen && src[i]; i++) { | for (i=0; i<maxlen && src[i]; i++) { |
| dst[i] = src[i]; | dst[i] = src[i]; |
| } | } |
| while((i) && ((dst[i] & 0xc0) == 0x80)) { | while((i) && ((dst[i-1] & 0xc0) == 0x80)) { |
| i--; | i--; |
| } | } |
| dst[i] = '\0'; | dst[i] = '\0'; |
| Line 534 void milutf8_ncat(char *dst, const char | Line 534 void milutf8_ncat(char *dst, const char |
| 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]; |
| } | } |
| while((i) && ((dst[i] & 0xc0) == 0x80)) { | while((i) && ((dst[i-1] & 0xc0) == 0x80)) { |
| i--; | i--; |
| } | } |
| dst[i] = '\0'; | dst[i] = '\0'; |
| Line 597 int milstr_extendcmp(const char *str, co | Line 597 int milstr_extendcmp(const char *str, co |
| return((s > c)?1:-1); | return((s > c)?1:-1); |
| } | } |
| char *milstr_nextword(const char *str) { | OEMCHAR *milstr_nextword(const OEMCHAR *str) { |
| if (str) { | if (str) { |
| while(!(((*str) - 1) & 0xe0)) { | while((*str > '\0') && (*str <= ' ')) { |
| str++; | str++; |
| } | } |
| } | } |
| return((char *)str); | return((OEMCHAR *)str); |
| } | } |
| int milstr_getarg(char *str, char *arg[], int maxarg) { | int milstr_getarg(OEMCHAR *str, OEMCHAR *arg[], int maxarg) { |
| int ret = 0; | int ret = 0; |
| char *p; | OEMCHAR *p; |
| BOOL quot; | BOOL quot; |
| while(maxarg--) { | while(maxarg--) { |
| quot = FALSE; | quot = FALSE; |
| while((*str) && (((BYTE)*str) <= 0x20)) { | while((*str > '\0') && (*str <= ' ')) { |
| str++; | str++; |
| } | } |
| if (*str == '\0') { | if (*str == '\0') { |
| Line 624 int milstr_getarg(char *str, char *arg[] | Line 624 int milstr_getarg(char *str, char *arg[] |
| arg[ret++] = str; | arg[ret++] = str; |
| p = str; | p = str; |
| while(*str) { | while(*str) { |
| if (*str == 0x22) { | if (*str == '\"') { |
| quot = !quot; | quot = !quot; |
| } | } |
| else if ((((BYTE)*str) > 0x20) || (quot)) { | else if ((quot) || (*str < '\0') || (*str > ' ')) { |
| *p++ = *str; | *p++ = *str; |
| } | } |
| else { | else { |
| Line 641 int milstr_getarg(char *str, char *arg[] | Line 641 int milstr_getarg(char *str, char *arg[] |
| return(ret); | return(ret); |
| } | } |
| long milstr_solveHEX(const char *str) { | long milstr_solveHEX(const OEMCHAR *str) { |
| long ret; | long ret; |
| int i; | int i; |
| Line 668 long milstr_solveHEX(const char *str) { | Line 668 long milstr_solveHEX(const char *str) { |
| return(ret); | return(ret); |
| } | } |
| long milstr_solveINT(const char *str) { | long milstr_solveINT(const OEMCHAR *str) { |
| long ret; | long ret; |
| int c; | int c; |
| Line 697 long milstr_solveINT(const char *str) { | Line 697 long milstr_solveINT(const char *str) { |
| return(ret * s); | return(ret * s); |
| } | } |
| char *milstr_list(const char *lststr, UINT pos) { | OEMCHAR *milstr_list(const OEMCHAR *lststr, UINT pos) { |
| if (lststr) { | if (lststr) { |
| while(pos) { | while(pos) { |
| Line 706 char *milstr_list(const char *lststr, UI | Line 706 char *milstr_list(const char *lststr, UI |
| } | } |
| } | } |
| } | } |
| return((char *)lststr); | return((OEMCHAR *)lststr); |
| } | } |