implement reverse mode for encoding + fix typos

This commit is contained in:
Vlasta Vesely 2021-04-16 12:14:08 +02:00
parent b732cf6c33
commit 000d33b7a2
No known key found for this signature in database
GPG key ID: EB0E649DC0DFCC22
2 changed files with 13 additions and 5 deletions

7
main.c
View file

@ -75,8 +75,13 @@ static int process_input(const char *input, char **out, unsigned int flags)
char *tmp = NULL;
int ret;
if (flags & FLAG_REVERSE)
if (flags & FLAG_REVERSE) {
if (flags & FLAG_VELTHUIS) {
return encode_iast_to_velthuis(input, out);
} else {
return transliterate_latin_to_devanagari(input, out);
}
}
if (flags & FLAG_VELTHUIS)
return encode_velthuis_to_iast(input, out);

View file

@ -97,9 +97,12 @@ END_TEST
START_TEST(test_velthuis)
{
test_output("./iast \"r.ta.m ca satyam\" -e", "rṭaṃ ca satyam\n");
test_output("./iast \"r.ta.m ca satyam\" --encode", "rṭaṃ ca satyam\n");
test_output("./iast \"r.ta.m ca satyam\" --velthuis", "rṭaṃ ca satyam\n");
test_output("./iast \".rta.m ca satyam\" -e", "ṛtaṃ ca satyam\n");
test_output("./iast \".rta.m ca satyam\" --encode", "ṛtaṃ ca satyam\n");
test_output("./iast \".rta.m ca satyam\" --velthuis", "ṛtaṃ ca satyam\n");
/* reverse */
test_output("./iast \"ṛtaṃ ca satyam\" -er", ".rta.m ca satyam\n");
}
END_TEST