viric@14: #include viric@14: #include "dictre.h" viric@14: viric@14: static void give_accent_to_word(const char *tmp) viric@14: { viric@14: char def[MAXDEF]; viric@14: viric@14: find_def(tmp, def); viric@14: if (def[0] != 0) /* found */ viric@14: { viric@14: /* Print the word UNTIL a space. viric@14: * the definition will have the form: viric@14: * ACCENTED_WORD NOMINATIVE1 NOMINATIVE2 ... \n */ viric@14: char *first_space; viric@14: char *pos; viric@14: first_space = strchr(def, ' '); viric@14: if (first_space != 0) /* Space found */ viric@14: for(pos = def; pos < first_space; ++pos) viric@14: putchar(*pos); viric@14: return; viric@14: } viric@14: viric@14: /* if first_space == 0 or word not found */ viric@14: printf("%s", tmp); viric@14: } viric@14: viric@14: static void process_text(FILE *in, int pos, int length) viric@14: { viric@14: unsigned char tmp[MAXWORD]; viric@14: int wordpos = 0; viric@14: do viric@14: { viric@14: int c; viric@14: /* Check pos only if length >= 0 */ viric@14: if (length >= 0 && pos >= length) viric@14: break; viric@14: c = fgetc(in); viric@14: if (c == EOF) viric@14: break; viric@14: if (is_ASCII(c)) viric@14: { viric@14: if (wordpos != 0) viric@14: { viric@14: tmp[wordpos] = 0; viric@14: give_accent_to_word(tmp); viric@14: wordpos = 0; viric@14: } viric@14: putchar(c); viric@14: } viric@14: else /* non-ASCII - we consider it russian */ viric@14: { viric@14: tmp[wordpos++] = c; viric@14: } viric@14: viric@14: pos += 1; viric@14: } while(1); viric@14: } viric@14: viric@14: int main() viric@14: { viric@14: init_dictionary(); viric@14: process_text(stdin, 0, -1); viric@14: end_dictionary(); viric@14: }