syllable: remember code of the original letter
This commit is contained in:
parent
7fdbf8ada8
commit
1b0623ca43
3 changed files with 11 additions and 7 deletions
|
@ -13,6 +13,7 @@ struct syllable *syllable_alloc(const char *data)
|
|||
return NULL;
|
||||
|
||||
ptr->data = strdup(data);
|
||||
ptr->code = 0;
|
||||
ptr->prev = NULL;
|
||||
ptr->next = NULL;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
struct syllable {
|
||||
char *data;
|
||||
unsigned int code;
|
||||
struct syllable *prev;
|
||||
struct syllable *next;
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ char *transliterate_devanagari_to_latin(const char *text,
|
|||
const char *ptr = text;
|
||||
const char *end = ptr + length;
|
||||
char *tmp;
|
||||
unsigned int c;
|
||||
unsigned int code;
|
||||
struct syllable *head, *tail;
|
||||
const struct transliteration_letter *letter;
|
||||
|
||||
|
@ -51,21 +51,23 @@ char *transliterate_devanagari_to_latin(const char *text,
|
|||
tail = head;
|
||||
|
||||
while (ptr < end) {
|
||||
c = utf8_unpack_char(ptr);
|
||||
ptr += utf8_char_length(c);
|
||||
code = utf8_unpack_char(ptr);
|
||||
ptr += utf8_char_length(code);
|
||||
|
||||
letter = find_letter_by_code(c, context->table);
|
||||
letter = find_letter_by_code(code, context->table);
|
||||
if (letter != NULL) {
|
||||
|
||||
if (letter->flags & FLAG_REGULAR)
|
||||
if (letter->flags & FLAG_REGULAR) {
|
||||
tail = syllable_append(tail, letter->data);
|
||||
else if (letter->flags & FLAG_MODIFIER)
|
||||
tail->code = code;
|
||||
} else if (letter->flags & FLAG_MODIFIER) {
|
||||
syllable_modify(tail, letter->data);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
tmp = utf8_code_to_string(c);
|
||||
tmp = utf8_code_to_string(code);
|
||||
tail = syllable_append(tail, tmp);
|
||||
free(tmp);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue