| static int IsLetterGroup(Translator *tr, char *word, int group, int pre) | static int IsLetterGroup(Translator *tr, char *word, int group, int pre) | ||||
| { | { | ||||
| /* match the word against a list of utf-8 strings | |||||
| /* Match the word against a list of utf-8 strings. | |||||
| * | |||||
| * How this works: | * How this works: | ||||
| * | |||||
| * +-+ | * +-+ | ||||
| * |c|<-(tr->letterGroups[group]) | * |c|<-(tr->letterGroups[group]) | ||||
| * |0| | * |0| | ||||
| * |7| |s| | * |7| |s| | ||||
| * +-+ +-+ | * +-+ +-+ | ||||
| * | * | ||||
| * 7=RULE_GROUP_EN | |||||
| * 7=RULE_GROUP_END | |||||
| * 0=null terminator | * 0=null terminator | ||||
| * pre==1 — pre-rule | * pre==1 — pre-rule | ||||
| * pre==0 — post-rule | * pre==0 — post-rule | ||||
| // If no character is allowed in group | // If no character is allowed in group | ||||
| // at the start (for pre-rule) or end (post-rule) | // at the start (for pre-rule) or end (post-rule) | ||||
| // of the checked letter in the word, return OK | |||||
| // of the checked letter in the word, return true. | |||||
| if (*p == '~' && *w == ' ') // word end checked because of comment below | if (*p == '~' && *w == ' ') // word end checked because of comment below | ||||
| return 1; | return 1; | ||||
| /* TODO need to investigate why word end mark _ doesn't work properly | |||||
| * for post rule somewhere in MatchRule() function. or E.g.: | |||||
| /* TODO: Need to investigate why word end mark _ doesn't work properly | |||||
| * for post rule somewhere in MatchRule() function. or e.g.: | |||||
| * | * | ||||
| * .L01 ~ b c | * .L01 ~ b c | ||||
| * .group a | * .group a | ||||
| w++; | w++; | ||||
| p++; | p++; | ||||
| } | } | ||||
| if (*p == 0) { // matched some of group strings | |||||
| if (*p == 0) { // Matched the current group. | |||||
| if (pre) | if (pre) | ||||
| return len; | return len; | ||||
| return w - word; | return w - word; | ||||
| } | } | ||||
| // if the string of current group didn't match skip till to the | |||||
| // end of the string | |||||
| // No match, so skip the rest of this group. | |||||
| while (*p++ != 0) | while (*p++ != 0) | ||||
| ; | ; | ||||
| } | } |