equal
deleted
inserted
replaced
|
1 #include <stdio.h> |
|
2 #include "dictre.h" |
|
3 |
|
4 static void give_accent_to_word(const char *tmp) |
|
5 { |
|
6 char def[MAXDEF]; |
|
7 |
|
8 find_def(tmp, def); |
|
9 if (def[0] != 0) /* found */ |
|
10 { |
|
11 /* Print the word UNTIL a space. |
|
12 * the definition will have the form: |
|
13 * ACCENTED_WORD NOMINATIVE1 NOMINATIVE2 ... \n */ |
|
14 char *first_space; |
|
15 char *pos; |
|
16 first_space = strchr(def, ' '); |
|
17 if (first_space != 0) /* Space found */ |
|
18 for(pos = def; pos < first_space; ++pos) |
|
19 putchar(*pos); |
|
20 return; |
|
21 } |
|
22 |
|
23 /* if first_space == 0 or word not found */ |
|
24 printf("%s", tmp); |
|
25 } |
|
26 |
|
27 static void process_text(FILE *in, int pos, int length) |
|
28 { |
|
29 unsigned char tmp[MAXWORD]; |
|
30 int wordpos = 0; |
|
31 do |
|
32 { |
|
33 int c; |
|
34 /* Check pos only if length >= 0 */ |
|
35 if (length >= 0 && pos >= length) |
|
36 break; |
|
37 c = fgetc(in); |
|
38 if (c == EOF) |
|
39 break; |
|
40 if (is_ASCII(c)) |
|
41 { |
|
42 if (wordpos != 0) |
|
43 { |
|
44 tmp[wordpos] = 0; |
|
45 give_accent_to_word(tmp); |
|
46 wordpos = 0; |
|
47 } |
|
48 putchar(c); |
|
49 } |
|
50 else /* non-ASCII - we consider it russian */ |
|
51 { |
|
52 tmp[wordpos++] = c; |
|
53 } |
|
54 |
|
55 pos += 1; |
|
56 } while(1); |
|
57 } |
|
58 |
|
59 int main() |
|
60 { |
|
61 init_dictionary(); |
|
62 process_text(stdin, 0, -1); |
|
63 end_dictionary(); |
|
64 } |