git: 654cb5b91266 - main - textproc/lua-icu-utils: New port

From: Martin Matuska <mm_at_FreeBSD.org>
Date: Wed, 16 Feb 2022 15:20:46 UTC
The branch main has been updated by mm:

URL: https://cgit.FreeBSD.org/ports/commit/?id=654cb5b91266e40ffe32db8234508b515422dbb4

commit 654cb5b91266e40ffe32db8234508b515422dbb4
Author:     Martin Matuska <mm@FreeBSD.org>
AuthorDate: 2022-02-16 15:19:10 +0000
Commit:     Martin Matuska <mm@FreeBSD.org>
CommitDate: 2022-02-16 15:19:50 +0000

    textproc/lua-icu-utils: New port
    
    Lua interface to selected utilities from the ICU project
    
    WWW: https://github.com/adam-stanek/lua_icu_utils
---
 textproc/Makefile                                  |  1 +
 textproc/lua-icu-utils/Makefile                    | 40 ++++++++++++++++++++++
 textproc/lua-icu-utils/distinfo                    |  3 ++
 .../lua-icu-utils/files/patch-src_convert__case.c  | 29 ++++++++++++++++
 textproc/lua-icu-utils/pkg-descr                   |  3 ++
 5 files changed, 76 insertions(+)

diff --git a/textproc/Makefile b/textproc/Makefile
index a1986b1ab2f6..ae2c01c9bfbd 100644
--- a/textproc/Makefile
+++ b/textproc/Makefile
@@ -429,6 +429,7 @@
     SUBDIR += lt-hyphen
     SUBDIR += lttoolbox
     SUBDIR += ltxml
+    SUBDIR += lua-icu-utils
     SUBDIR += lua-lyaml
     SUBDIR += luaexpat
     SUBDIR += lucene
diff --git a/textproc/lua-icu-utils/Makefile b/textproc/lua-icu-utils/Makefile
new file mode 100644
index 000000000000..ca646aa4861b
--- /dev/null
+++ b/textproc/lua-icu-utils/Makefile
@@ -0,0 +1,40 @@
+# Created by: Martin Matuska <mm@FreeBSD.org>
+
+PORTNAME=	icu-utils
+DISTVERSION=	0.0-20160816
+CATEGORIES=	textproc
+PKGNAMEPREFIX=	${LUA_PKGNAMEPREFIX}
+
+MAINTAINER=	mm@FreeBSD.org
+COMMENT=	Lua interface to selected ICU utilities
+
+LICENSE=	MIT
+
+LIB_DEPENDS=	libicui18n.so:devel/icu
+
+USES=		gmake lua:module
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	adam-stanek
+GH_PROJECT=	lua_icu_utils
+GH_TAGNAME=	df830c0
+
+CFLAGS+=	-fPIC -I${LOCALBASE}/include
+MAKE_ARGS=	CC="${CC}" CFLAGS="${CFLAGS}" LDFLAGS="-shared -L${LOCALBASE}/lib" LUA_INCDIR="${LUA_INCDIR}"
+
+PLIST_FILES=	${LUA_MODLIBDIR}/icu_utils.so
+PORTDOCS=	README.md
+
+DOCSDIR=	${PREFIX}/share/doc/lua${LUA_VER_STR}/${PORTNAME}
+
+OPTIONS_DEFINE=	DOCS
+
+do-install:
+	${MKDIR} ${STAGEDIR}${LUA_MODLIBDIR}
+	${INSTALL_LIB} ${WRKSRC}/icu_utils.so ${STAGEDIR}${LUA_MODLIBDIR}
+
+do-install-DOCS-on:
+	${MKDIR} ${STAGEDIR}${DOCSDIR}
+	${INSTALL_DATA} ${WRKSRC}/README.md ${STAGEDIR}${DOCSDIR}
+
+.include <bsd.port.mk>
diff --git a/textproc/lua-icu-utils/distinfo b/textproc/lua-icu-utils/distinfo
new file mode 100644
index 000000000000..6a75857d3ea8
--- /dev/null
+++ b/textproc/lua-icu-utils/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1645023714
+SHA256 (adam-stanek-lua_icu_utils-0.0-20160816-df830c0_GH0.tar.gz) = 52f964db41cbdad5baac755805a9310b27d8d0dc7a7f429cddd81dea948f4348
+SIZE (adam-stanek-lua_icu_utils-0.0-20160816-df830c0_GH0.tar.gz) = 5799
diff --git a/textproc/lua-icu-utils/files/patch-src_convert__case.c b/textproc/lua-icu-utils/files/patch-src_convert__case.c
new file mode 100644
index 000000000000..eba62824f6fe
--- /dev/null
+++ b/textproc/lua-icu-utils/files/patch-src_convert__case.c
@@ -0,0 +1,29 @@
+--- src/convert_case.c.orig	2022-02-16 14:49:42 UTC
++++ src/convert_case.c
+@@ -45,7 +45,7 @@ int strtolower(lua_State *l) {
+   int32_t out_len = u_strToLower(dest, str_len, str, str_len, "", &status);
+   if(U_FAILURE(status)) {
+     // Allocate more memory if necessary
+-    if(status = U_BUFFER_OVERFLOW_ERROR) {
++    if(status == U_BUFFER_OVERFLOW_ERROR) {
+       free(dest);
+       dest = malloc(sizeof(UChar) * (out_len + 1));
+       if(!dest) {
+@@ -109,7 +109,7 @@ int strtoupper(lua_State *l) {
+   int32_t out_len = u_strToUpper(dest, str_len, str, str_len, "", &status);
+   if(U_FAILURE(status)) {
+     // Allocate more memory if necessary
+-    if(status = U_BUFFER_OVERFLOW_ERROR) {
++    if(status == U_BUFFER_OVERFLOW_ERROR) {
+       free(dest);
+       dest = malloc(sizeof(UChar) * (out_len + 1));
+       if(!dest) {
+@@ -173,7 +173,7 @@ int strtotitle(lua_State *l) {
+   int32_t out_len = u_strToTitle(dest, str_len, str, str_len, NULL, "", &status);
+   if(U_FAILURE(status)) {
+     // Allocate more memory if necessary
+-    if(status = U_BUFFER_OVERFLOW_ERROR) {
++    if(status == U_BUFFER_OVERFLOW_ERROR) {
+       free(dest);
+       dest = malloc(sizeof(UChar) * (out_len + 1));
+       if(!dest) {
diff --git a/textproc/lua-icu-utils/pkg-descr b/textproc/lua-icu-utils/pkg-descr
new file mode 100644
index 000000000000..bd0094f0105a
--- /dev/null
+++ b/textproc/lua-icu-utils/pkg-descr
@@ -0,0 +1,3 @@
+Lua interface to selected utilities from the ICU project
+
+WWW: https://github.com/adam-stanek/lua_icu_utils