From eaa7b4910796e8181cddc294af119ee8c56db45f Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 17 Aug 2017 00:34:44 +0200 Subject: [PATCH] Make libintl.h provide inline stubs Previously libandroid-support contained inline stubs for libintl.h functions (gettext(), dgettext() and friends). We now provide inline versions of them in libintl.h directly so libandroid-support is no longer necessary to get them. --- build-package.sh | 4 +-- ndk-patches/libintl.h | 53 ++++++++++++++++++++++++++++ packages/libandroid-support/build.sh | 8 ++--- 3 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 ndk-patches/libintl.h diff --git a/build-package.sh b/build-package.sh index 9018f069f..f4fa40d44 100755 --- a/build-package.sh +++ b/build-package.sh @@ -365,7 +365,7 @@ termux_step_start_build() { TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_TOPDIR/_lib/${TERMUX_NDK_VERSION}-${TERMUX_ARCH}-${TERMUX_PKG_API_LEVEL}" # Bump the below version if a change is made in toolchain setup to ensure # that everyone gets an updated toolchain: - TERMUX_STANDALONE_TOOLCHAIN+="-v11" + TERMUX_STANDALONE_TOOLCHAIN+="-v12" if [ -n "${TERMUX_PKG_BLACKLISTED_ARCHES:=""}" ] && [ "$TERMUX_PKG_BLACKLISTED_ARCHES" != "${TERMUX_PKG_BLACKLISTED_ARCHES/$TERMUX_ARCH/}" ]; then echo "Skipping building $TERMUX_PKG_NAME for arch $TERMUX_ARCH" @@ -658,7 +658,7 @@ termux_step_setup_toolchain() { # elf.h: Taken from glibc since the elf.h in the NDK is lacking. # sysexits.h: Header-only and used by a few programs. # ifaddrs.h: Added in android-24 unified headers, use a inline implementation for now. - cp "$TERMUX_SCRIPTDIR"/ndk-patches/{elf.h,sysexits.h,ifaddrs.h} usr/include + cp "$TERMUX_SCRIPTDIR"/ndk-patches/{elf.h,sysexits.h,ifaddrs.h,libintl.h} usr/include # Remove from the NDK in favour of that from the libandroid-shmem. # Also remove as it doesn't work for non-root. diff --git a/ndk-patches/libintl.h b/ndk-patches/libintl.h new file mode 100644 index 000000000..16eb25225 --- /dev/null +++ b/ndk-patches/libintl.h @@ -0,0 +1,53 @@ +#ifndef _LIBINTL_H +#define _LIBINTL_H + +#include +#include + +static __inline__ char* gettext(const char* msgid) +{ return (char*) msgid; } + +static __inline__ char* dgettext(const char* domainname, const char* msgid) +{ return (char*) msgid; } + +static __inline__ char* dcgettext(const char* domainname, const char* msgid, int category) +{ return (char*) msgid; } + +static __inline__ char* ngettext(const char* msgid1, const char* msgid2, unsigned long int n) +{ return (char *) ((n == 1) ? msgid1 : msgid2); } + +static __inline__ char* dngettext(const char* domainname, const char* msgid1, const char* msgid2, unsigned long int n) +{ return (char *) ((n == 1) ? msgid1 : msgid2); } + +static __inline__ char* dcngettext(const char* domainname, const char* msgid1, const char* msgid2, unsigned long int n, int category) +{ return (char *) ((n == 1) ? msgid1 : msgid2); } + +static __inline__ char* textdomain(const char* domainname) +{ + static const char default_str[] = "messages"; + if (domainname && *domainname && strcmp(domainname, default_str)) { + errno = EINVAL; + return NULL; + } + return (char*) default_str; +} + +static __inline__ char* bindtextdomain(const char* domainname, const char* dirname) +{ + static const char dir[] = "/"; + if (!domainname || !*domainname || (dirname && ((dirname[0] != '/') || dirname[1]))) { + errno = EINVAL; + return NULL; + } + return (char*) dir; +} + +static __inline__ char* bind_textdomain_codeset(const char* domainname, const char* codeset) +{ + if (!domainname || !*domainname || (codeset && strcasecmp(codeset, "UTF-8"))) { + errno = EINVAL; + } + return NULL; +} + +#endif diff --git a/packages/libandroid-support/build.sh b/packages/libandroid-support/build.sh index a290e3b35..2b0d83f2b 100755 --- a/packages/libandroid-support/build.sh +++ b/packages/libandroid-support/build.sh @@ -1,7 +1,7 @@ TERMUX_PKG_HOMEPAGE=https://github.com/termux/libandroid-support TERMUX_PKG_DESCRIPTION="Library extending the Android C library (Bionic) for additional multibyte, locale and math support" -TERMUX_PKG_VERSION=21 -TERMUX_PKG_SHA256=e355c822d0891ba610275eac4b13e9b0fb4dd57e8e2891b9fd98d11edc6fd40d +TERMUX_PKG_VERSION=22 +TERMUX_PKG_SHA256=667f20d0821a6305c50c667363486d546b293e846f31d02f559947d50121f51e TERMUX_PKG_SRCURL=https://github.com/termux/libandroid-support/archive/v${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_FOLDERNAME=libandroid-support-$TERMUX_PKG_VERSION TERMUX_PKG_BUILD_IN_SRC=yes @@ -17,11 +17,11 @@ termux_step_make_install () { cp libandroid-support.so $TERMUX_PREFIX/lib/ - (cd $TERMUX_PREFIX/lib; ln -f -s libandroid-support.so libiconv.so; ln -f -s libandroid-support.so libintl.so) + (cd $TERMUX_PREFIX/lib; ln -f -s libandroid-support.so libiconv.so; ) rm -Rf $TERMUX_PREFIX/include/libandroid-support mkdir -p $TERMUX_PREFIX/include/libandroid-support cp -Rf include/* $TERMUX_PREFIX/include/libandroid-support/ - (cd $TERMUX_PREFIX/include; ln -f -s libandroid-support/libintl.h libintl.h; ln -f -s libandroid-support/iconv.h iconv.h) + (cd $TERMUX_PREFIX/include; ln -f -s libandroid-support/iconv.h iconv.h) }