add the ‘-d’ option
This commit is contained in:
parent
ff04eba8f5
commit
5685e83933
3 changed files with 32 additions and 3 deletions
8
iast.1
8
iast.1
|
@ -91,6 +91,14 @@ encoding rather than
|
||||||
characters.
|
characters.
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
|
.BR \-d ,
|
||||||
|
.B \-\-devanagari
|
||||||
|
.RS 4
|
||||||
|
When encoding, output Devanagari rather than
|
||||||
|
.I IAST
|
||||||
|
characters.
|
||||||
|
.RE
|
||||||
|
|
||||||
.BR \-h ,
|
.BR \-h ,
|
||||||
.B \-\-help
|
.B \-\-help
|
||||||
.RS 4
|
.RS 4
|
||||||
|
|
24
main.c
24
main.c
|
@ -8,6 +8,7 @@
|
||||||
#define FLAG_VELTHUIS 1 << 1
|
#define FLAG_VELTHUIS 1 << 1
|
||||||
#define FLAG_CZECH 1 << 2
|
#define FLAG_CZECH 1 << 2
|
||||||
#define FLAG_ASCII 1 << 3
|
#define FLAG_ASCII 1 << 3
|
||||||
|
#define FLAG_DEVANAGARI 1 << 4
|
||||||
|
|
||||||
static const char *usage_str =
|
static const char *usage_str =
|
||||||
PROGNAME ", a helper for Sanskrit transliteration.\n"
|
PROGNAME ", a helper for Sanskrit transliteration.\n"
|
||||||
|
@ -19,6 +20,8 @@ static const char *usage_str =
|
||||||
" -f, --file the input file for transliteration\n"
|
" -f, --file the input file for transliteration\n"
|
||||||
" -r, --reverse reverse transliteration (from Latin to Devanagari)\n"
|
" -r, --reverse reverse transliteration (from Latin to Devanagari)\n"
|
||||||
" -e, --encode convert an ASCII text to IAST using the Velthuis scheme\n"
|
" -e, --encode convert an ASCII text to IAST using the Velthuis scheme\n"
|
||||||
|
" -a, --ascii convert a Devanagari text to Velthuis text rather than to IAST\n"
|
||||||
|
" -d, --devanagari when encoding, output a Devanagari text rather than IAST\n"
|
||||||
" -c, --czech transcript Devanagari to Czech language (experimental)\n"
|
" -c, --czech transcript Devanagari to Czech language (experimental)\n"
|
||||||
" -h, --help show this help and exit\n"
|
" -h, --help show this help and exit\n"
|
||||||
" -v, --version show version number and exit\n"
|
" -v, --version show version number and exit\n"
|
||||||
|
@ -35,7 +38,7 @@ static const char *usage_str =
|
||||||
"\n"
|
"\n"
|
||||||
" For more information see the iast(1) manual page.\n";
|
" For more information see the iast(1) manual page.\n";
|
||||||
|
|
||||||
static const char *short_opts = "f:reachv";
|
static const char *short_opts = "f:readchv";
|
||||||
|
|
||||||
static const struct option long_opts[] = {
|
static const struct option long_opts[] = {
|
||||||
{"file", required_argument, 0, 'f'},
|
{"file", required_argument, 0, 'f'},
|
||||||
|
@ -43,6 +46,7 @@ static const struct option long_opts[] = {
|
||||||
{"encode", no_argument, 0, 'e'},
|
{"encode", no_argument, 0, 'e'},
|
||||||
{"velthuis", no_argument, 0, 'e'},
|
{"velthuis", no_argument, 0, 'e'},
|
||||||
{"ascii", no_argument, 0, 'a'},
|
{"ascii", no_argument, 0, 'a'},
|
||||||
|
{"devanagari", no_argument, 0, 'd'},
|
||||||
{"czech", no_argument, 0, 'c'},
|
{"czech", no_argument, 0, 'c'},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, 0, 'h'},
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, 0, 'v'},
|
||||||
|
@ -83,8 +87,19 @@ static int process_input(const char *input, char **out, unsigned int flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & FLAG_VELTHUIS)
|
if (flags & FLAG_VELTHUIS) {
|
||||||
return encode_velthuis_to_iast(input, out);
|
if (flags & FLAG_DEVANAGARI) {
|
||||||
|
ret = encode_velthuis_to_iast(input, &tmp);
|
||||||
|
if (ret != 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = transliterate_latin_to_devanagari(tmp, out);
|
||||||
|
free(tmp);
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
return encode_velthuis_to_iast(input, out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & FLAG_CZECH)
|
if (flags & FLAG_CZECH)
|
||||||
return transcript_devanagari_to_czech(input, out);
|
return transcript_devanagari_to_czech(input, out);
|
||||||
|
@ -204,6 +219,9 @@ int main(int argc, const char **argv)
|
||||||
case 'a':
|
case 'a':
|
||||||
flags |= FLAG_ASCII;
|
flags |= FLAG_ASCII;
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
flags |= FLAG_DEVANAGARI;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
flags |= FLAG_CZECH;
|
flags |= FLAG_CZECH;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -103,6 +103,9 @@ START_TEST(test_velthuis)
|
||||||
|
|
||||||
/* reverse */
|
/* reverse */
|
||||||
test_output("./iast \"ṛtaṃ ca satyam\" -er", ".rta.m ca satyam\n");
|
test_output("./iast \"ṛtaṃ ca satyam\" -er", ".rta.m ca satyam\n");
|
||||||
|
|
||||||
|
/* force Devanagari output */
|
||||||
|
test_output("./iast \"agnii.h\" -ed", "अग्नीः\n");
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue