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
|
||||
*.so
|
||||
*.so.*
|
||||
*.pc
|
||||
/iast
|
||||
/tests/test
|
||||
/tests/coverage
|
||||
|
|
11
Makefile.in
11
Makefile.in
|
@ -25,6 +25,7 @@ bindir = @bindir@
|
|||
libdir = @libdir@
|
||||
datarootdir = @datarootdir@
|
||||
includedir = @includedir@
|
||||
pkgconfigdir = @pkgconfigdir@
|
||||
mandir = @mandir@
|
||||
|
||||
USE_GCOV = @USE_GCOV@
|
||||
|
@ -57,7 +58,7 @@ $(ANAME): $(OBJECTS)
|
|||
$(QUIET_AR) $(AR) rcs $@ $^
|
||||
|
||||
$(REALNAME): $(OBJECTS)
|
||||
$(QUIET_LD) $(CC) $^ -shared -o $@ $(LFLAGS)
|
||||
$(QUIET_LD) $(CC) $^ -shared -Wl,-soname=$(SONAME) -o $@ $(LFLAGS)
|
||||
|
||||
$(SONAME): $(REALNAME)
|
||||
$(QUIET_LN) $(LN_S) -f $< $@
|
||||
|
@ -83,7 +84,7 @@ tests/test: $(OBJECTS) $(TEST_OBJECTS)
|
|||
install: install-prog install-lib install-dev
|
||||
|
||||
install-prog:
|
||||
$(MKDIR_P) $(bindir) $(libdir) $(mandir)/man1
|
||||
$(MKDIR_P) $(bindir) $(mandir)/man1
|
||||
$(INSTALL_PROGRAM) $(PROGNAME) $(bindir)
|
||||
$(INSTALL_DATA) $(PROGNAME).1.gz $(mandir)/man1
|
||||
|
||||
|
@ -92,9 +93,10 @@ install-lib:
|
|||
cp -P $(REALNAME) $(SONAME) $(libdir)
|
||||
|
||||
install-dev:
|
||||
$(MKDIR_P) $(includedir)/iast $(libdir)
|
||||
$(MKDIR_P) $(includedir)/iast $(libdir) $(pkgconfigdir)
|
||||
$(INSTALL_DATA) $(INCLUDES) $(includedir)/iast
|
||||
$(INSTALL_DATA) iast.h $(includedir)
|
||||
$(INSTALL_DATA) $(PROGNAME).pc $(pkgconfigdir)
|
||||
cp -P $(ANAME) $(LINKNAME) $(libdir)
|
||||
|
||||
uninstall: uninstall-prog uninstall-lib uninstall-dev
|
||||
|
@ -108,10 +110,11 @@ uninstall-lib:
|
|||
|
||||
uninstall-dev:
|
||||
$(RM) -r $(includedir)/iast $(includedir)/iast.h
|
||||
$(RM) $(pkgconfigdir)/$(PROGNAME).pc
|
||||
|
||||
clean:
|
||||
$(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
|
||||
|
||||
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).
|
||||
|
||||
|
||||
Donations
|
||||
---------
|
||||
If you like this project and it is useful to you, consider sending a donation
|
||||
to the following Bitcoin address: 1LXAkkvKodKB237yayzCTYAsb8tYawGfHz
|
||||
|
||||
|
||||
Licensing Notice
|
||||
----------------
|
||||
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 <stdarg.h>
|
||||
#include <getopt.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define ARRAY_SIZE(a) sizeof(a) / sizeof(*a)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
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_HEADERS([config.h])
|
||||
|
||||
|
@ -17,6 +17,9 @@ AC_PROG_INSTALL
|
|||
AC_PROG_LN_S
|
||||
AC_CHECK_TOOL([AR], [ar])
|
||||
|
||||
PKG_PROG_PKG_CONFIG
|
||||
PKG_INSTALLDIR
|
||||
|
||||
# Checks for libraries.
|
||||
PKG_CHECK_MODULES(CHECK, check)
|
||||
|
||||
|
@ -56,5 +59,5 @@ AC_SUBST(COVERAGE_CFLAGS)
|
|||
AC_SUBST(COVERAGE_LFLAGS)
|
||||
AC_SUBST(USE_GCOV)
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_CONFIG_FILES([Makefile iast.pc])
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
#ifndef __HARVARD_KYOTO_H
|
||||
#define __HARVARD_KYOTO_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int encode_harvard_kyoto_to_iast(const char *text, char **out);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
.B iast
|
||||
|
@ -98,6 +98,19 @@ representation using the
|
|||
scheme.
|
||||
.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 ,
|
||||
.B \-\-ascii
|
||||
.RS 4
|
||||
|
@ -201,14 +214,17 @@ Wikipedia:
|
|||
.br
|
||||
.I https://en.wikipedia.org/wiki/Velthuis
|
||||
- the Velthuis scheme.
|
||||
.br
|
||||
.I https://en.wikipedia.org/wiki/Harvard-Kyoto
|
||||
- the Harvard-Kyoto scheme.
|
||||
.RE
|
||||
|
||||
|
||||
.SH REPORTING BUGS
|
||||
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
|
||||
report it on the GitLab issues tracker:
|
||||
.IR https://gitlab.com/vlastavesely/sanskrit-iast/issues .
|
||||
report it on the GitHub issues tracker:
|
||||
.IR https://github.com/vlastavesely/sanskrit-iast/issues .
|
||||
|
||||
|
||||
.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)
|
||||
{
|
||||
test_output("./iast -v", "iast v3.0.0\n");
|
||||
test_output("./iast -v", "iast v3.1.0\n");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
|
@ -23,6 +23,18 @@ static void test_translit(const char *devanagari, const char *latin)
|
|||
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)
|
||||
{
|
||||
/* https://en.wikipedia.org/wiki/Sanskrit */
|
||||
|
@ -52,6 +64,9 @@ START_TEST(test_translit_vedic)
|
|||
|
||||
/* vedic stresses */
|
||||
test_translit("अ॒ग्निमी॑ळे पु॒रोहि॑तं", "a\\_gnimī\\'ḷe pu\\_rohi\\'taṃ");
|
||||
|
||||
/* double svarita */
|
||||
test_translit("अ॒ग्निमी᳚ळे", "a\\_gnimī\\\"ḷe");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
@ -67,6 +82,17 @@ START_TEST(test_translit_lla_sylable)
|
|||
}
|
||||
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)
|
||||
{
|
||||
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_vedic);
|
||||
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_zero_width_joiner);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define SCHWA_CHARACTER 'a'
|
||||
#define ZERO_WIDTH_JOINER 0x200d
|
||||
#define VIRAMA 0x094d
|
||||
#define AUM 0x0950
|
||||
#define CHUNKSIZE 1024
|
||||
|
||||
static struct translit_letter table[] = {
|
||||
|
@ -35,6 +36,7 @@ static struct translit_letter table[] = {
|
|||
{0x0902, CODA, "\u1e43"}, /* anusvara (.m) */
|
||||
{0x0903, CODA, "\u1e25"}, /* visarga (.h) */
|
||||
{0x093d, CODA, "'"}, /* avagrada (') */
|
||||
{0x093d, CODA, "’"}, /* avagrada (’) - typographic */
|
||||
{0x0901, CODA, "m\u0310"}, /* candrabindu */
|
||||
|
||||
/* Consonants */
|
||||
|
@ -105,6 +107,7 @@ static struct translit_letter table[] = {
|
|||
{0x0964, CODA, "|"}, /* danda */
|
||||
|
||||
{0x0951, CODA, "\\'"}, /* svarita */
|
||||
{0x1cda, CODA, "\\\""}, /* double svarita */
|
||||
{0x0952, CODA, "\\_"} /* anudatta */
|
||||
};
|
||||
|
||||
|
@ -259,6 +262,14 @@ int transliterate_latin_to_devanagari(const char *latin, char **ret)
|
|||
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:
|
||||
/* A consonant or an initial vowel */
|
||||
utf8_pack_char(devanagari + done, letter->code);
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
#ifndef __TRANSLITERATION_H
|
||||
#define __TRANSLITERATION_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum translit_letter_type {
|
||||
VOWEL,
|
||||
CONSONANT,
|
||||
|
@ -30,4 +34,8 @@ static inline int is_devanagari(unsigned int code)
|
|||
return code >= 0x0900 && code <= 0x097f;
|
||||
}
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __TRANSLITERATION_H */
|
||||
|
|
|
@ -3,7 +3,15 @@
|
|||
#ifndef __VELTHUIS_H
|
||||
#define __VELTHUIS_H
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int encode_velthuis_to_iast(const char *text, char **out);
|
||||
int encode_iast_to_velthuis(const char *text, char **out);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __VELTHUIS_H */
|
||||
|
|
Loading…
Reference in a new issue