Compare commits
10 commits
f63901f0cc
...
7e9e632b15
Author | SHA1 | Date | |
---|---|---|---|
7e9e632b15 | |||
61d36a546b | |||
cb7c09f44f | |||
82ab22f237 | |||
755f75857e | |||
119ae59457 | |||
5032ddbf6d | |||
b7dcc2940a | |||
4695ec3da9 | |||
caf12045fa |
15 changed files with 144 additions and 34 deletions
|
@ -1,16 +0,0 @@
|
||||||
version: '{branch}-{build}'
|
|
||||||
|
|
||||||
platform: x64
|
|
||||||
|
|
||||||
environment:
|
|
||||||
CYG_ROOT: C:\cygwin64
|
|
||||||
CYG_SHELL: C:\cygwin64\bin\sh
|
|
||||||
|
|
||||||
install:
|
|
||||||
- cmd: '%CYG_ROOT%\setup-x86_64.exe --quiet-mode --no-shortcuts --upgrade-also --packages autoconf,make,git,gcc,check'
|
|
||||||
|
|
||||||
build_script:
|
|
||||||
- cmd: '%CYG_SHELL% -lc "cd $APPVEYOR_BUILD_FOLDER && sh autogen.sh && sh configure && make all"'
|
|
||||||
|
|
||||||
test_script:
|
|
||||||
- cmd: '%CYG_SHELL% -lc "cd $APPVEYOR_BUILD_FOLDER && make test"'
|
|
22
.github/workflows/test.yml
vendored
Normal file
22
.github/workflows/test.yml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
name: C/C++ CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: dependencies
|
||||||
|
run: sudo apt update && sudo apt install -y autoconf make gcc lcov check pkg-config
|
||||||
|
- name: configure
|
||||||
|
run: sh autogen.sh && ./configure
|
||||||
|
- name: make
|
||||||
|
run: make
|
||||||
|
- name: maketest
|
||||||
|
run: make test
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,6 +3,7 @@
|
||||||
*.d
|
*.d
|
||||||
*.so
|
*.so
|
||||||
*.so.*
|
*.so.*
|
||||||
|
*.pc
|
||||||
/iast
|
/iast
|
||||||
/tests/test
|
/tests/test
|
||||||
/tests/coverage
|
/tests/coverage
|
||||||
|
|
11
Makefile.in
11
Makefile.in
|
@ -25,6 +25,7 @@ bindir = @bindir@
|
||||||
libdir = @libdir@
|
libdir = @libdir@
|
||||||
datarootdir = @datarootdir@
|
datarootdir = @datarootdir@
|
||||||
includedir = @includedir@
|
includedir = @includedir@
|
||||||
|
pkgconfigdir = @pkgconfigdir@
|
||||||
mandir = @mandir@
|
mandir = @mandir@
|
||||||
|
|
||||||
USE_GCOV = @USE_GCOV@
|
USE_GCOV = @USE_GCOV@
|
||||||
|
@ -57,7 +58,7 @@ $(ANAME): $(OBJECTS)
|
||||||
$(QUIET_AR) $(AR) rcs $@ $^
|
$(QUIET_AR) $(AR) rcs $@ $^
|
||||||
|
|
||||||
$(REALNAME): $(OBJECTS)
|
$(REALNAME): $(OBJECTS)
|
||||||
$(QUIET_LD) $(CC) $^ -shared -o $@ $(LFLAGS)
|
$(QUIET_LD) $(CC) $^ -shared -Wl,-soname=$(SONAME) -o $@ $(LFLAGS)
|
||||||
|
|
||||||
$(SONAME): $(REALNAME)
|
$(SONAME): $(REALNAME)
|
||||||
$(QUIET_LN) $(LN_S) -f $< $@
|
$(QUIET_LN) $(LN_S) -f $< $@
|
||||||
|
@ -83,7 +84,7 @@ tests/test: $(OBJECTS) $(TEST_OBJECTS)
|
||||||
install: install-prog install-lib install-dev
|
install: install-prog install-lib install-dev
|
||||||
|
|
||||||
install-prog:
|
install-prog:
|
||||||
$(MKDIR_P) $(bindir) $(libdir) $(mandir)/man1
|
$(MKDIR_P) $(bindir) $(mandir)/man1
|
||||||
$(INSTALL_PROGRAM) $(PROGNAME) $(bindir)
|
$(INSTALL_PROGRAM) $(PROGNAME) $(bindir)
|
||||||
$(INSTALL_DATA) $(PROGNAME).1.gz $(mandir)/man1
|
$(INSTALL_DATA) $(PROGNAME).1.gz $(mandir)/man1
|
||||||
|
|
||||||
|
@ -92,9 +93,10 @@ install-lib:
|
||||||
cp -P $(REALNAME) $(SONAME) $(libdir)
|
cp -P $(REALNAME) $(SONAME) $(libdir)
|
||||||
|
|
||||||
install-dev:
|
install-dev:
|
||||||
$(MKDIR_P) $(includedir)/iast $(libdir)
|
$(MKDIR_P) $(includedir)/iast $(libdir) $(pkgconfigdir)
|
||||||
$(INSTALL_DATA) $(INCLUDES) $(includedir)/iast
|
$(INSTALL_DATA) $(INCLUDES) $(includedir)/iast
|
||||||
$(INSTALL_DATA) iast.h $(includedir)
|
$(INSTALL_DATA) iast.h $(includedir)
|
||||||
|
$(INSTALL_DATA) $(PROGNAME).pc $(pkgconfigdir)
|
||||||
cp -P $(ANAME) $(LINKNAME) $(libdir)
|
cp -P $(ANAME) $(LINKNAME) $(libdir)
|
||||||
|
|
||||||
uninstall: uninstall-prog uninstall-lib uninstall-dev
|
uninstall: uninstall-prog uninstall-lib uninstall-dev
|
||||||
|
@ -108,10 +110,11 @@ uninstall-lib:
|
||||||
|
|
||||||
uninstall-dev:
|
uninstall-dev:
|
||||||
$(RM) -r $(includedir)/iast $(includedir)/iast.h
|
$(RM) -r $(includedir)/iast $(includedir)/iast.h
|
||||||
|
$(RM) $(pkgconfigdir)/$(PROGNAME).pc
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(PROGNAME) tests/test $(PROGNAME).1.gz
|
$(RM) $(PROGNAME) tests/test $(PROGNAME).1.gz
|
||||||
$(RM) -r $(LIBFILES) *.o */*.o */*.d *.d
|
$(RM) -r $(LIBFILES) *.o */*.o */*.d *.d $(PROGNAME).pc
|
||||||
$(RM) *.gcda *.gcno tests/coverage */*.test
|
$(RM) *.gcda *.gcno tests/coverage */*.test
|
||||||
|
|
||||||
clean-aux:
|
clean-aux:
|
||||||
|
|
6
README
6
README
|
@ -16,6 +16,12 @@ For more details on the usage of the program and the requirements for the input
|
||||||
data, see the included manual page iast(1).
|
data, see the included manual page iast(1).
|
||||||
|
|
||||||
|
|
||||||
|
Donations
|
||||||
|
---------
|
||||||
|
If you like this project and it is useful to you, consider sending a donation
|
||||||
|
to the following Bitcoin address: 1LXAkkvKodKB237yayzCTYAsb8tYawGfHz
|
||||||
|
|
||||||
|
|
||||||
Licensing Notice
|
Licensing Notice
|
||||||
----------------
|
----------------
|
||||||
This software is released under the terms of the GPL license version 2 as
|
This software is released under the terms of the GPL license version 2 as
|
||||||
|
|
1
compat.h
1
compat.h
|
@ -8,6 +8,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#define ARRAY_SIZE(a) sizeof(a) / sizeof(*a)
|
#define ARRAY_SIZE(a) sizeof(a) / sizeof(*a)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
AC_PREREQ([2.69])
|
||||||
AC_INIT([sanskrit-iast], [3.0.0], [vlastavesely@protonmail.ch])
|
AC_INIT([sanskrit-iast], [3.1.0], [vlastavesely@protonmail.ch])
|
||||||
AC_CONFIG_SRCDIR([transliteration.c])
|
AC_CONFIG_SRCDIR([transliteration.c])
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ AC_PROG_INSTALL
|
||||||
AC_PROG_LN_S
|
AC_PROG_LN_S
|
||||||
AC_CHECK_TOOL([AR], [ar])
|
AC_CHECK_TOOL([AR], [ar])
|
||||||
|
|
||||||
|
PKG_PROG_PKG_CONFIG
|
||||||
|
PKG_INSTALLDIR
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
PKG_CHECK_MODULES(CHECK, check)
|
PKG_CHECK_MODULES(CHECK, check)
|
||||||
|
|
||||||
|
@ -56,5 +59,5 @@ AC_SUBST(COVERAGE_CFLAGS)
|
||||||
AC_SUBST(COVERAGE_LFLAGS)
|
AC_SUBST(COVERAGE_LFLAGS)
|
||||||
AC_SUBST(USE_GCOV)
|
AC_SUBST(USE_GCOV)
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile])
|
AC_CONFIG_FILES([Makefile iast.pc])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
|
@ -3,6 +3,14 @@
|
||||||
#ifndef __HARVARD_KYOTO_H
|
#ifndef __HARVARD_KYOTO_H
|
||||||
#define __HARVARD_KYOTO_H
|
#define __HARVARD_KYOTO_H
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
int encode_harvard_kyoto_to_iast(const char *text, char **out);
|
int encode_harvard_kyoto_to_iast(const char *text, char **out);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __HARVARD_KYOTO_H */
|
#endif /* __HARVARD_KYOTO_H */
|
||||||
|
|
22
iast.1
22
iast.1
|
@ -1,4 +1,4 @@
|
||||||
.TH "iast" "1" "10 January 2022" "sanskrit-iast" "Sanskrit Transliteration"
|
.TH "iast" "1" "02 March 2023" "sanskrit-iast" "Sanskrit Transliteration"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.B iast
|
.B iast
|
||||||
|
@ -98,6 +98,19 @@ representation using the
|
||||||
scheme.
|
scheme.
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
|
.BR \-k ,
|
||||||
|
.BR \-\-harvard ,
|
||||||
|
.BR \-\-kyoto
|
||||||
|
.RS 4
|
||||||
|
Convert a plain
|
||||||
|
.BR ASCII (7)
|
||||||
|
string to the
|
||||||
|
.I IAST
|
||||||
|
representation using the
|
||||||
|
.I Harvard-Kyoto
|
||||||
|
scheme.
|
||||||
|
.RE
|
||||||
|
|
||||||
.BR \-a ,
|
.BR \-a ,
|
||||||
.B \-\-ascii
|
.B \-\-ascii
|
||||||
.RS 4
|
.RS 4
|
||||||
|
@ -201,14 +214,17 @@ Wikipedia:
|
||||||
.br
|
.br
|
||||||
.I https://en.wikipedia.org/wiki/Velthuis
|
.I https://en.wikipedia.org/wiki/Velthuis
|
||||||
- the Velthuis scheme.
|
- the Velthuis scheme.
|
||||||
|
.br
|
||||||
|
.I https://en.wikipedia.org/wiki/Harvard-Kyoto
|
||||||
|
- the Harvard-Kyoto scheme.
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
|
|
||||||
.SH REPORTING BUGS
|
.SH REPORTING BUGS
|
||||||
If you encounter a bug, you should make sure that you are using the latest
|
If you encounter a bug, you should make sure that you are using the latest
|
||||||
version of the software. If you are and the bug is still present, you can
|
version of the software. If you are and the bug is still present, you can
|
||||||
report it on the GitLab issues tracker:
|
report it on the GitHub issues tracker:
|
||||||
.IR https://gitlab.com/vlastavesely/sanskrit-iast/issues .
|
.IR https://github.com/vlastavesely/sanskrit-iast/issues .
|
||||||
|
|
||||||
|
|
||||||
.SH LICENSE AND WARRANTY
|
.SH LICENSE AND WARRANTY
|
||||||
|
|
11
iast.pc.in
Normal file
11
iast.pc.in
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
libdir=@libdir@
|
||||||
|
includedir=@includedir@
|
||||||
|
|
||||||
|
Name: libiast
|
||||||
|
URL: https://github.com/vlastavesely/sanskrit-iast
|
||||||
|
Description: Library for romanisation of texts written in Devanagari
|
||||||
|
Version: @PACKAGE_VERSION@
|
||||||
|
Libs: -L${libdir} -liast
|
||||||
|
Cflags:
|
|
@ -152,7 +152,7 @@ END_TEST
|
||||||
|
|
||||||
START_TEST(test_version)
|
START_TEST(test_version)
|
||||||
{
|
{
|
||||||
test_output("./iast -v", "iast v3.0.0\n");
|
test_output("./iast -v", "iast v3.1.0\n");
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,18 @@ static void test_translit(const char *devanagari, const char *latin)
|
||||||
free(b);
|
free(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_translit_latin(const char *latin, const char *devanagari)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = transliterate_latin_to_devanagari(latin, &str);
|
||||||
|
ck_assert_int_eq(0, ret);
|
||||||
|
ck_assert_str_eq(devanagari, str);
|
||||||
|
|
||||||
|
free(str);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(test_translit_words)
|
START_TEST(test_translit_words)
|
||||||
{
|
{
|
||||||
/* https://en.wikipedia.org/wiki/Sanskrit */
|
/* https://en.wikipedia.org/wiki/Sanskrit */
|
||||||
|
@ -52,6 +64,9 @@ START_TEST(test_translit_vedic)
|
||||||
|
|
||||||
/* vedic stresses */
|
/* vedic stresses */
|
||||||
test_translit("अ॒ग्निमी॑ळे पु॒रोहि॑तं", "a\\_gnimī\\'ḷe pu\\_rohi\\'taṃ");
|
test_translit("अ॒ग्निमी॑ळे पु॒रोहि॑तं", "a\\_gnimī\\'ḷe pu\\_rohi\\'taṃ");
|
||||||
|
|
||||||
|
/* double svarita */
|
||||||
|
test_translit("अ॒ग्निमी᳚ळे", "a\\_gnimī\\\"ḷe");
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
@ -67,6 +82,17 @@ START_TEST(test_translit_lla_sylable)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_translit_aum)
|
||||||
|
{
|
||||||
|
test_translit("ॐ औम औमे तौमे ॐ", "aum auma aume taume aum");
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(test_translit_avagraha)
|
||||||
|
{
|
||||||
|
test_translit_latin("śivo'ham", "शिवोऽहम्");
|
||||||
|
test_translit_latin("śivo’ham", "शिवोऽहम्");
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(test_translit_candrabindu)
|
START_TEST(test_translit_candrabindu)
|
||||||
{
|
{
|
||||||
test_translit("तान्यजत्राँ", "tānyajatrām̐");
|
test_translit("तान्यजत्राँ", "tānyajatrām̐");
|
||||||
|
@ -84,6 +110,8 @@ void register_translit_tests(TCase *test_case)
|
||||||
tcase_add_test(test_case, test_translit_words);
|
tcase_add_test(test_case, test_translit_words);
|
||||||
tcase_add_test(test_case, test_translit_vedic);
|
tcase_add_test(test_case, test_translit_vedic);
|
||||||
tcase_add_test(test_case, test_translit_lla_sylable);
|
tcase_add_test(test_case, test_translit_lla_sylable);
|
||||||
|
tcase_add_test(test_case, test_translit_aum);
|
||||||
|
tcase_add_test(test_case, test_translit_avagraha);
|
||||||
tcase_add_test(test_case, test_translit_candrabindu);
|
tcase_add_test(test_case, test_translit_candrabindu);
|
||||||
tcase_add_test(test_case, test_translit_zero_width_joiner);
|
tcase_add_test(test_case, test_translit_zero_width_joiner);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#define SCHWA_CHARACTER 'a'
|
#define SCHWA_CHARACTER 'a'
|
||||||
#define ZERO_WIDTH_JOINER 0x200d
|
#define ZERO_WIDTH_JOINER 0x200d
|
||||||
#define VIRAMA 0x094d
|
#define VIRAMA 0x094d
|
||||||
|
#define AUM 0x0950
|
||||||
#define CHUNKSIZE 1024
|
#define CHUNKSIZE 1024
|
||||||
|
|
||||||
static struct translit_letter table[] = {
|
static struct translit_letter table[] = {
|
||||||
|
@ -35,6 +36,7 @@ static struct translit_letter table[] = {
|
||||||
{0x0902, CODA, "\u1e43"}, /* anusvara (.m) */
|
{0x0902, CODA, "\u1e43"}, /* anusvara (.m) */
|
||||||
{0x0903, CODA, "\u1e25"}, /* visarga (.h) */
|
{0x0903, CODA, "\u1e25"}, /* visarga (.h) */
|
||||||
{0x093d, CODA, "'"}, /* avagrada (') */
|
{0x093d, CODA, "'"}, /* avagrada (') */
|
||||||
|
{0x093d, CODA, "’"}, /* avagrada (’) - typographic */
|
||||||
{0x0901, CODA, "m\u0310"}, /* candrabindu */
|
{0x0901, CODA, "m\u0310"}, /* candrabindu */
|
||||||
|
|
||||||
/* Consonants */
|
/* Consonants */
|
||||||
|
@ -105,6 +107,7 @@ static struct translit_letter table[] = {
|
||||||
{0x0964, CODA, "|"}, /* danda */
|
{0x0964, CODA, "|"}, /* danda */
|
||||||
|
|
||||||
{0x0951, CODA, "\\'"}, /* svarita */
|
{0x0951, CODA, "\\'"}, /* svarita */
|
||||||
|
{0x1cda, CODA, "\\\""}, /* double svarita */
|
||||||
{0x0952, CODA, "\\_"} /* anudatta */
|
{0x0952, CODA, "\\_"} /* anudatta */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -259,6 +262,14 @@ int transliterate_latin_to_devanagari(const char *latin, char **ret)
|
||||||
letter = letter_by_code(0x0933); /* .la */
|
letter = letter_by_code(0x0933); /* .la */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (letter->code == AUM) {
|
||||||
|
/* ‘aum’ is followed by something else than
|
||||||
|
* a whitespace → it is ‘au’ + ‘m…’ */
|
||||||
|
if (!isspace(src[3]) && src[3] != '\0') {
|
||||||
|
letter = letter_by_code(0x0914);
|
||||||
|
}
|
||||||
|
}
|
||||||
encode_consonant:
|
encode_consonant:
|
||||||
/* A consonant or an initial vowel */
|
/* A consonant or an initial vowel */
|
||||||
utf8_pack_char(devanagari + done, letter->code);
|
utf8_pack_char(devanagari + done, letter->code);
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
#ifndef __TRANSLITERATION_H
|
#ifndef __TRANSLITERATION_H
|
||||||
#define __TRANSLITERATION_H
|
#define __TRANSLITERATION_H
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
enum translit_letter_type {
|
enum translit_letter_type {
|
||||||
VOWEL,
|
VOWEL,
|
||||||
CONSONANT,
|
CONSONANT,
|
||||||
|
@ -30,4 +34,8 @@ static inline int is_devanagari(unsigned int code)
|
||||||
return code >= 0x0900 && code <= 0x097f;
|
return code >= 0x0900 && code <= 0x097f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __TRANSLITERATION_H */
|
#endif /* __TRANSLITERATION_H */
|
||||||
|
|
|
@ -3,7 +3,15 @@
|
||||||
#ifndef __VELTHUIS_H
|
#ifndef __VELTHUIS_H
|
||||||
#define __VELTHUIS_H
|
#define __VELTHUIS_H
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
int encode_velthuis_to_iast(const char *text, char **out);
|
int encode_velthuis_to_iast(const char *text, char **out);
|
||||||
int encode_iast_to_velthuis(const char *text, char **out);
|
int encode_iast_to_velthuis(const char *text, char **out);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __VELTHUIS_H */
|
#endif /* __VELTHUIS_H */
|
||||||
|
|
Loading…
Reference in a new issue