| return 1; | return 1; | ||||
| } | } | ||||
| static const char *FindReplacementChars(Translator *tr, const char **pfrom, unsigned int c, unsigned int nextc, int *ignore_next_n) | |||||
| static const char *FindReplacementChars(Translator *tr, const char **pfrom, unsigned int c, const char *next, int *ignore_next_n) | |||||
| { | { | ||||
| const char *from = *pfrom; | const char *from = *pfrom; | ||||
| while (*(unsigned int *)from != 0) { | while (*(unsigned int *)from != 0) { | ||||
| unsigned int fc = 0; // from character | unsigned int fc = 0; // from character | ||||
| unsigned int nc = c; // next character | unsigned int nc = c; // next character | ||||
| const char *match_next = next; | |||||
| *pfrom = from; | *pfrom = from; | ||||
| if (*from == 0) return from + 1; | if (*from == 0) return from + 1; | ||||
| from += utf8_in((int *)&fc, from); | from += utf8_in((int *)&fc, from); | ||||
| nc = nextc; | |||||
| match_next += utf8_in((int *)&nc, match_next); | |||||
| nc = towlower2(nextc, tr); | |||||
| nc = towlower2(nc, tr); | |||||
| if (*from == 0 && nc == fc) { | if (*from == 0 && nc == fc) { | ||||
| *ignore_next_n = 1; | *ignore_next_n = 1; | ||||
| return from + 1; | return from + 1; | ||||
| } | } | ||||
| // handle .replace rule in xx_rules file | // handle .replace rule in xx_rules file | ||||
| static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in, int *insert, int *wordflags) | |||||
| static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in, const char *next, int *insert, int *wordflags) | |||||
| { | { | ||||
| unsigned int new_c, c2 = ' ', c_lower; | unsigned int new_c, c2 = ' ', c_lower; | ||||
| int upper_case = 0; | int upper_case = 0; | ||||
| upper_case = 1; | upper_case = 1; | ||||
| } | } | ||||
| const char *to = FindReplacementChars(tr, &from, c_lower, next_in, &ignore_next_n); | |||||
| const char *to = FindReplacementChars(tr, &from, c_lower, next, &ignore_next_n); | |||||
| if (to == NULL) | if (to == NULL) | ||||
| return c; // no substitution | return c; // no substitution | ||||
| break; | break; | ||||
| } | } | ||||
| // handle .replace rule in xx_rules file | // handle .replace rule in xx_rules file | ||||
| return SubstituteChar(tr, c, next_in, insert, wordflags); | |||||
| return SubstituteChar(tr, c, next_in, ptr, insert, wordflags); | |||||
| } | } | ||||
| static const char *UCase_ga[] = { "bp", "bhf", "dt", "gc", "hA", "mb", "nd", "ng", "ts", "tA", "nA", NULL }; | static const char *UCase_ga[] = { "bp", "bhf", "dt", "gc", "hA", "mb", "nd", "ng", "ts", "tA", "nA", NULL }; |