From 000d33b7a2644ca6ce081a7013bfa7f5e8968849 Mon Sep 17 00:00:00 2001 From: Vlasta Vesely Date: Fri, 16 Apr 2021 12:14:08 +0200 Subject: [PATCH] implement reverse mode for encoding + fix typos --- main.c | 9 +++++++-- tests/integration.c | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 4a69c9f..caea188 100644 --- a/main.c +++ b/main.c @@ -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) - return transliterate_latin_to_devanagari(input, out); + 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); diff --git a/tests/integration.c b/tests/integration.c index 1f30161..1572ccd 100644 --- a/tests/integration.c +++ b/tests/integration.c @@ -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