├── m4 ├── configheader.m4 ├── xsize.m4 ├── wchar_t.m4 ├── codeset.m4 ├── glibc2.m4 ├── intldir.m4 ├── glibc21.m4 ├── stdint_h.m4 ├── inttypes_h.m4 ├── uintmax_t.m4 ├── intmax.m4 ├── nls.m4 ├── inttypes-pri.m4 ├── lcmessage.m4 ├── lock.m4 ├── printf-posix.m4 ├── wint_t.m4 ├── intlmacosx.m4 ├── intdiv0.m4 ├── size_max.m4 ├── progtest.m4 ├── visibility.m4 ├── lib-ld.m4 ├── ansi-c++.m4 ├── longlong.m4 ├── fcntl-o.m4 ├── lib-prefix.m4 ├── iconv.m4 ├── intl.m4 ├── threadlib.m4 ├── gettext.m4 └── po.m4 ├── libintl ├── libintl-musl.c └── libintl.c ├── src ├── StringEscape.h ├── autopoint.in ├── poparser.h ├── StringEscape.c ├── xgettext.sh ├── msgmerge.c ├── msgfmt.c └── poparser.c ├── .gitignore ├── create-dist.sh ├── install.sh ├── LICENSE ├── README.md ├── Makefile ├── include └── libintl.h ├── docs ├── msgfmt.txt ├── msgmerge.txt └── xgettext.txt └── data ├── Makevars.template └── autopoint_Makefile.in /m4/configheader.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) 2 | -------------------------------------------------------------------------------- /libintl/libintl-musl.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* trick configure tests checking for gnu libintl, as in the copy included in gdb */ 4 | const char *_nl_expand_alias () { return NULL; } 5 | int _nl_msg_cat_cntr = 0; 6 | -------------------------------------------------------------------------------- /src/StringEscape.h: -------------------------------------------------------------------------------- 1 | #ifndef STRINGESCAPE_H 2 | #define STRINGESCAPE_H 3 | 4 | #include 5 | 6 | size_t escape(char* in, char *out, size_t outsize); 7 | size_t unescape(char* in, char *out, size_t outsize); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.lo 3 | *.a 4 | *.so 5 | config.mak 6 | *~ 7 | msgfmt 8 | msgunfmt 9 | msgcat 10 | msgconv 11 | msggrep 12 | msgfilter 13 | msguniq 14 | msgcomm 15 | msgcmp 16 | msgattrib 17 | msggen 18 | msgexec 19 | autopoint 20 | msgmerge 21 | msginit 22 | gettextize 23 | xgettext 24 | gettext 25 | ngettext 26 | envsubst 27 | -------------------------------------------------------------------------------- /m4/xsize.m4: -------------------------------------------------------------------------------- 1 | # xsize.m4 serial 5 2 | dnl Copyright (C) 2003-2004, 2008-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_XSIZE], 8 | [ 9 | dnl Prerequisites of lib/xsize.h. 10 | AC_REQUIRE([gl_SIZE_MAX]) 11 | AC_CHECK_HEADERS([stdint.h]) 12 | ]) 13 | -------------------------------------------------------------------------------- /create-dist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ -z "$VER" ] ; then 3 | echo set VER! 4 | exit 5 | fi 6 | me=`pwd` 7 | 8 | proj=gettext-tiny 9 | projver=${proj}-${VER} 10 | 11 | tempdir=/tmp/${proj}-0000 12 | rm -rf $tempdir 13 | mkdir -p $tempdir 14 | 15 | cd $tempdir 16 | GITDIR=https://github.com/rofl0r/$proj 17 | GITDIR=$me 18 | git clone "$GITDIR" $projver 19 | rm -rf $projver/.git 20 | rm -rf $projver/docs 21 | rm -f $projver/.gitignore 22 | rm -f $projver/create-dist.sh 23 | 24 | tar cf $proj.tar $projver/ 25 | xz -z -9 -e $proj.tar 26 | mv $proj.tar.xz $me/$projver.tar.xz 27 | -------------------------------------------------------------------------------- /m4/wchar_t.m4: -------------------------------------------------------------------------------- 1 | # wchar_t.m4 serial 4 (gettext-0.18.2) 2 | dnl Copyright (C) 2002-2003, 2008-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | dnl Test whether has the 'wchar_t' type. 9 | dnl Prerequisite: AC_PROG_CC 10 | 11 | AC_DEFUN([gt_TYPE_WCHAR_T], 12 | [ 13 | AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], 14 | [AC_COMPILE_IFELSE( 15 | [AC_LANG_PROGRAM( 16 | [[#include 17 | wchar_t foo = (wchar_t)'\0';]], 18 | [[]])], 19 | [gt_cv_c_wchar_t=yes], 20 | [gt_cv_c_wchar_t=no])]) 21 | if test $gt_cv_c_wchar_t = yes; then 22 | AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.]) 23 | fi 24 | ]) 25 | -------------------------------------------------------------------------------- /m4/codeset.m4: -------------------------------------------------------------------------------- 1 | # codeset.m4 serial 5 (gettext-0.18.2) 2 | dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016 Free Software Foundation, 3 | dnl Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | dnl From Bruno Haible. 9 | 10 | AC_DEFUN([AM_LANGINFO_CODESET], 11 | [ 12 | AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset], 13 | [AC_LINK_IFELSE( 14 | [AC_LANG_PROGRAM( 15 | [[#include ]], 16 | [[char* cs = nl_langinfo(CODESET); return !cs;]])], 17 | [am_cv_langinfo_codeset=yes], 18 | [am_cv_langinfo_codeset=no]) 19 | ]) 20 | if test $am_cv_langinfo_codeset = yes; then 21 | AC_DEFINE([HAVE_LANGINFO_CODESET], [1], 22 | [Define if you have and nl_langinfo(CODESET).]) 23 | fi 24 | ]) 25 | -------------------------------------------------------------------------------- /m4/glibc2.m4: -------------------------------------------------------------------------------- 1 | # glibc2.m4 serial 3 2 | dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2017 Free Software Foundation, 3 | dnl Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | # Test for the GNU C Library, version 2.0 or newer. 9 | # From Bruno Haible. 10 | 11 | AC_DEFUN([gt_GLIBC2], 12 | [ 13 | AC_CACHE_CHECK([whether we are using the GNU C Library 2 or newer], 14 | [ac_cv_gnu_library_2], 15 | [AC_EGREP_CPP([Lucky GNU user], 16 | [ 17 | #include 18 | #ifdef __GNU_LIBRARY__ 19 | #if (__GLIBC__ >= 2) && !defined __UCLIBC__ 20 | Lucky GNU user 21 | #endif 22 | #endif 23 | ], 24 | [ac_cv_gnu_library_2=yes], 25 | [ac_cv_gnu_library_2=no]) 26 | ] 27 | ) 28 | AC_SUBST([GLIBC2]) 29 | GLIBC2="$ac_cv_gnu_library_2" 30 | ] 31 | ) 32 | -------------------------------------------------------------------------------- /m4/intldir.m4: -------------------------------------------------------------------------------- 1 | # intldir.m4 serial 2 (gettext-0.18) 2 | dnl Copyright (C) 2006, 2009-2014, 2016 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | dnl 7 | dnl This file can be used in projects which are not available under 8 | dnl the GNU General Public License or the GNU Library General Public 9 | dnl License but which still want to provide support for the GNU gettext 10 | dnl functionality. 11 | dnl Please note that the actual code of the GNU gettext library is covered 12 | dnl by the GNU Library General Public License, and the rest of the GNU 13 | dnl gettext package is covered by the GNU General Public License. 14 | dnl They are *not* in the public domain. 15 | 16 | AC_PREREQ([2.52]) 17 | 18 | dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory. 19 | AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], []) 20 | -------------------------------------------------------------------------------- /m4/glibc21.m4: -------------------------------------------------------------------------------- 1 | # glibc21.m4 serial 5 2 | dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2017 Free Software Foundation, 3 | dnl Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | # Test for the GNU C Library, version 2.1 or newer, or uClibc. 9 | # From Bruno Haible. 10 | 11 | AC_DEFUN([gl_GLIBC21], 12 | [ 13 | AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc], 14 | [ac_cv_gnu_library_2_1], 15 | [AC_EGREP_CPP([Lucky], 16 | [ 17 | #include 18 | #ifdef __GNU_LIBRARY__ 19 | #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) 20 | Lucky GNU user 21 | #endif 22 | #endif 23 | #ifdef __UCLIBC__ 24 | Lucky user 25 | #endif 26 | ], 27 | [ac_cv_gnu_library_2_1=yes], 28 | [ac_cv_gnu_library_2_1=no]) 29 | ] 30 | ) 31 | AC_SUBST([GLIBC21]) 32 | GLIBC21="$ac_cv_gnu_library_2_1" 33 | ] 34 | ) 35 | -------------------------------------------------------------------------------- /m4/stdint_h.m4: -------------------------------------------------------------------------------- 1 | # stdint_h.m4 serial 9 2 | dnl Copyright (C) 1997-2004, 2006, 2008-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Paul Eggert. 8 | 9 | # Define HAVE_STDINT_H_WITH_UINTMAX if exists, 10 | # doesn't clash with , and declares uintmax_t. 11 | 12 | AC_DEFUN([gl_AC_HEADER_STDINT_H], 13 | [ 14 | AC_CACHE_CHECK([for stdint.h], [gl_cv_header_stdint_h], 15 | [AC_COMPILE_IFELSE( 16 | [AC_LANG_PROGRAM( 17 | [[#include 18 | #include ]], 19 | [[uintmax_t i = (uintmax_t) -1; return !i;]])], 20 | [gl_cv_header_stdint_h=yes], 21 | [gl_cv_header_stdint_h=no])]) 22 | if test $gl_cv_header_stdint_h = yes; then 23 | AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1], 24 | [Define if exists, doesn't clash with , 25 | and declares uintmax_t. ]) 26 | fi 27 | ]) 28 | -------------------------------------------------------------------------------- /m4/inttypes_h.m4: -------------------------------------------------------------------------------- 1 | # inttypes_h.m4 serial 10 2 | dnl Copyright (C) 1997-2004, 2006, 2008-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Paul Eggert. 8 | 9 | # Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, 10 | # doesn't clash with , and declares uintmax_t. 11 | 12 | AC_DEFUN([gl_AC_HEADER_INTTYPES_H], 13 | [ 14 | AC_CACHE_CHECK([for inttypes.h], [gl_cv_header_inttypes_h], 15 | [AC_COMPILE_IFELSE( 16 | [AC_LANG_PROGRAM( 17 | [[ 18 | #include 19 | #include 20 | ]], 21 | [[uintmax_t i = (uintmax_t) -1; return !i;]])], 22 | [gl_cv_header_inttypes_h=yes], 23 | [gl_cv_header_inttypes_h=no])]) 24 | if test $gl_cv_header_inttypes_h = yes; then 25 | AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1], 26 | [Define if exists, doesn't clash with , 27 | and declares uintmax_t. ]) 28 | fi 29 | ]) 30 | -------------------------------------------------------------------------------- /m4/uintmax_t.m4: -------------------------------------------------------------------------------- 1 | # uintmax_t.m4 serial 12 2 | dnl Copyright (C) 1997-2004, 2007-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Paul Eggert. 8 | 9 | AC_PREREQ([2.13]) 10 | 11 | # Define uintmax_t to 'unsigned long' or 'unsigned long long' 12 | # if it is not already defined in or . 13 | 14 | AC_DEFUN([gl_AC_TYPE_UINTMAX_T], 15 | [ 16 | AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) 17 | AC_REQUIRE([gl_AC_HEADER_STDINT_H]) 18 | if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then 19 | AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) 20 | test $ac_cv_type_unsigned_long_long_int = yes \ 21 | && ac_type='unsigned long long' \ 22 | || ac_type='unsigned long' 23 | AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type], 24 | [Define to unsigned long or unsigned long long 25 | if and don't define.]) 26 | else 27 | AC_DEFINE([HAVE_UINTMAX_T], [1], 28 | [Define if you have the 'uintmax_t' type in or .]) 29 | fi 30 | ]) 31 | -------------------------------------------------------------------------------- /m4/intmax.m4: -------------------------------------------------------------------------------- 1 | # intmax.m4 serial 6 (gettext-0.18.2) 2 | dnl Copyright (C) 2002-2005, 2008-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | dnl Test whether the system has the 'intmax_t' type, but don't attempt to 9 | dnl find a replacement if it is lacking. 10 | 11 | AC_DEFUN([gt_TYPE_INTMAX_T], 12 | [ 13 | AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) 14 | AC_REQUIRE([gl_AC_HEADER_STDINT_H]) 15 | AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t], 16 | [AC_COMPILE_IFELSE( 17 | [AC_LANG_PROGRAM( 18 | [[ 19 | #include 20 | #include 21 | #if HAVE_STDINT_H_WITH_UINTMAX 22 | #include 23 | #endif 24 | #if HAVE_INTTYPES_H_WITH_UINTMAX 25 | #include 26 | #endif 27 | ]], 28 | [[intmax_t x = -1; 29 | return !x;]])], 30 | [gt_cv_c_intmax_t=yes], 31 | [gt_cv_c_intmax_t=no])]) 32 | if test $gt_cv_c_intmax_t = yes; then 33 | AC_DEFINE([HAVE_INTMAX_T], [1], 34 | [Define if you have the 'intmax_t' type in or .]) 35 | fi 36 | ]) 37 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Written by Rich Felker, originally as part of musl libc. 4 | # Multi-licensed under MIT, 0BSD, and CC0. 5 | # 6 | # This is an actually-safe install command which installs the new 7 | # file atomically in the new location, rather than overwriting 8 | # existing files. 9 | # 10 | 11 | usage() { 12 | printf "usage: %s [-D] [-l] [-m mode] src dest\n" "$0" 1>&2 13 | exit 1 14 | } 15 | 16 | mkdirp= 17 | symlink= 18 | mode=755 19 | 20 | while getopts Dlm: name ; do 21 | case "$name" in 22 | D) mkdirp=yes ;; 23 | l) symlink=yes ;; 24 | m) mode=$OPTARG ;; 25 | ?) usage ;; 26 | esac 27 | done 28 | shift $(($OPTIND - 1)) 29 | 30 | test "$#" -eq 2 || usage 31 | src=$1 32 | dst=$2 33 | tmp="$dst.tmp.$$" 34 | 35 | case "$dst" in 36 | */) printf "%s: %s ends in /\n", "$0" "$dst" 1>&2 ; exit 1 ;; 37 | esac 38 | 39 | set -C 40 | set -e 41 | 42 | if test "$mkdirp" ; then 43 | umask 022 44 | case "$2" in 45 | */*) mkdir -p "${dst%/*}" ;; 46 | esac 47 | fi 48 | 49 | trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP 50 | 51 | umask 077 52 | 53 | if test "$symlink" ; then 54 | ln -s "$1" "$tmp" 55 | else 56 | cat < "$1" > "$tmp" 57 | chmod "$mode" "$tmp" 58 | fi 59 | 60 | mv -f "$tmp" "$2" 61 | test -d "$2" && { 62 | rm -f "$2/$tmp" 63 | printf "%s: %s is a directory\n" "$0" "$dst" 1>&2 64 | exit 1 65 | } 66 | 67 | exit 0 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2012 rofl0r 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | ------------------------------------------------------------------------------- 23 | 24 | Files contained in the doc/ directory may be licensed under different terms. 25 | If so, it is noted there in the respective file. 26 | -------------------------------------------------------------------------------- /m4/nls.m4: -------------------------------------------------------------------------------- 1 | # nls.m4 serial 5 (gettext-0.18) 2 | dnl Copyright (C) 1995-2003, 2005-2006, 2008-2014, 2016 Free Software 3 | dnl Foundation, Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | dnl 8 | dnl This file can be used in projects which are not available under 9 | dnl the GNU General Public License or the GNU Library General Public 10 | dnl License but which still want to provide support for the GNU gettext 11 | dnl functionality. 12 | dnl Please note that the actual code of the GNU gettext library is covered 13 | dnl by the GNU Library General Public License, and the rest of the GNU 14 | dnl gettext package is covered by the GNU General Public License. 15 | dnl They are *not* in the public domain. 16 | 17 | dnl Authors: 18 | dnl Ulrich Drepper , 1995-2000. 19 | dnl Bruno Haible , 2000-2003. 20 | 21 | AC_PREREQ([2.50]) 22 | 23 | AC_DEFUN([AM_NLS], 24 | [ 25 | AC_MSG_CHECKING([whether NLS is requested]) 26 | dnl Default is enabled NLS 27 | AC_ARG_ENABLE([nls], 28 | [ --disable-nls do not use Native Language Support], 29 | USE_NLS=$enableval, USE_NLS=yes) 30 | AC_MSG_RESULT([$USE_NLS]) 31 | AC_SUBST([USE_NLS]) 32 | ]) 33 | -------------------------------------------------------------------------------- /m4/inttypes-pri.m4: -------------------------------------------------------------------------------- 1 | # inttypes-pri.m4 serial 7 (gettext-0.18.2) 2 | dnl Copyright (C) 1997-2002, 2006, 2008-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | AC_PREREQ([2.53]) 10 | 11 | # Define PRI_MACROS_BROKEN if exists and defines the PRI* 12 | # macros to non-string values. This is the case on AIX 4.3.3. 13 | 14 | AC_DEFUN([gt_INTTYPES_PRI], 15 | [ 16 | AC_CHECK_HEADERS([inttypes.h]) 17 | if test $ac_cv_header_inttypes_h = yes; then 18 | AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], 19 | [gt_cv_inttypes_pri_broken], 20 | [ 21 | AC_COMPILE_IFELSE( 22 | [AC_LANG_PROGRAM( 23 | [[ 24 | #include 25 | #ifdef PRId32 26 | char *p = PRId32; 27 | #endif 28 | ]], 29 | [[]])], 30 | [gt_cv_inttypes_pri_broken=no], 31 | [gt_cv_inttypes_pri_broken=yes]) 32 | ]) 33 | fi 34 | if test "$gt_cv_inttypes_pri_broken" = yes; then 35 | AC_DEFINE_UNQUOTED([PRI_MACROS_BROKEN], [1], 36 | [Define if exists and defines unusable PRI* macros.]) 37 | PRI_MACROS_BROKEN=1 38 | else 39 | PRI_MACROS_BROKEN=0 40 | fi 41 | AC_SUBST([PRI_MACROS_BROKEN]) 42 | ]) 43 | -------------------------------------------------------------------------------- /src/autopoint.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | test "$1" = "--version" && { 3 | echo "autopoint (GNU gettext-tools-compatible) 99.99" 4 | exit 0 5 | } 6 | 7 | m4src=@datadir@/m4 8 | 9 | get_m4_serial() { 10 | sed -n -e '/^#.* serial /s;^#.* serial \([^ ]*\).*;\1;p' "$@" 11 | } 12 | 13 | if ! test -e configure.ac ; then 14 | echo "$0: error: configure.ac not found" >&2 15 | exit 1 16 | fi 17 | 18 | mkdir -p m4 intl po 19 | for i in $m4src/*.m4 ; do 20 | dest="m4/$(basename "$i")" 21 | if test -f "$dest"; then 22 | serial_dest="$(get_m4_serial "$dest")" 23 | serial_gettext="$(get_m4_serial "$i")" 24 | 25 | test "$serial_dest" -ge "$serial_gettext" && continue 26 | fi 27 | 28 | cp -f $i m4/ 29 | done 30 | 31 | dirprefix="" 32 | while read line 33 | do 34 | if [ "${line##*AC_CONFIG_AUX_DIR}" != "$line" ]; then 35 | dirprefix="${line##*'(['}" 36 | dirprefix="${dirprefix%%'])'*}" 37 | mkdir -p "${dirprefix}" 38 | fi 39 | 40 | if [ "${line##*po/Makefile.in}" != "$line" ]; then 41 | poprefix="${line##*'['}" 42 | poprefix="${poprefix%%po/Makefile.in*}" 43 | install -D -m 644 @datadir@/data/autopoint_Makefile.in "./${poprefix}/po/Makefile.in.in" 44 | fi 45 | done < "configure.ac" 46 | 47 | touch "./${dirprefix}/config.rpath" ABOUT-NLS 48 | 49 | for i in intl/Makefile.in po/Makefile.in.in ; do 50 | install -D -m 644 @datadir@/data/autopoint_Makefile.in "$i" 51 | done 52 | 53 | install -D -m 644 @datadir@/data/Makevars.template po/Makevars.template 54 | true 55 | -------------------------------------------------------------------------------- /m4/lcmessage.m4: -------------------------------------------------------------------------------- 1 | # lcmessage.m4 serial 7 (gettext-0.18.2) 2 | dnl Copyright (C) 1995-2002, 2004-2005, 2008-2014, 2016 Free Software 3 | dnl Foundation, Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | dnl 8 | dnl This file can be used in projects which are not available under 9 | dnl the GNU General Public License or the GNU Library General Public 10 | dnl License but which still want to provide support for the GNU gettext 11 | dnl functionality. 12 | dnl Please note that the actual code of the GNU gettext library is covered 13 | dnl by the GNU Library General Public License, and the rest of the GNU 14 | dnl gettext package is covered by the GNU General Public License. 15 | dnl They are *not* in the public domain. 16 | 17 | dnl Authors: 18 | dnl Ulrich Drepper , 1995. 19 | 20 | # Check whether LC_MESSAGES is available in . 21 | 22 | AC_DEFUN([gt_LC_MESSAGES], 23 | [ 24 | AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES], 25 | [AC_LINK_IFELSE( 26 | [AC_LANG_PROGRAM( 27 | [[#include ]], 28 | [[return LC_MESSAGES]])], 29 | [gt_cv_val_LC_MESSAGES=yes], 30 | [gt_cv_val_LC_MESSAGES=no])]) 31 | if test $gt_cv_val_LC_MESSAGES = yes; then 32 | AC_DEFINE([HAVE_LC_MESSAGES], [1], 33 | [Define if your file defines LC_MESSAGES.]) 34 | fi 35 | ]) 36 | -------------------------------------------------------------------------------- /m4/lock.m4: -------------------------------------------------------------------------------- 1 | # lock.m4 serial 14 2 | dnl Copyright (C) 2005-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | AC_DEFUN([gl_LOCK], 10 | [ 11 | AC_REQUIRE([gl_THREADLIB]) 12 | if test "$gl_threads_api" = posix; then 13 | # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the 14 | # pthread_rwlock_* functions. 15 | has_rwlock=false 16 | AC_CHECK_TYPE([pthread_rwlock_t], 17 | [has_rwlock=true 18 | AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], 19 | [Define if the POSIX multithreading library has read/write locks.])], 20 | [], 21 | [#include ]) 22 | if $has_rwlock; then 23 | gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER 24 | fi 25 | # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. 26 | AC_COMPILE_IFELSE([ 27 | AC_LANG_PROGRAM( 28 | [[#include ]], 29 | [[ 30 | #if __FreeBSD__ == 4 31 | error "No, in FreeBSD 4.0 recursive mutexes actually don't work." 32 | #elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \ 33 | && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070) 34 | error "No, in Mac OS X < 10.7 recursive mutexes actually don't work." 35 | #else 36 | int x = (int)PTHREAD_MUTEX_RECURSIVE; 37 | return !x; 38 | #endif 39 | ]])], 40 | [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1], 41 | [Define if the defines PTHREAD_MUTEX_RECURSIVE.])]) 42 | fi 43 | gl_PREREQ_LOCK 44 | ]) 45 | 46 | # Prerequisites of lib/glthread/lock.c. 47 | AC_DEFUN([gl_PREREQ_LOCK], [:]) 48 | -------------------------------------------------------------------------------- /m4/printf-posix.m4: -------------------------------------------------------------------------------- 1 | # printf-posix.m4 serial 6 (gettext-0.18.2) 2 | dnl Copyright (C) 2003, 2007, 2009-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | dnl Test whether the printf() function supports POSIX/XSI format strings with 9 | dnl positions. 10 | 11 | AC_DEFUN([gt_PRINTF_POSIX], 12 | [ 13 | AC_REQUIRE([AC_PROG_CC]) 14 | AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings], 15 | gt_cv_func_printf_posix, 16 | [ 17 | AC_RUN_IFELSE( 18 | [AC_LANG_SOURCE([[ 19 | #include 20 | #include 21 | /* The string "%2$d %1$d", with dollar characters protected from the shell's 22 | dollar expansion (possibly an autoconf bug). */ 23 | static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; 24 | static char buf[100]; 25 | int main () 26 | { 27 | sprintf (buf, format, 33, 55); 28 | return (strcmp (buf, "55 33") != 0); 29 | }]])], 30 | [gt_cv_func_printf_posix=yes], 31 | [gt_cv_func_printf_posix=no], 32 | [ 33 | AC_EGREP_CPP([notposix], [ 34 | #if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ 35 | notposix 36 | #endif 37 | ], 38 | [gt_cv_func_printf_posix="guessing no"], 39 | [gt_cv_func_printf_posix="guessing yes"]) 40 | ]) 41 | ]) 42 | case $gt_cv_func_printf_posix in 43 | *yes) 44 | AC_DEFINE([HAVE_POSIX_PRINTF], [1], 45 | [Define if your printf() function supports format strings with positions.]) 46 | ;; 47 | esac 48 | ]) 49 | -------------------------------------------------------------------------------- /libintl/libintl.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2003 Manuel Novoa III 2 | * Copyright (C) 2000-2006 Erik Andersen 3 | * 4 | * Trivial Stubs, Public Domain. 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | char *gettext(const char *msgid) 12 | { 13 | return (char *) msgid; 14 | } 15 | 16 | char *dgettext(const char *domainname, const char *msgid) 17 | { 18 | (void) domainname; 19 | return (char *) msgid; 20 | } 21 | 22 | char *dcgettext(const char *domainname, const char *msgid, int category) 23 | { 24 | (void) domainname; 25 | (void) category; 26 | return (char *) msgid; 27 | } 28 | 29 | char *ngettext(const char *msgid1, const char *msgid2, unsigned long n) 30 | { 31 | return (char *) ((n == 1) ? msgid1 : msgid2); 32 | } 33 | 34 | char *dngettext(const char *domainname, const char *msgid1, const char *msgid2, unsigned long n) 35 | { 36 | (void) domainname; 37 | return (char *) ((n == 1) ? msgid1 : msgid2); 38 | } 39 | 40 | char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2, unsigned long n, int category) 41 | { 42 | (void) domainname; 43 | (void) category; 44 | return (char *) ((n == 1) ? msgid1 : msgid2); 45 | } 46 | 47 | char *textdomain(const char *domainname) 48 | { 49 | static const char default_str[] = "messages"; 50 | 51 | if (domainname && *domainname && strcmp(domainname, default_str)) { 52 | errno = EINVAL; 53 | return NULL; 54 | } 55 | return (char *) default_str; 56 | } 57 | 58 | char *bindtextdomain(const char *domainname, const char *dirname) 59 | { 60 | static const char dir[] = "/"; 61 | 62 | if (!domainname || !*domainname 63 | || (dirname && ((dirname[0] != '/') || dirname[1])) 64 | ) { 65 | errno = EINVAL; 66 | return NULL; 67 | } 68 | 69 | return (char *) dir; 70 | } 71 | 72 | char *bind_textdomain_codeset(const char *domainname, const char *codeset) 73 | { 74 | if (!domainname || !*domainname || (codeset && strcasecmp(codeset, "UTF-8"))) { 75 | errno = EINVAL; 76 | return NULL; 77 | } 78 | return codeset; 79 | } 80 | 81 | /* trick configure tests checking for gnu libintl, as in the copy included in gdb */ 82 | const char *_nl_expand_alias () { return NULL; } 83 | int _nl_msg_cat_cntr = 0; 84 | -------------------------------------------------------------------------------- /src/poparser.h: -------------------------------------------------------------------------------- 1 | #ifndef POPARSER_H 2 | #define POPARSER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define MAX_NPLURALS 6 9 | 10 | enum sysdep_types { 11 | st_priu32 = 0, 12 | st_priu64, 13 | st_priumax, 14 | st_max 15 | }; 16 | 17 | // make sure out has equal or more space than in 18 | // this add the NULL terminator, but do not count it in size 19 | size_t poparser_sysdep(const char *in, char *out, int num); 20 | 21 | struct po_header { 22 | char charset[12]; 23 | unsigned nplurals; 24 | // maybe parse the header later 25 | }; 26 | 27 | #define PO_FUZZY 1u 28 | 29 | struct po_message { 30 | char *ctxt; 31 | char *id; 32 | char *plural; 33 | char* str[MAX_NPLURALS]; 34 | 35 | int sysdep; 36 | size_t ctxt_len; 37 | size_t id_len; 38 | size_t plural_len; 39 | size_t strlen[MAX_NPLURALS]; 40 | // h.......1.0 41 | // |-------|a| 42 | // |.......|a| 43 | int flags; 44 | }; 45 | typedef struct po_message *po_message_t; 46 | 47 | typedef int (*poparser_callback)(po_message_t msg, void* user); 48 | 49 | enum po_stage { 50 | // collect size of every msg 51 | ps_size = 0, 52 | // parse 53 | ps_parse, 54 | ps_max = ps_parse, 55 | }; 56 | 57 | enum po_entry { 58 | po_ctxt = 0, 59 | po_id, 60 | po_plural, 61 | po_str, 62 | }; 63 | 64 | struct po_parser { 65 | struct po_header hdr; 66 | struct po_message msg; 67 | enum po_stage stage; 68 | 69 | // private parts 70 | bool first; 71 | bool strict; 72 | iconv_t cd; 73 | enum po_entry previous; 74 | unsigned strcnt; 75 | size_t max_ctxt_len; 76 | size_t max_id_len; 77 | size_t max_plural_len; 78 | size_t max_strlen[MAX_NPLURALS]; 79 | char *buf; 80 | size_t bufsize; 81 | poparser_callback cb; 82 | void *cbdata; 83 | }; 84 | 85 | enum po_error { 86 | po_success = 0, 87 | po_unsupported_charset, 88 | po_failed_iconv, 89 | po_excepted_token, 90 | po_plurals_overflow, 91 | po_invalid_entry, 92 | po_internal, 93 | po_error_last = po_internal, 94 | }; 95 | 96 | void poparser_init(struct po_parser *p, char* workbuf, size_t bufsize, poparser_callback cb, void* cbdata); 97 | enum po_error poparser_feed_line(struct po_parser *p, char* line, size_t buflen); 98 | enum po_error poparser_finish(struct po_parser *p); 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Intro 2 | gettext-tiny provides lightweight replacements for tools typically used 3 | from the `GNU gettext` suite, which is incredibly bloated and takes 4 | a lot of time to build (in the order of an hour on slow devices). 5 | the most notable component is `msgfmt` which is used to create binary 6 | translation files in the `.mo` format out of textual input files in 7 | `.po` format. this is the most important tool for building software from 8 | source, because it is used from the build processes of many software packages. 9 | 10 | our `msgfmt` implementation was initially a fake implementation that would 11 | just output the english input string as the translation, which is sufficient 12 | to get software to work, but it has since grown into a complete implementation. 13 | unlike the GNU implementation, it can even expand input strings containing 14 | so-called `sysdep` strings into a constant translation table. 15 | `sysdep` strings were glued as an after-thought onto the GNU implementation to 16 | deal with system-specific format strings, and in the GNU implementation those 17 | are created at runtime, which requires mapping the entire `.mo` file into 18 | read/write memory locations, thereby wasting precious RAM for read-only data 19 | that could otherwise be shared among processes. 20 | 21 | other parts of gettext-tiny such as `xgettext` and `msgmerge` are still stubs, 22 | but they are sufficient to build many packages. 23 | 24 | since `musl` libc, our preferred target, didn't provide a `libintl` in the past, 25 | (and it's also part of `GNU gettext`) we also ship a no-op libintl providing 26 | a header and a library. 27 | 28 | it comes in two flavours: 29 | 30 | 1) nop: gettext functions just return the input string as translation 31 | 2) musl: a compat library providing a few compatibility symbols meant to be used 32 | together with the libintl built-in into recent musl versions. 33 | the compatibility symbols help to get past configure scripts that insist on 34 | using only the GNU gettext suite. 35 | additionally, it can be entirely disabled. 36 | 37 | 38 | # Compilation/Installation 39 | 40 | ``` 41 | make LIBINTL=FLAVOR 42 | make LIBINTL=FLAVOR DESTDIR=pkgdir prefix=/ install 43 | ``` 44 | 45 | where FLAVOR can be one of NONE, MUSL, NOOP (as detailed above). 46 | you can override any variables used in the Makefile (such as `CFLAGS`) by 47 | appending them to the `make` invocation, or by saving them into a file called 48 | `config.mak` before running `make`. 49 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | prefix=/usr/local 2 | bindir=$(prefix)/bin 3 | includedir=$(prefix)/include 4 | libdir=$(prefix)/lib 5 | sysconfdir=$(prefix)/etc 6 | datarootdir=$(prefix)/share 7 | datadir=$(datarootdir)/gettext-tiny 8 | acdir=$(datarootdir)/aclocal 9 | 10 | ifeq ($(LIBINTL), MUSL) 11 | LIBSRC = libintl/libintl-musl.c 12 | HEADERS = 13 | else ifeq ($(LIBINTL), NONE) 14 | LIBSRC = 15 | HEADERS = 16 | else 17 | LIBSRC = libintl/libintl.c 18 | HEADERS = libintl.h 19 | endif 20 | PROGSRC = $(sort $(wildcard src/*.c)) 21 | 22 | PARSEROBJS = src/poparser.o src/StringEscape.o 23 | PROGOBJS = $(PROGSRC:.c=.o) 24 | LIBOBJS = $(LIBSRC:.c=.o) 25 | OBJS = $(PROGOBJS) $(LIBOBJS) 26 | 27 | ALL_INCLUDES = $(HEADERS) 28 | ifneq ($(LIBINTL), NONE) 29 | ALL_LIBS=libintl.a 30 | endif 31 | ALL_TOOLS=msgfmt msgmerge xgettext autopoint 32 | ALL_M4S=$(sort $(wildcard m4/*.m4)) 33 | ALL_DATA=$(sort $(wildcard data/*)) 34 | 35 | CFLAGS ?= -O0 -fPIC 36 | 37 | AR ?= $(CROSS_COMPILE)ar 38 | RANLIB ?= $(CROSS_COMPILE)ranlib 39 | CC ?= $(CROSS_COMPILE)cc 40 | 41 | INSTALL ?= ./install.sh 42 | 43 | -include config.mak 44 | 45 | LDLIBS:=$(shell echo "int main(){}" | $(CC) $(CFLAGS) $(LDFLAGS) -liconv -x c - >/dev/null 2>&1 && printf %s -liconv) 46 | 47 | BUILDCFLAGS=$(CFLAGS) 48 | 49 | all: $(ALL_LIBS) $(ALL_TOOLS) 50 | 51 | install: $(ALL_LIBS:lib%=$(DESTDIR)$(libdir)/lib%) $(ALL_INCLUDES:%=$(DESTDIR)$(includedir)/%) $(ALL_TOOLS:%=$(DESTDIR)$(bindir)/%) $(ALL_M4S:%=$(DESTDIR)$(datadir)/%) $(ALL_M4S:%=$(DESTDIR)$(acdir)/%) $(ALL_DATA:%=$(DESTDIR)$(datadir)/%) 52 | 53 | clean: 54 | rm -f $(ALL_LIBS) 55 | rm -f $(OBJS) 56 | rm -f $(ALL_TOOLS) 57 | 58 | %.o: %.c 59 | $(CC) $(BUILDCFLAGS) -c -o $@ $< 60 | 61 | libintl.a: $(LIBOBJS) 62 | rm -f $@ 63 | $(AR) rc $@ $(LIBOBJS) 64 | $(RANLIB) $@ 65 | 66 | msgmerge: $(OBJS) 67 | $(CC) -o $@ src/msgmerge.o $(PARSEROBJS) $(LDFLAGS) $(LDLIBS) 68 | 69 | msgfmt: $(OBJS) 70 | $(CC) -o $@ src/msgfmt.o $(PARSEROBJS) $(LDFLAGS) $(LDLIBS) 71 | 72 | xgettext: 73 | cp src/xgettext.sh ./xgettext 74 | 75 | autopoint: src/autopoint.in 76 | cat $< | sed 's,@datadir@,$(datadir),' > $@ 77 | 78 | $(DESTDIR)$(libdir)/%.a: %.a 79 | $(INSTALL) -D -m 755 $< $@ 80 | 81 | $(DESTDIR)$(includedir)/%.h: include/%.h 82 | $(INSTALL) -D -m 644 $< $@ 83 | 84 | $(DESTDIR)$(bindir)/%: % 85 | $(INSTALL) -D -m 755 $< $@ 86 | 87 | $(DESTDIR)$(datadir)/%: % 88 | $(INSTALL) -D -m 644 $< $@ 89 | 90 | $(DESTDIR)$(acdir)/%: % 91 | $(INSTALL) -D -l ../$(subst $(datarootdir)/,,$(datadir))/$< $(patsubst %m4/,%,$(dir $@))/$(notdir $@) 92 | 93 | .PHONY: all clean install 94 | -------------------------------------------------------------------------------- /src/StringEscape.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | //FIXME out gets silently truncated if outsize is too small 6 | 7 | size_t escape(char* in, char* out, size_t outsize) { 8 | size_t l = 0; 9 | while(*in && l + 3 < outsize) { 10 | switch(*in) { 11 | case '\n': 12 | *out++ = '\\'; 13 | l++; 14 | *out = 'n'; 15 | break; 16 | case '\r': 17 | *out++ = '\\'; 18 | l++; 19 | *out = 'r'; 20 | break; 21 | case '\t': 22 | *out++ = '\\'; 23 | l++; 24 | *out = 't'; 25 | break; 26 | case '\\': 27 | *out++ = '\\'; 28 | l++; 29 | *out = '\\'; 30 | break; 31 | case '"': 32 | *out++ = '\\'; 33 | l++; 34 | *out = '"'; 35 | break; 36 | case '\v': 37 | *out++ = '\\'; 38 | l++; 39 | *out = 'v'; 40 | break; 41 | case '\?': 42 | *out++ = '\\'; 43 | l++; 44 | *out = '?'; 45 | break; 46 | case '\f': 47 | *out++ = '\\'; 48 | l++; 49 | *out = 'f'; 50 | break; 51 | case '\b': 52 | *out++ = '\\'; 53 | l++; 54 | *out = 'b'; 55 | break; 56 | case '\a': 57 | *out++ = '\\'; 58 | l++; 59 | *out = 'a'; 60 | break; 61 | default: 62 | *out = *in; 63 | } 64 | in++; 65 | out++; 66 | l++; 67 | } 68 | *out = 0; 69 | return l; 70 | } 71 | 72 | size_t unescape(char* in, char *out, size_t outsize) { 73 | size_t l = 0; 74 | while(*in && l + 1 < outsize) { 75 | switch (*in) { 76 | case '\\': 77 | ++in; 78 | assert(*in); 79 | switch(*in) { 80 | case 'n': 81 | *out='\n'; 82 | break; 83 | case 'r': 84 | *out='\r'; 85 | break; 86 | case 't': 87 | *out='\t'; 88 | break; 89 | case '\\': 90 | *out='\\'; 91 | break; 92 | case '"': 93 | *out='"'; 94 | break; 95 | case 'v': 96 | *out='\v'; 97 | break; 98 | case '?': 99 | *out = '\?'; 100 | break; 101 | case 'f': 102 | *out = '\f'; 103 | break; 104 | case '\'': 105 | *out = '\''; 106 | break; 107 | case 'b': 108 | *out = '\b'; 109 | break; 110 | case 'a': 111 | *out = '\a'; 112 | break; 113 | // FIXME add handling of hex and octal 114 | default: 115 | abort(); 116 | } 117 | break; 118 | default: 119 | *out=*in; 120 | } 121 | in++; 122 | out++; 123 | l++; 124 | } 125 | *out = 0; 126 | return l; 127 | } 128 | -------------------------------------------------------------------------------- /src/xgettext.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | outputfile= 3 | outputdir= 4 | domain=messages 5 | 6 | spliteq() { 7 | arg=$1 8 | echo "${arg#*=}" 9 | #alternatives echo "$arg" | cut -d= -f2- 10 | # or echo "$arg" | sed 's/[^=]*=//' 11 | } 12 | 13 | syntax() { 14 | printf "%s\n" "Usage: xgettext [OPTION] [INPUTFILE]..." 15 | exit 1 16 | } 17 | 18 | show_version() { 19 | printf "%s\n" "xgettext (GNU gettext-tools-compatible) 99.99" 20 | exit 0 21 | } 22 | 23 | while [ $# -gt 0 ] ; do 24 | case $1 in 25 | #--files-from=*) readfile `spliteq "$1"`;; 26 | #-f) expectfilefrom=1;; 27 | --version) show_version;; 28 | -V) show_version;; 29 | --default-domain=*) domain=`spliteq "$1"` ;; 30 | -d) shift ; domain="$1" ;; 31 | --files-from=*) : ;; 32 | -f) shift ;; 33 | --directory=*) : ;; 34 | -D) shift ;; 35 | -o) shift ; outputfile="$1" ;; 36 | --output=*) outputfile=`spliteq "$1"` ;; 37 | --output-dir=*) outputdir=`spliteq "$1"` ;; 38 | -p) shift ; outputdir=`spliteq "$1"` ;; 39 | --language=*) : ;; 40 | -L) shift ;; 41 | --C) : ;; 42 | --c++) : ;; 43 | --from-code=*) : ;; 44 | --join-existing) : ;; 45 | -j) : ;; 46 | --exclude-file=*) : ;; 47 | -x) shift;; 48 | --add-comments=*) : ;; 49 | -cTAG) shift;; 50 | --add-comments) : ;; 51 | -c) : ;; 52 | --extract-all) : ;; 53 | -a) : ;; 54 | --keyword=*) : ;; 55 | -k*) : ;; 56 | --keyword) : ;; 57 | -k) : ;; 58 | --flag=*) : ;; 59 | --trigraphs) : ;; 60 | -T) : ;; 61 | --qt) : ;; 62 | --kde) : ;; 63 | --boost) : ;; 64 | --debug) : ;; 65 | --color) : ;; 66 | --color=*) : ;; 67 | --style=*) : ;; 68 | --no-escape) : ;; 69 | -e) : ;; 70 | --escape) : ;; 71 | -E) : ;; 72 | --force-po) force=1 ;; 73 | --indent) : ;; 74 | -i) : ;; 75 | --no-location) : ;; 76 | --add-location) : ;; 77 | -n) : ;; 78 | --strict) : ;; 79 | --properties-output) : ;; 80 | --stringtable-output) : ;; 81 | --width=*) : ;; 82 | -w) : ;; 83 | --no-wrap) : ;; 84 | --sort-output) : ;; 85 | -s) : ;; 86 | --sort-by-file) : ;; 87 | -F) : ;; 88 | --omit-header) : ;; 89 | --copyright-holder=*) : ;; 90 | --foreign-user) : ;; 91 | --package-name=*) : ;; 92 | --package-version=*) : ;; 93 | --msgid-bugs-address=*) : ;; 94 | --msgstr-prefix*) : ;; 95 | -m*) : ;; 96 | --msgstr-suffix*) : ;; 97 | -M*) : ;; 98 | --help) syntax ;; 99 | -h) syntax ;; 100 | esac 101 | shift 102 | done 103 | 104 | [ "$outputfile" = "-" ] && exit 0 105 | [ -z "$outputfile" ] && outputfile=${domain}.po 106 | 107 | if [ -z "$outputdir" ]; then 108 | touch $outputfile 109 | else 110 | touch $outputdir/$outputfile 111 | fi 112 | -------------------------------------------------------------------------------- /m4/wint_t.m4: -------------------------------------------------------------------------------- 1 | # wint_t.m4 serial 6 2 | dnl Copyright (C) 2003, 2007-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | dnl Test whether has the 'wint_t' type and whether gnulib's 9 | dnl or would, if present, override 'wint_t'. 10 | dnl Prerequisite: AC_PROG_CC 11 | 12 | AC_DEFUN([gt_TYPE_WINT_T], 13 | [ 14 | AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], 15 | [AC_COMPILE_IFELSE( 16 | [AC_LANG_PROGRAM( 17 | [[ 18 | /* Tru64 with Desktop Toolkit C has a bug: must be included before 19 | . 20 | BSD/OS 4.0.1 has a bug: , and must be included 21 | before . */ 22 | #include 23 | #include 24 | #include 25 | #include 26 | wint_t foo = (wchar_t)'\0';]], 27 | [[]])], 28 | [gt_cv_c_wint_t=yes], 29 | [gt_cv_c_wint_t=no])]) 30 | if test $gt_cv_c_wint_t = yes; then 31 | AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.]) 32 | 33 | dnl Determine whether gnulib's or would, if present, 34 | dnl override 'wint_t'. 35 | AC_CACHE_CHECK([whether wint_t is too small], 36 | [gl_cv_type_wint_t_too_small], 37 | [AC_COMPILE_IFELSE( 38 | [AC_LANG_PROGRAM([[ 39 | /* Tru64 with Desktop Toolkit C has a bug: must be included before 40 | . 41 | BSD/OS 4.0.1 has a bug: , and must be 42 | included before . */ 43 | #if !(defined __GLIBC__ && !defined __UCLIBC__) 44 | # include 45 | # include 46 | # include 47 | #endif 48 | #include 49 | int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1]; 50 | ]])], 51 | [gl_cv_type_wint_t_too_small=no], 52 | [gl_cv_type_wint_t_too_small=yes])]) 53 | if test $gl_cv_type_wint_t_too_small = yes; then 54 | GNULIB_OVERRIDES_WINT_T=1 55 | else 56 | GNULIB_OVERRIDES_WINT_T=0 57 | fi 58 | else 59 | GNULIB_OVERRIDES_WINT_T=0 60 | fi 61 | AC_SUBST([GNULIB_OVERRIDES_WINT_T]) 62 | ]) 63 | 64 | dnl Prerequisites of the 'wint_t' override. 65 | AC_DEFUN([gl_TYPE_WINT_T_PREREQ], 66 | [ 67 | AC_CHECK_HEADERS_ONCE([crtdefs.h]) 68 | if test $ac_cv_header_crtdefs_h = yes; then 69 | HAVE_CRTDEFS_H=1 70 | else 71 | HAVE_CRTDEFS_H=0 72 | fi 73 | AC_SUBST([HAVE_CRTDEFS_H]) 74 | ]) 75 | -------------------------------------------------------------------------------- /m4/intlmacosx.m4: -------------------------------------------------------------------------------- 1 | # intlmacosx.m4 serial 5 (gettext-0.18.2) 2 | dnl Copyright (C) 2004-2014, 2016 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | dnl 7 | dnl This file can be used in projects which are not available under 8 | dnl the GNU General Public License or the GNU Library General Public 9 | dnl License but which still want to provide support for the GNU gettext 10 | dnl functionality. 11 | dnl Please note that the actual code of the GNU gettext library is covered 12 | dnl by the GNU Library General Public License, and the rest of the GNU 13 | dnl gettext package is covered by the GNU General Public License. 14 | dnl They are *not* in the public domain. 15 | 16 | dnl Checks for special options needed on Mac OS X. 17 | dnl Defines INTL_MACOSX_LIBS. 18 | AC_DEFUN([gt_INTL_MACOSX], 19 | [ 20 | dnl Check for API introduced in Mac OS X 10.2. 21 | AC_CACHE_CHECK([for CFPreferencesCopyAppValue], 22 | [gt_cv_func_CFPreferencesCopyAppValue], 23 | [gt_save_LIBS="$LIBS" 24 | LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" 25 | AC_LINK_IFELSE( 26 | [AC_LANG_PROGRAM( 27 | [[#include ]], 28 | [[CFPreferencesCopyAppValue(NULL, NULL)]])], 29 | [gt_cv_func_CFPreferencesCopyAppValue=yes], 30 | [gt_cv_func_CFPreferencesCopyAppValue=no]) 31 | LIBS="$gt_save_LIBS"]) 32 | if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then 33 | AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1], 34 | [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) 35 | fi 36 | dnl Check for API introduced in Mac OS X 10.3. 37 | AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent], 38 | [gt_save_LIBS="$LIBS" 39 | LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" 40 | AC_LINK_IFELSE( 41 | [AC_LANG_PROGRAM( 42 | [[#include ]], 43 | [[CFLocaleCopyCurrent();]])], 44 | [gt_cv_func_CFLocaleCopyCurrent=yes], 45 | [gt_cv_func_CFLocaleCopyCurrent=no]) 46 | LIBS="$gt_save_LIBS"]) 47 | if test $gt_cv_func_CFLocaleCopyCurrent = yes; then 48 | AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1], 49 | [Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) 50 | fi 51 | INTL_MACOSX_LIBS= 52 | if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then 53 | INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" 54 | fi 55 | AC_SUBST([INTL_MACOSX_LIBS]) 56 | ]) 57 | -------------------------------------------------------------------------------- /m4/intdiv0.m4: -------------------------------------------------------------------------------- 1 | # intdiv0.m4 serial 6 (gettext-0.18.2) 2 | dnl Copyright (C) 2002, 2007-2008, 2010-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | AC_DEFUN([gt_INTDIV0], 10 | [ 11 | AC_REQUIRE([AC_PROG_CC])dnl 12 | AC_REQUIRE([AC_CANONICAL_HOST])dnl 13 | 14 | AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], 15 | gt_cv_int_divbyzero_sigfpe, 16 | [ 17 | gt_cv_int_divbyzero_sigfpe= 18 | changequote(,)dnl 19 | case "$host_os" in 20 | macos* | darwin[6-9]* | darwin[1-9][0-9]*) 21 | # On Mac OS X 10.2 or newer, just assume the same as when cross- 22 | # compiling. If we were to perform the real test, 1 Crash Report 23 | # dialog window would pop up. 24 | case "$host_cpu" in 25 | i[34567]86 | x86_64) 26 | gt_cv_int_divbyzero_sigfpe="guessing yes" ;; 27 | esac 28 | ;; 29 | esac 30 | changequote([,])dnl 31 | if test -z "$gt_cv_int_divbyzero_sigfpe"; then 32 | AC_RUN_IFELSE( 33 | [AC_LANG_SOURCE([[ 34 | #include 35 | #include 36 | 37 | static void 38 | sigfpe_handler (int sig) 39 | { 40 | /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ 41 | _exit (sig != SIGFPE); 42 | } 43 | 44 | int x = 1; 45 | int y = 0; 46 | int z; 47 | int nan; 48 | 49 | int main () 50 | { 51 | signal (SIGFPE, sigfpe_handler); 52 | /* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ 53 | #if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) 54 | signal (SIGTRAP, sigfpe_handler); 55 | #endif 56 | /* Linux/SPARC yields signal SIGILL. */ 57 | #if defined (__sparc__) && defined (__linux__) 58 | signal (SIGILL, sigfpe_handler); 59 | #endif 60 | 61 | z = x / y; 62 | nan = y / y; 63 | exit (2); 64 | } 65 | ]])], 66 | [gt_cv_int_divbyzero_sigfpe=yes], 67 | [gt_cv_int_divbyzero_sigfpe=no], 68 | [ 69 | # Guess based on the CPU. 70 | changequote(,)dnl 71 | case "$host_cpu" in 72 | alpha* | i[34567]86 | x86_64 | m68k | s390*) 73 | gt_cv_int_divbyzero_sigfpe="guessing yes";; 74 | *) 75 | gt_cv_int_divbyzero_sigfpe="guessing no";; 76 | esac 77 | changequote([,])dnl 78 | ]) 79 | fi 80 | ]) 81 | case "$gt_cv_int_divbyzero_sigfpe" in 82 | *yes) value=1;; 83 | *) value=0;; 84 | esac 85 | AC_DEFINE_UNQUOTED([INTDIV0_RAISES_SIGFPE], [$value], 86 | [Define if integer division by zero raises signal SIGFPE.]) 87 | ]) 88 | -------------------------------------------------------------------------------- /include/libintl.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBINTL_H 2 | #define LIBINTL_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #if __GNUC__ + 0 >= 3 9 | # define GETTEXT_INTERNAL_FA(n) __attribute__ ((__format_arg__ (n))) 10 | #else 11 | # define GETTEXT_INTERNAL_FA(n) 12 | #endif 13 | 14 | char *gettext(const char *msgid) 15 | GETTEXT_INTERNAL_FA(1); 16 | char *dgettext(const char *domainname, const char *msgid) 17 | GETTEXT_INTERNAL_FA(2); 18 | char *dcgettext(const char *domainname, const char *msgid, int category) 19 | GETTEXT_INTERNAL_FA(2); 20 | char *ngettext(const char *msgid1, const char *msgid2, unsigned long n) 21 | GETTEXT_INTERNAL_FA(1) GETTEXT_INTERNAL_FA(2); 22 | char *dngettext(const char *domainname, const char *msgid1, const char *msgid2, unsigned long n) 23 | GETTEXT_INTERNAL_FA(2) GETTEXT_INTERNAL_FA(3); 24 | char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2, unsigned long n, int category) 25 | GETTEXT_INTERNAL_FA(2) GETTEXT_INTERNAL_FA(3); 26 | 27 | char *textdomain(const char *domainname); 28 | char *bind_textdomain_codeset(const char *domainname, const char *codeset); 29 | char *bindtextdomain(const char *domainname, const char *dirname); 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #undef gettext_noop 35 | #define gettext_noop(X) X 36 | 37 | #ifndef LIBINTL_NO_MACROS 38 | /* if these macros are defined, configure checks will detect libintl as 39 | * built into the libc because test programs will work without -lintl. 40 | * for example: 41 | * checking for ngettext in libc ... yes 42 | * the consequence is that -lintl will not be added to the LDFLAGS. 43 | * so if for some reason you want that libintl.a gets linked, 44 | * add -DLIBINTL_NO_MACROS=1 to your CPPFLAGS. */ 45 | 46 | #define gettext(X) ((char*) (X)) 47 | #define dgettext(dom, X) ((void)(dom), (char*) (X)) 48 | #define dcgettext(dom, X, cat) ((void)(dom), (void)(cat), (char*) (X)) 49 | #define ngettext(X, Y, N) \ 50 | ((char*) (((N) == 1) ? ((void)(Y), (X)) : ((void)(X), (Y)))) 51 | #define dngettext(dom, X, Y, N) \ 52 | ((dom), (char*) (((N) == 1) ? ((void)(Y), (X)) : ((void)(X), (Y)))) 53 | #define dcngettext(dom, X, Y, N, cat) \ 54 | ((dom), (cat), (char*) (((N) == 1) ? ((void)(Y), (X)) : ((void)(X), (Y)))) 55 | #define bindtextdomain(X, Y) ((void)(X), (void)(Y), (char*) "/") 56 | #define bind_textdomain_codeset(dom, codeset) \ 57 | ((void)(dom), (void)(codeset), (char*) 0) 58 | #define textdomain(X) ((void)(X), (char*) "messages") 59 | 60 | #undef ENABLE_NLS 61 | #undef DISABLE_NLS 62 | #define DISABLE_NLS 1 63 | 64 | #if __GNUC__ +0 > 3 65 | /* most ppl call bindtextdomain() without using its return value 66 | thus we get tons of warnings about "statement with no effect" */ 67 | #pragma GCC diagnostic ignored "-Wunused-value" 68 | #endif 69 | 70 | #endif 71 | 72 | #include 73 | #define gettext_printf(args...) printf(args) 74 | 75 | /* to supply LC_MESSAGES and other stuff GNU expects to be exported when 76 | including libintl.h */ 77 | #include 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /m4/size_max.m4: -------------------------------------------------------------------------------- 1 | # size_max.m4 serial 10 2 | dnl Copyright (C) 2003, 2005-2006, 2008-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | AC_DEFUN([gl_SIZE_MAX], 10 | [ 11 | AC_CHECK_HEADERS([stdint.h]) 12 | dnl First test whether the system already has SIZE_MAX. 13 | AC_CACHE_CHECK([for SIZE_MAX], [gl_cv_size_max], [ 14 | gl_cv_size_max= 15 | AC_EGREP_CPP([Found it], [ 16 | #include 17 | #if HAVE_STDINT_H 18 | #include 19 | #endif 20 | #ifdef SIZE_MAX 21 | Found it 22 | #endif 23 | ], [gl_cv_size_max=yes]) 24 | if test -z "$gl_cv_size_max"; then 25 | dnl Define it ourselves. Here we assume that the type 'size_t' is not wider 26 | dnl than the type 'unsigned long'. Try hard to find a definition that can 27 | dnl be used in a preprocessor #if, i.e. doesn't contain a cast. 28 | AC_COMPUTE_INT([size_t_bits_minus_1], [sizeof (size_t) * CHAR_BIT - 1], 29 | [#include 30 | #include ], [size_t_bits_minus_1=]) 31 | AC_COMPUTE_INT([fits_in_uint], [sizeof (size_t) <= sizeof (unsigned int)], 32 | [#include ], [fits_in_uint=]) 33 | if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then 34 | if test $fits_in_uint = 1; then 35 | dnl Even though SIZE_MAX fits in an unsigned int, it must be of type 36 | dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'. 37 | AC_COMPILE_IFELSE( 38 | [AC_LANG_PROGRAM( 39 | [[#include 40 | extern size_t foo; 41 | extern unsigned long foo; 42 | ]], 43 | [[]])], 44 | [fits_in_uint=0]) 45 | fi 46 | dnl We cannot use 'expr' to simplify this expression, because 'expr' 47 | dnl works only with 'long' integers in the host environment, while we 48 | dnl might be cross-compiling from a 32-bit platform to a 64-bit platform. 49 | if test $fits_in_uint = 1; then 50 | gl_cv_size_max="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)" 51 | else 52 | gl_cv_size_max="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)" 53 | fi 54 | else 55 | dnl Shouldn't happen, but who knows... 56 | gl_cv_size_max='((size_t)~(size_t)0)' 57 | fi 58 | fi 59 | ]) 60 | if test "$gl_cv_size_max" != yes; then 61 | AC_DEFINE_UNQUOTED([SIZE_MAX], [$gl_cv_size_max], 62 | [Define as the maximum value of type 'size_t', if the system doesn't define it.]) 63 | fi 64 | dnl Don't redefine SIZE_MAX in config.h if config.h is re-included after 65 | dnl . Remember that the #undef in AH_VERBATIM gets replaced with 66 | dnl #define by AC_DEFINE_UNQUOTED. 67 | AH_VERBATIM([SIZE_MAX], 68 | [/* Define as the maximum value of type 'size_t', if the system doesn't define 69 | it. */ 70 | #ifndef SIZE_MAX 71 | # undef SIZE_MAX 72 | #endif]) 73 | ]) 74 | 75 | dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in. 76 | dnl Remove this when we can assume autoconf >= 2.61. 77 | m4_ifdef([AC_COMPUTE_INT], [], [ 78 | AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])]) 79 | ]) 80 | -------------------------------------------------------------------------------- /m4/progtest.m4: -------------------------------------------------------------------------------- 1 | # progtest.m4 serial 7 (gettext-0.18.2) 2 | dnl Copyright (C) 1996-2003, 2005, 2008-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | dnl 7 | dnl This file can can be used in projects which are not available under 8 | dnl the GNU General Public License or the GNU Library General Public 9 | dnl License but which still want to provide support for the GNU gettext 10 | dnl functionality. 11 | dnl Please note that the actual code of the GNU gettext library is covered 12 | dnl by the GNU Library General Public License, and the rest of the GNU 13 | dnl gettext package package is covered by the GNU General Public License. 14 | dnl They are *not* in the public domain. 15 | 16 | dnl Authors: 17 | dnl Ulrich Drepper , 1996. 18 | 19 | AC_PREREQ([2.50]) 20 | 21 | # Search path for a program which passes the given test. 22 | 23 | dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, 24 | dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) 25 | AC_DEFUN([AM_PATH_PROG_WITH_TEST], 26 | [ 27 | # Prepare PATH_SEPARATOR. 28 | # The user is always right. 29 | if test "${PATH_SEPARATOR+set}" != set; then 30 | # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which 31 | # contains only /bin. Note that ksh looks also at the FPATH variable, 32 | # so we have to set that as well for the test. 33 | PATH_SEPARATOR=: 34 | (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ 35 | && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ 36 | || PATH_SEPARATOR=';' 37 | } 38 | fi 39 | 40 | # Find out how to test for executable files. Don't use a zero-byte file, 41 | # as systems may use methods other than mode bits to determine executability. 42 | cat >conf$$.file <<_ASEOF 43 | #! /bin/sh 44 | exit 0 45 | _ASEOF 46 | chmod +x conf$$.file 47 | if test -x conf$$.file >/dev/null 2>&1; then 48 | ac_executable_p="test -x" 49 | else 50 | ac_executable_p="test -f" 51 | fi 52 | rm -f conf$$.file 53 | 54 | # Extract the first word of "$2", so it can be a program name with args. 55 | set dummy $2; ac_word=[$]2 56 | AC_MSG_CHECKING([for $ac_word]) 57 | AC_CACHE_VAL([ac_cv_path_$1], 58 | [case "[$]$1" in 59 | [[\\/]]* | ?:[[\\/]]*) 60 | ac_cv_path_$1="[$]$1" # Let the user override the test with a path. 61 | ;; 62 | *) 63 | ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR 64 | for ac_dir in ifelse([$5], , $PATH, [$5]); do 65 | IFS="$ac_save_IFS" 66 | test -z "$ac_dir" && ac_dir=. 67 | for ac_exec_ext in '' $ac_executable_extensions; do 68 | if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then 69 | echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD 70 | if [$3]; then 71 | ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" 72 | break 2 73 | fi 74 | fi 75 | done 76 | done 77 | IFS="$ac_save_IFS" 78 | dnl If no 4th arg is given, leave the cache variable unset, 79 | dnl so AC_PATH_PROGS will keep looking. 80 | ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" 81 | ])dnl 82 | ;; 83 | esac])dnl 84 | $1="$ac_cv_path_$1" 85 | if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then 86 | AC_MSG_RESULT([$][$1]) 87 | else 88 | AC_MSG_RESULT([no]) 89 | fi 90 | AC_SUBST([$1])dnl 91 | ]) 92 | -------------------------------------------------------------------------------- /m4/visibility.m4: -------------------------------------------------------------------------------- 1 | # visibility.m4 serial 5 (gettext-0.18.2) 2 | dnl Copyright (C) 2005, 2008, 2010-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | dnl Tests whether the compiler supports the command-line option 10 | dnl -fvisibility=hidden and the function and variable attributes 11 | dnl __attribute__((__visibility__("hidden"))) and 12 | dnl __attribute__((__visibility__("default"))). 13 | dnl Does *not* test for __visibility__("protected") - which has tricky 14 | dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on 15 | dnl Mac OS X. 16 | dnl Does *not* test for __visibility__("internal") - which has processor 17 | dnl dependent semantics. 18 | dnl Does *not* test for #pragma GCC visibility push(hidden) - which is 19 | dnl "really only recommended for legacy code". 20 | dnl Set the variable CFLAG_VISIBILITY. 21 | dnl Defines and sets the variable HAVE_VISIBILITY. 22 | 23 | AC_DEFUN([gl_VISIBILITY], 24 | [ 25 | AC_REQUIRE([AC_PROG_CC]) 26 | CFLAG_VISIBILITY= 27 | HAVE_VISIBILITY=0 28 | if test -n "$GCC"; then 29 | dnl First, check whether -Werror can be added to the command line, or 30 | dnl whether it leads to an error because of some other option that the 31 | dnl user has put into $CC $CFLAGS $CPPFLAGS. 32 | AC_MSG_CHECKING([whether the -Werror option is usable]) 33 | AC_CACHE_VAL([gl_cv_cc_vis_werror], [ 34 | gl_save_CFLAGS="$CFLAGS" 35 | CFLAGS="$CFLAGS -Werror" 36 | AC_COMPILE_IFELSE( 37 | [AC_LANG_PROGRAM([[]], [[]])], 38 | [gl_cv_cc_vis_werror=yes], 39 | [gl_cv_cc_vis_werror=no]) 40 | CFLAGS="$gl_save_CFLAGS"]) 41 | AC_MSG_RESULT([$gl_cv_cc_vis_werror]) 42 | dnl Now check whether visibility declarations are supported. 43 | AC_MSG_CHECKING([for simple visibility declarations]) 44 | AC_CACHE_VAL([gl_cv_cc_visibility], [ 45 | gl_save_CFLAGS="$CFLAGS" 46 | CFLAGS="$CFLAGS -fvisibility=hidden" 47 | dnl We use the option -Werror and a function dummyfunc, because on some 48 | dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning 49 | dnl "visibility attribute not supported in this configuration; ignored" 50 | dnl at the first function definition in every compilation unit, and we 51 | dnl don't want to use the option in this case. 52 | if test $gl_cv_cc_vis_werror = yes; then 53 | CFLAGS="$CFLAGS -Werror" 54 | fi 55 | AC_COMPILE_IFELSE( 56 | [AC_LANG_PROGRAM( 57 | [[extern __attribute__((__visibility__("hidden"))) int hiddenvar; 58 | extern __attribute__((__visibility__("default"))) int exportedvar; 59 | extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); 60 | extern __attribute__((__visibility__("default"))) int exportedfunc (void); 61 | void dummyfunc (void) {} 62 | ]], 63 | [[]])], 64 | [gl_cv_cc_visibility=yes], 65 | [gl_cv_cc_visibility=no]) 66 | CFLAGS="$gl_save_CFLAGS"]) 67 | AC_MSG_RESULT([$gl_cv_cc_visibility]) 68 | if test $gl_cv_cc_visibility = yes; then 69 | CFLAG_VISIBILITY="-fvisibility=hidden" 70 | HAVE_VISIBILITY=1 71 | fi 72 | fi 73 | AC_SUBST([CFLAG_VISIBILITY]) 74 | AC_SUBST([HAVE_VISIBILITY]) 75 | AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY], 76 | [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.]) 77 | ]) 78 | -------------------------------------------------------------------------------- /docs/msgfmt.txt: -------------------------------------------------------------------------------- 1 | Usage: msgfmt [OPTION] filename.po ... 2 | 3 | Generate binary message catalog from textual translation description. 4 | 5 | Mandatory arguments to long options are mandatory for short options too. 6 | Similarly for optional arguments. 7 | 8 | Input file location: 9 | filename.po ... input files 10 | -D, --directory=DIRECTORY add DIRECTORY to list for input files search 11 | If input file is -, standard input is read. 12 | 13 | Operation mode: 14 | -j, --java Java mode: generate a Java ResourceBundle class 15 | --java2 like --java, and assume Java2 (JDK 1.2 or higher) 16 | --csharp C# mode: generate a .NET .dll file 17 | --csharp-resources C# resources mode: generate a .NET .resources file 18 | --tcl Tcl mode: generate a tcl/msgcat .msg file 19 | --qt Qt mode: generate a Qt .qm file 20 | 21 | Output file location: 22 | -o, --output-file=FILE write output to specified file 23 | --strict enable strict Uniforum mode 24 | If output file is -, output is written to standard output. 25 | 26 | Output file location in Java mode: 27 | -r, --resource=RESOURCE resource name 28 | -l, --locale=LOCALE locale name, either language or language_COUNTRY 29 | -d DIRECTORY base directory of classes directory hierarchy 30 | The class name is determined by appending the locale name to the resource name, 31 | separated with an underscore. The -d option is mandatory. The class is 32 | written under the specified directory. 33 | 34 | Output file location in C# mode: 35 | -r, --resource=RESOURCE resource name 36 | -l, --locale=LOCALE locale name, either language or language_COUNTRY 37 | -d DIRECTORY base directory for locale dependent .dll files 38 | The -l and -d options are mandatory. The .dll file is written in a 39 | subdirectory of the specified directory whose name depends on the locale. 40 | 41 | Output file location in Tcl mode: 42 | -l, --locale=LOCALE locale name, either language or language_COUNTRY 43 | -d DIRECTORY base directory of .msg message catalogs 44 | The -l and -d options are mandatory. The .msg file is written in the 45 | specified directory. 46 | 47 | Input file syntax: 48 | -P, --properties-input input files are in Java .properties syntax 49 | --stringtable-input input files are in NeXTstep/GNUstep .strings 50 | syntax 51 | 52 | Input file interpretation: 53 | -c, --check perform all the checks implied by 54 | --check-format, --check-header, --check-domain 55 | --check-format check language dependent format strings 56 | --check-header verify presence and contents of the header entry 57 | --check-domain check for conflicts between domain directives 58 | and the --output-file option 59 | -C, --check-compatibility check that GNU msgfmt behaves like X/Open msgfmt 60 | --check-accelerators[=CHAR] check presence of keyboard accelerators for 61 | menu items 62 | -f, --use-fuzzy use fuzzy entries in output 63 | 64 | Output details: 65 | -a, --alignment=NUMBER align strings to NUMBER bytes (default: 1) 66 | --no-hash binary file will not include the hash table 67 | 68 | Informative output: 69 | -h, --help display this help and exit 70 | -V, --version output version information and exit 71 | --statistics print statistics about translations 72 | -v, --verbose increase verbosity level 73 | 74 | Report bugs to . 75 | -------------------------------------------------------------------------------- /data/Makevars.template: -------------------------------------------------------------------------------- 1 | # Makefile variables for PO directory in any package using GNU gettext. 2 | # 3 | # Copyright (C) 2003-2017 Free Software Foundation, Inc. 4 | # This file, Makevars,template, is free software; the Free Software Foundation 5 | # gives unlimited permission to use, copy, distribute, and modify it. 6 | 7 | # Usually the message domain is the same as the package name. 8 | DOMAIN = $(PACKAGE) 9 | 10 | # These two variables depend on the location of this directory. 11 | subdir = po 12 | top_builddir = .. 13 | 14 | # These options get passed to xgettext. 15 | XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ 16 | 17 | # This is the copyright holder that gets inserted into the header of the 18 | # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 19 | # package. (Note that the msgstr strings, extracted from the package's 20 | # sources, belong to the copyright holder of the package.) Translators are 21 | # expected to transfer the copyright for their translations to this person 22 | # or entity, or to disclaim their copyright. The empty string stands for 23 | # the public domain; in this case the translators are expected to disclaim 24 | # their copyright. 25 | COPYRIGHT_HOLDER = Free Software Foundation, Inc. 26 | 27 | # This tells whether or not to prepend "GNU " prefix to the package 28 | # name that gets inserted into the header of the $(DOMAIN).pot file. 29 | # Possible values are "yes", "no", or empty. If it is empty, try to 30 | # detect it automatically by scanning the files in $(top_srcdir) for 31 | # "GNU packagename" string. 32 | PACKAGE_GNU = 33 | 34 | # This is the email address or URL to which the translators shall report 35 | # bugs in the untranslated strings: 36 | # - Strings which are not entire sentences, see the maintainer guidelines 37 | # in the GNU gettext documentation, section 'Preparing Strings'. 38 | # - Strings which use unclear terms or require additional context to be 39 | # understood. 40 | # - Strings which make invalid assumptions about notation of date, time or 41 | # money. 42 | # - Pluralisation problems. 43 | # - Incorrect English spelling. 44 | # - Incorrect formatting. 45 | # It can be your email address, or a mailing list address where translators 46 | # can write to without being subscribed, or the URL of a web page through 47 | # which the translators can contact you. 48 | MSGID_BUGS_ADDRESS = 49 | 50 | # This is the list of locale categories, beyond LC_MESSAGES, for which the 51 | # message catalogs shall be used. It is usually empty. 52 | EXTRA_LOCALE_CATEGORIES = 53 | 54 | # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' 55 | # context. Possible values are "yes" and "no". Set this to yes if the 56 | # package uses functions taking also a message context, like pgettext(), or 57 | # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. 58 | USE_MSGCTXT = no 59 | 60 | # These options get passed to msgmerge. 61 | # Useful options are in particular: 62 | # --previous to keep previous msgids of translated messages, 63 | # --quiet to reduce the verbosity. 64 | MSGMERGE_OPTIONS = 65 | 66 | # These options get passed to msginit. 67 | # If you want to disable line wrapping when writing PO files, add 68 | # --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and 69 | # MSGINIT_OPTIONS. 70 | MSGINIT_OPTIONS = 71 | 72 | # This tells whether or not to regenerate a PO file when $(DOMAIN).pot 73 | # has changed. Possible values are "yes" and "no". Set this to no if 74 | # the POT file is checked in the repository and the version control 75 | # program ignores timestamps. 76 | PO_DEPENDS_ON_POT = yes 77 | 78 | # This tells whether or not to forcibly update $(DOMAIN).pot and 79 | # regenerate PO files on "make dist". Possible values are "yes" and 80 | # "no". Set this to no if the POT file and PO files are maintained 81 | # externally. 82 | DIST_DEPENDS_ON_UPDATE_PO = yes 83 | -------------------------------------------------------------------------------- /m4/lib-ld.m4: -------------------------------------------------------------------------------- 1 | # lib-ld.m4 serial 6 2 | dnl Copyright (C) 1996-2003, 2009-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl Subroutines of libtool.m4, 8 | dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid 9 | dnl collision with libtool.m4. 10 | 11 | dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. 12 | AC_DEFUN([AC_LIB_PROG_LD_GNU], 13 | [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], 14 | [# I'd rather use --version here, but apparently some GNU lds only accept -v. 15 | case `$LD -v 2>&1 /dev/null 2>&1 \ 45 | && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ 46 | || PATH_SEPARATOR=';' 47 | } 48 | fi 49 | 50 | ac_prog=ld 51 | if test "$GCC" = yes; then 52 | # Check if gcc -print-prog-name=ld gives a path. 53 | AC_MSG_CHECKING([for ld used by $CC]) 54 | case $host in 55 | *-*-mingw*) 56 | # gcc leaves a trailing carriage return which upsets mingw 57 | ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; 58 | *) 59 | ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; 60 | esac 61 | case $ac_prog in 62 | # Accept absolute paths. 63 | [[\\/]]* | ?:[[\\/]]*) 64 | re_direlt='/[[^/]][[^/]]*/\.\./' 65 | # Canonicalize the pathname of ld 66 | ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` 67 | while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do 68 | ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` 69 | done 70 | test -z "$LD" && LD="$ac_prog" 71 | ;; 72 | "") 73 | # If it fails, then pretend we aren't using GCC. 74 | ac_prog=ld 75 | ;; 76 | *) 77 | # If it is relative, then search for the first ld in PATH. 78 | with_gnu_ld=unknown 79 | ;; 80 | esac 81 | elif test "$with_gnu_ld" = yes; then 82 | AC_MSG_CHECKING([for GNU ld]) 83 | else 84 | AC_MSG_CHECKING([for non-GNU ld]) 85 | fi 86 | AC_CACHE_VAL([acl_cv_path_LD], 87 | [if test -z "$LD"; then 88 | acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR 89 | for ac_dir in $PATH; do 90 | IFS="$acl_save_ifs" 91 | test -z "$ac_dir" && ac_dir=. 92 | if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then 93 | acl_cv_path_LD="$ac_dir/$ac_prog" 94 | # Check to see if the program is GNU ld. I'd rather use --version, 95 | # but apparently some variants of GNU ld only accept -v. 96 | # Break only if it was the GNU/non-GNU ld that we prefer. 97 | case `"$acl_cv_path_LD" -v 2>&1 . 82 | -------------------------------------------------------------------------------- /m4/ansi-c++.m4: -------------------------------------------------------------------------------- 1 | # ansi-c++.m4 serial 9 2 | dnl Copyright (C) 2002-2003, 2005, 2010-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | # Sets CXX_CHOICE to 'yes' or 'no', depending on the preferred use of C++. 10 | # The default is 'yes'. If the configure.ac contains a definition of the 11 | # macro gl_CXX_CHOICE_DEFAULT_NO, then the default is 'no'. In both cases, 12 | # the user can change the value by passing the option --disable-cxx or 13 | # --enable-cxx, respectively. 14 | 15 | AC_DEFUN([gl_CXX_CHOICE], 16 | [ 17 | AC_MSG_CHECKING([whether to use C++]) 18 | dnl Plus signs are supported in AC_ARG_ENABLE starting with autoconf-2.66. 19 | m4_version_prereq([2.66], 20 | [m4_ifdef([gl_CXX_CHOICE_DEFAULT_NO], 21 | [AC_ARG_ENABLE([c++], 22 | [ --enable-c++ also build C++ sources], 23 | [CXX_CHOICE="$enableval"], 24 | [CXX_CHOICE=no])], 25 | [AC_ARG_ENABLE([c++], 26 | [ --disable-c++ do not build C++ sources], 27 | [CXX_CHOICE="$enableval"], 28 | [CXX_CHOICE=yes])])], 29 | [m4_ifdef([gl_CXX_CHOICE_DEFAULT_NO], 30 | [AC_ARG_ENABLE([cxx], 31 | [ --enable-cxx also build C++ sources], 32 | [CXX_CHOICE="$enableval"], 33 | [CXX_CHOICE=no])], 34 | [AC_ARG_ENABLE([cxx], 35 | [ --disable-cxx do not build C++ sources], 36 | [CXX_CHOICE="$enableval"], 37 | [CXX_CHOICE=yes])])]) 38 | AC_MSG_RESULT([$CXX_CHOICE]) 39 | AC_SUBST([CXX_CHOICE]) 40 | ]) 41 | 42 | # gl_PROG_ANSI_CXX([ANSICXX_VARIABLE], [ANSICXX_CONDITIONAL]) 43 | # Sets ANSICXX_VARIABLE to the name of a sufficiently ANSI C++ compliant 44 | # compiler, or to "no" if none is found. 45 | # Defines the Automake condition ANSICXX_CONDITIONAL to true if such a compiler 46 | # was found, or to false if not. 47 | 48 | AC_DEFUN([gl_PROG_ANSI_CXX], 49 | [ 50 | AC_REQUIRE([gl_CXX_CHOICE]) 51 | m4_if([$1], [CXX], [], 52 | [gl_save_CXX="$CXX"]) 53 | if test "$CXX_CHOICE" = no; then 54 | CXX=no 55 | fi 56 | if test -z "$CXX"; then 57 | if test -n "$CCC"; then 58 | CXX="$CCC" 59 | else 60 | AC_CHECK_TOOLS([CXX], 61 | [g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC], 62 | [:]) 63 | fi 64 | fi 65 | if test "$CXX" != no; then 66 | dnl Use a modified version of AC_PROG_CXX_WORKS that does not exit 67 | dnl upon failure. 68 | AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works]) 69 | AC_LANG_PUSH([C++]) 70 | AC_ARG_VAR([CXX], [C++ compiler command]) 71 | AC_ARG_VAR([CXXFLAGS], [C++ compiler flags]) 72 | echo 'int main () { return 0; }' > conftest.$ac_ext 73 | if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 74 | gl_cv_prog_ansicxx_works=yes 75 | if (./conftest; exit) 2>/dev/null; then 76 | gl_cv_prog_ansicxx_cross=no 77 | else 78 | gl_cv_prog_ansicxx_cross=yes 79 | fi 80 | else 81 | gl_cv_prog_ansicxx_works=no 82 | fi 83 | rm -fr conftest* 84 | AC_LANG_POP([C++]) 85 | AC_MSG_RESULT([$gl_cv_prog_ansicxx_works]) 86 | if test $gl_cv_prog_ansicxx_works = no; then 87 | CXX=no 88 | else 89 | dnl Test for namespaces. 90 | dnl We don't bother supporting pre-ANSI-C++ compilers. 91 | AC_MSG_CHECKING([whether the C++ compiler supports namespaces]) 92 | AC_LANG_PUSH([C++]) 93 | cat < conftest.$ac_ext 94 | #include 95 | namespace test { using namespace std; } 96 | std::ostream* ptr; 97 | int main () { return 0; } 98 | EOF 99 | if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 100 | gl_cv_prog_ansicxx_namespaces=yes 101 | else 102 | gl_cv_prog_ansicxx_namespaces=no 103 | fi 104 | rm -fr conftest* 105 | AC_LANG_POP([C++]) 106 | AC_MSG_RESULT([$gl_cv_prog_ansicxx_namespaces]) 107 | if test $gl_cv_prog_ansicxx_namespaces = no; then 108 | CXX=no 109 | fi 110 | fi 111 | fi 112 | m4_if([$1], [CXX], [], 113 | [$1="$CXX" 114 | CXX="$gl_save_CXX"]) 115 | AC_SUBST([$1]) 116 | 117 | AM_CONDITIONAL([$2], [test "$$1" != no]) 118 | 119 | if test "$$1" != no; then 120 | dnl This macro invocation resolves an automake error: 121 | dnl /usr/local/share/automake-1.11/am/depend2.am: am__fastdepCXX does not appear in AM_CONDITIONAL 122 | dnl /usr/local/share/automake-1.11/am/depend2.am: The usual way to define 'am__fastdepCXX' is to add 'AC_PROG_CXX' 123 | dnl /usr/local/share/automake-1.11/am/depend2.am: to 'configure.ac' and run 'aclocal' and 'autoconf' again. 124 | _AM_DEPENDENCIES([CXX]) 125 | else 126 | AM_CONDITIONAL([am__fastdepCXX], [false]) 127 | fi 128 | ]) 129 | -------------------------------------------------------------------------------- /m4/longlong.m4: -------------------------------------------------------------------------------- 1 | # longlong.m4 serial 17 2 | dnl Copyright (C) 1999-2007, 2009-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Paul Eggert. 8 | 9 | # Define HAVE_LONG_LONG_INT if 'long long int' works. 10 | # This fixes a bug in Autoconf 2.61, and can be faster 11 | # than what's in Autoconf 2.62 through 2.68. 12 | 13 | # Note: If the type 'long long int' exists but is only 32 bits large 14 | # (as on some very old compilers), HAVE_LONG_LONG_INT will not be 15 | # defined. In this case you can treat 'long long int' like 'long int'. 16 | 17 | AC_DEFUN([AC_TYPE_LONG_LONG_INT], 18 | [ 19 | AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) 20 | AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], 21 | [ac_cv_type_long_long_int=yes 22 | if test "x${ac_cv_prog_cc_c99-no}" = xno; then 23 | ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int 24 | if test $ac_cv_type_long_long_int = yes; then 25 | dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. 26 | dnl If cross compiling, assume the bug is not important, since 27 | dnl nobody cross compiles for this platform as far as we know. 28 | AC_RUN_IFELSE( 29 | [AC_LANG_PROGRAM( 30 | [[@%:@include 31 | @%:@ifndef LLONG_MAX 32 | @%:@ define HALF \ 33 | (1LL << (sizeof (long long int) * CHAR_BIT - 2)) 34 | @%:@ define LLONG_MAX (HALF - 1 + HALF) 35 | @%:@endif]], 36 | [[long long int n = 1; 37 | int i; 38 | for (i = 0; ; i++) 39 | { 40 | long long int m = n << i; 41 | if (m >> i != n) 42 | return 1; 43 | if (LLONG_MAX / 2 < m) 44 | break; 45 | } 46 | return 0;]])], 47 | [], 48 | [ac_cv_type_long_long_int=no], 49 | [:]) 50 | fi 51 | fi]) 52 | if test $ac_cv_type_long_long_int = yes; then 53 | AC_DEFINE([HAVE_LONG_LONG_INT], [1], 54 | [Define to 1 if the system has the type 'long long int'.]) 55 | fi 56 | ]) 57 | 58 | # Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. 59 | # This fixes a bug in Autoconf 2.61, and can be faster 60 | # than what's in Autoconf 2.62 through 2.68. 61 | 62 | # Note: If the type 'unsigned long long int' exists but is only 32 bits 63 | # large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT 64 | # will not be defined. In this case you can treat 'unsigned long long int' 65 | # like 'unsigned long int'. 66 | 67 | AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], 68 | [ 69 | AC_CACHE_CHECK([for unsigned long long int], 70 | [ac_cv_type_unsigned_long_long_int], 71 | [ac_cv_type_unsigned_long_long_int=yes 72 | if test "x${ac_cv_prog_cc_c99-no}" = xno; then 73 | AC_LINK_IFELSE( 74 | [_AC_TYPE_LONG_LONG_SNIPPET], 75 | [], 76 | [ac_cv_type_unsigned_long_long_int=no]) 77 | fi]) 78 | if test $ac_cv_type_unsigned_long_long_int = yes; then 79 | AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], 80 | [Define to 1 if the system has the type 'unsigned long long int'.]) 81 | fi 82 | ]) 83 | 84 | # Expands to a C program that can be used to test for simultaneous support 85 | # of 'long long' and 'unsigned long long'. We don't want to say that 86 | # 'long long' is available if 'unsigned long long' is not, or vice versa, 87 | # because too many programs rely on the symmetry between signed and unsigned 88 | # integer types (excluding 'bool'). 89 | AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], 90 | [ 91 | AC_LANG_PROGRAM( 92 | [[/* For now, do not test the preprocessor; as of 2007 there are too many 93 | implementations with broken preprocessors. Perhaps this can 94 | be revisited in 2012. In the meantime, code should not expect 95 | #if to work with literals wider than 32 bits. */ 96 | /* Test literals. */ 97 | long long int ll = 9223372036854775807ll; 98 | long long int nll = -9223372036854775807LL; 99 | unsigned long long int ull = 18446744073709551615ULL; 100 | /* Test constant expressions. */ 101 | typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) 102 | ? 1 : -1)]; 103 | typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 104 | ? 1 : -1)]; 105 | int i = 63;]], 106 | [[/* Test availability of runtime routines for shift and division. */ 107 | long long int llmax = 9223372036854775807ll; 108 | unsigned long long int ullmax = 18446744073709551615ull; 109 | return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) 110 | | (llmax / ll) | (llmax % ll) 111 | | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) 112 | | (ullmax / ull) | (ullmax % ull));]]) 113 | ]) 114 | -------------------------------------------------------------------------------- /m4/fcntl-o.m4: -------------------------------------------------------------------------------- 1 | # fcntl-o.m4 serial 4 2 | dnl Copyright (C) 2006, 2009-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl Written by Paul Eggert. 8 | 9 | # Test whether the flags O_NOATIME and O_NOFOLLOW actually work. 10 | # Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise. 11 | # Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise. 12 | AC_DEFUN([gl_FCNTL_O_FLAGS], 13 | [ 14 | dnl Persuade glibc to define O_NOATIME and O_NOFOLLOW. 15 | dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes 16 | dnl AC_GNU_SOURCE. 17 | m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], 18 | [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], 19 | [AC_REQUIRE([AC_GNU_SOURCE])]) 20 | 21 | AC_CHECK_HEADERS_ONCE([unistd.h]) 22 | AC_CHECK_FUNCS_ONCE([symlink]) 23 | AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], 24 | [AC_RUN_IFELSE( 25 | [AC_LANG_PROGRAM( 26 | [[#include 27 | #include 28 | #if HAVE_UNISTD_H 29 | # include 30 | #else /* on Windows with MSVC */ 31 | # include 32 | # include 33 | # defined sleep(n) _sleep ((n) * 1000) 34 | #endif 35 | #include 36 | #ifndef O_NOATIME 37 | #define O_NOATIME 0 38 | #endif 39 | #ifndef O_NOFOLLOW 40 | #define O_NOFOLLOW 0 41 | #endif 42 | static int const constants[] = 43 | { 44 | O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, 45 | O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY 46 | }; 47 | ]], 48 | [[ 49 | int result = !constants; 50 | #if HAVE_SYMLINK 51 | { 52 | static char const sym[] = "conftest.sym"; 53 | if (symlink ("/dev/null", sym) != 0) 54 | result |= 2; 55 | else 56 | { 57 | int fd = open (sym, O_WRONLY | O_NOFOLLOW | O_CREAT, 0); 58 | if (fd >= 0) 59 | { 60 | close (fd); 61 | result |= 4; 62 | } 63 | } 64 | if (unlink (sym) != 0 || symlink (".", sym) != 0) 65 | result |= 2; 66 | else 67 | { 68 | int fd = open (sym, O_RDONLY | O_NOFOLLOW); 69 | if (fd >= 0) 70 | { 71 | close (fd); 72 | result |= 4; 73 | } 74 | } 75 | unlink (sym); 76 | } 77 | #endif 78 | { 79 | static char const file[] = "confdefs.h"; 80 | int fd = open (file, O_RDONLY | O_NOATIME); 81 | if (fd < 0) 82 | result |= 8; 83 | else 84 | { 85 | struct stat st0; 86 | if (fstat (fd, &st0) != 0) 87 | result |= 16; 88 | else 89 | { 90 | char c; 91 | sleep (1); 92 | if (read (fd, &c, 1) != 1) 93 | result |= 24; 94 | else 95 | { 96 | if (close (fd) != 0) 97 | result |= 32; 98 | else 99 | { 100 | struct stat st1; 101 | if (stat (file, &st1) != 0) 102 | result |= 40; 103 | else 104 | if (st0.st_atime != st1.st_atime) 105 | result |= 64; 106 | } 107 | } 108 | } 109 | } 110 | } 111 | return result;]])], 112 | [gl_cv_header_working_fcntl_h=yes], 113 | [case $? in #( 114 | 4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( 115 | 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( 116 | 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( 117 | *) gl_cv_header_working_fcntl_h='no';; 118 | esac], 119 | [gl_cv_header_working_fcntl_h=cross-compiling])]) 120 | 121 | case $gl_cv_header_working_fcntl_h in #( 122 | *O_NOATIME* | no | cross-compiling) ac_val=0;; #( 123 | *) ac_val=1;; 124 | esac 125 | AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val], 126 | [Define to 1 if O_NOATIME works.]) 127 | 128 | case $gl_cv_header_working_fcntl_h in #( 129 | *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #( 130 | *) ac_val=1;; 131 | esac 132 | AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val], 133 | [Define to 1 if O_NOFOLLOW works.]) 134 | ]) 135 | -------------------------------------------------------------------------------- /docs/xgettext.txt: -------------------------------------------------------------------------------- 1 | Usage: xgettext [OPTION] [INPUTFILE]... 2 | 3 | Extract translatable strings from given input files. 4 | 5 | Mandatory arguments to long options are mandatory for short options too. 6 | Similarly for optional arguments. 7 | 8 | Input file location: 9 | INPUTFILE ... input files 10 | -f, --files-from=FILE get list of input files from FILE 11 | -D, --directory=DIRECTORY add DIRECTORY to list for input files search 12 | If input file is -, standard input is read. 13 | 14 | Output file location: 15 | -d, --default-domain=NAME use NAME.po for output (instead of messages.po) 16 | -o, --output=FILE write output to specified file 17 | -p, --output-dir=DIR output files will be placed in directory DIR 18 | If output file is -, output is written to standard output. 19 | 20 | Choice of input file language: 21 | -L, --language=NAME recognise the specified language 22 | (C, C++, ObjectiveC, PO, Shell, Python, Lisp, 23 | EmacsLisp, librep, Scheme, Smalltalk, Java, 24 | JavaProperties, C#, awk, YCP, Tcl, Perl, PHP, 25 | GCC-source, NXStringTable, RST, Glade) 26 | -C, --c++ shorthand for --language=C++ 27 | By default the language is guessed depending on the input file name extension. 28 | 29 | Input file interpretation: 30 | --from-code=NAME encoding of input files 31 | (except for Python, Tcl, Glade) 32 | By default the input files are assumed to be in ASCII. 33 | 34 | Operation mode: 35 | -j, --join-existing join messages with existing file 36 | -x, --exclude-file=FILE.po entries from FILE.po are not extracted 37 | -cTAG, --add-comments=TAG place comment blocks starting with TAG and 38 | preceding keyword lines in output file 39 | -c, --add-comments place all comment blocks preceding keyword lines 40 | in output file 41 | 42 | Language specific options: 43 | -a, --extract-all extract all strings 44 | (only languages C, C++, ObjectiveC, Shell, 45 | Python, Lisp, EmacsLisp, librep, Scheme, Java, 46 | C#, awk, Tcl, Perl, PHP, GCC-source, Glade) 47 | -kWORD, --keyword=WORD look for WORD as an additional keyword 48 | -k, --keyword do not to use default keywords 49 | (only languages C, C++, ObjectiveC, Shell, 50 | Python, Lisp, EmacsLisp, librep, Scheme, Java, 51 | C#, awk, Tcl, Perl, PHP, GCC-source, Glade) 52 | --flag=WORD:ARG:FLAG additional flag for strings inside the argument 53 | number ARG of keyword WORD 54 | (only languages C, C++, ObjectiveC, Shell, 55 | Python, Lisp, EmacsLisp, librep, Scheme, Java, 56 | C#, awk, YCP, Tcl, Perl, PHP, GCC-source) 57 | -T, --trigraphs understand ANSI C trigraphs for input 58 | (only languages C, C++, ObjectiveC) 59 | --qt recognize Qt format strings 60 | (only language C++) 61 | --kde recognize KDE 4 format strings 62 | (only language C++) 63 | --boost recognize Boost format strings 64 | (only language C++) 65 | --debug more detailed formatstring recognition result 66 | 67 | Output details: 68 | --color use colors and other text attributes always 69 | --color=WHEN use colors and other text attributes if WHEN. 70 | WHEN may be 'always', 'never', 'auto', or 'html'. 71 | --style=STYLEFILE specify CSS style rule file for --color 72 | -e, --no-escape do not use C escapes in output (default) 73 | -E, --escape use C escapes in output, no extended chars 74 | --force-po write PO file even if empty 75 | -i, --indent write the .po file using indented style 76 | --no-location do not write '#: filename:line' lines 77 | -n, --add-location generate '#: filename:line' lines (default) 78 | --strict write out strict Uniforum conforming .po file 79 | --properties-output write out a Java .properties file 80 | --stringtable-output write out a NeXTstep/GNUstep .strings file 81 | -w, --width=NUMBER set output page width 82 | --no-wrap do not break long message lines, longer than 83 | the output page width, into several lines 84 | -s, --sort-output generate sorted output 85 | -F, --sort-by-file sort output by file location 86 | --omit-header don't write header with `msgid ""' entry 87 | --copyright-holder=STRING set copyright holder in output 88 | --foreign-user omit FSF copyright in output for foreign user 89 | --package-name=PACKAGE set package name in output 90 | --package-version=VERSION set package version in output 91 | --msgid-bugs-address=EMAIL@ADDRESS set report address for msgid bugs 92 | -m[STRING], --msgstr-prefix[=STRING] use STRING or "" as prefix for msgstr 93 | values 94 | -M[STRING], --msgstr-suffix[=STRING] use STRING or "" as suffix for msgstr 95 | values 96 | 97 | Informative output: 98 | -h, --help display this help and exit 99 | -V, --version output version information and exit 100 | 101 | Report bugs to . 102 | -------------------------------------------------------------------------------- /data/autopoint_Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile for PO directory in any package using GNU gettext. 2 | # Copyright (C) 1995-1997, 2000-2007, 2009-2010 by Ulrich Drepper 3 | # 4 | # Copying and distribution of this file, with or without modification, 5 | # are permitted in any medium without royalty provided the copyright 6 | # notice and this notice are preserved. This file is offered as-is, 7 | # without any warranty. 8 | # 9 | # Origin: gettext-0.19.8 10 | # 11 | PACKAGE = @PACKAGE@ 12 | VERSION = @VERSION@ 13 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 14 | SED = @SED@ 15 | SHELL = /bin/sh 16 | srcdir = @srcdir@ 17 | top_srcdir = @top_srcdir@ 18 | VPATH = @srcdir@ 19 | prefix = @prefix@ 20 | exec_prefix = @exec_prefix@ 21 | datarootdir = @datarootdir@ 22 | datadir = @datadir@ 23 | localedir = @localedir@ 24 | gettextsrcdir = $(datadir)/gettext/po 25 | INSTALL = @INSTALL@ 26 | INSTALL_DATA = @INSTALL_DATA@ 27 | mkinstalldirs = $(SHELL) @install_sh@ -d 28 | install_sh = $(SHELL) @install_sh@ 29 | MKDIR_P = @MKDIR_P@ 30 | mkdir_p = @mkdir_p@ 31 | CROSS_COMPILING = @CROSS_COMPILING@ 32 | GMSGFMT_ = @GMSGFMT@ 33 | GMSGFMT_no = @GMSGFMT@ 34 | GMSGFMT_yes = @GMSGFMT_015@ 35 | GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT)) 36 | MSGFMT_ = @MSGFMT@ 37 | MSGFMT_no = @MSGFMT@ 38 | MSGFMT_yes = @MSGFMT_015@ 39 | MSGFMT = $(MSGFMT_$(USE_MSGCTXT)) 40 | 41 | POFILES = @POFILES@ 42 | GMOFILES = @GMOFILES@ 43 | MOFILES = @MOFILES@ 44 | 45 | POTFILES = \ 46 | 47 | CATALOGS = @CATALOGS@ 48 | 49 | # Makevars gets inserted here. (Don't remove this line!) 50 | 51 | .SUFFIXES: 52 | .SUFFIXES: .po .gmo .mo 53 | .PHONY: all 54 | 55 | all: all-@USE_NLS@ 56 | 57 | all-yes: update-po update-mo 58 | 59 | all-no: 60 | 61 | .po.mo: 62 | @echo "$(MSGFMT) -c -o $@ $<"; \ 63 | $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@ 64 | 65 | .po.gmo: 66 | @lang=`echo $* | sed -e 's,.*/,,'`; \ 67 | echo "cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o $${lang}.gmo $${lang}.po"; \ 68 | cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo 69 | 70 | $(srcdir)/$(DOMAIN).pot: 71 | test -f $(srcdir)/$(DOMAIN).pot || touch $(srcdir)/$(DOMAIN).pot; 72 | 73 | .po: $(srcdir)/$(DOMAIN).pot 74 | @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ 75 | if test -f "$(srcdir)/$${lang}.po"; then \ 76 | echo "cd $(srcdir) && $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot"; \ 77 | cd $(srcdir) && $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot; \ 78 | else \ 79 | echo "po file does not exist"; \ 80 | exit 1; \ 81 | fi 82 | 83 | update-gmo update-mo: 84 | if test -n "$(GMOFILES)"; then \ 85 | $(MAKE) $(GMOFILES); \ 86 | else \ 87 | test "$(MOFILES)" = "@MOFILES@" || $(MAKE) $(MOFILES); \ 88 | fi 89 | 90 | update-po: 91 | test -z "$(POFILES)" || $(MAKE) $(POFILES) 92 | 93 | install: install-@USE_NLS@ 94 | install-strip: install 95 | install-no: 96 | install-yes: all 97 | @catalogs='$(CATALOGS)'; \ 98 | for cat in $$catalogs; do \ 99 | cat=`basename $$cat`; \ 100 | lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ 101 | dir=$(localedir)/$$lang/LC_MESSAGES; \ 102 | $(mkdir_p) $(DESTDIR)$$dir; \ 103 | if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ 104 | $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \ 105 | echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \ 106 | for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ 107 | if test -n "$$lc"; then \ 108 | if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ 109 | link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ 110 | mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 111 | mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 112 | (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ 113 | for file in *; do \ 114 | if test -f $$file; then \ 115 | ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ 116 | fi; \ 117 | done); \ 118 | rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 119 | else \ 120 | if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ 121 | :; \ 122 | else \ 123 | rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ 124 | mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 125 | fi; \ 126 | fi; \ 127 | rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ 128 | ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ 129 | ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ 130 | cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ 131 | echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \ 132 | fi; \ 133 | done; \ 134 | done 135 | 136 | 137 | installdirs: installdirs-@USE_NLS@ 138 | installdirs-no: 139 | installdirs-yes: 140 | @catalogs='$(CATALOGS)'; \ 141 | for cat in $$catalogs; do \ 142 | cat=`basename $$cat`; \ 143 | lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ 144 | dir=$(localedir)/$$lang/LC_MESSAGES; \ 145 | $(mkdir_p) $(DESTDIR)$$dir; \ 146 | for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ 147 | if test -n "$$lc"; then \ 148 | if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ 149 | link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ 150 | mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 151 | mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 152 | (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ 153 | for file in *; do \ 154 | if test -f $$file; then \ 155 | ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ 156 | fi; \ 157 | done); \ 158 | rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 159 | else \ 160 | if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ 161 | :; \ 162 | else \ 163 | rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ 164 | mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 165 | fi; \ 166 | fi; \ 167 | fi; \ 168 | done; \ 169 | done 170 | 171 | installcheck: 172 | 173 | uninstall: uninstall-@USE_NLS@ 174 | uninstall-no: 175 | uninstall-yes: 176 | catalogs='$(CATALOGS)'; \ 177 | for cat in $$catalogs; do \ 178 | cat=`basename $$cat`; \ 179 | lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ 180 | for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \ 181 | rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ 182 | done; \ 183 | done 184 | 185 | check: all 186 | 187 | info dvi ps pdf html tags TAGS ctags CTAGS ID: 188 | 189 | install-dvi install-ps install-pdf install-html: 190 | 191 | distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) 192 | dist distdir: update-po update-mo 193 | $(mkdir_p) $(distdir); \ 194 | if test -n "$(GMOFILES)"; then \ 195 | dists="$(POFILES) $(GMOFILES)"; \ 196 | else \ 197 | dists="$(POFILES) $(MOFILES)"; \ 198 | fi; \ 199 | if test "$(PACKAGE)" = "gettext-tools"; then \ 200 | dists="$$dists Makevars.template"; \ 201 | fi; \ 202 | if test -f $(srcdir)/POTFILES.in; then \ 203 | dists="$$dists POTFILES.in"; \ 204 | fi; \ 205 | if test -f $(srcdir)/Makefile.in.in; then \ 206 | dists="$$dists Makefile.in.in"; \ 207 | fi; \ 208 | if test -f $(srcdir)/Makevars; then \ 209 | dists="$$dists Makevars"; \ 210 | fi; \ 211 | if test -f $(srcdir)/$(DOMAIN).pot; then \ 212 | dists="$$dists $(DOMAIN).pot"; \ 213 | fi; \ 214 | if test -f $(srcdir)/ChangeLog; then \ 215 | dists="$$dists ChangeLog"; \ 216 | fi; \ 217 | for i in 0 1 2 3 4 5 6 7 8 9; do \ 218 | if test -f $(srcdir)/ChangeLog.$$i; then \ 219 | dists="$$dists ChangeLog.$$i"; \ 220 | fi; \ 221 | done; \ 222 | if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \ 223 | for file in $$dists; do \ 224 | if test -f $$file; then \ 225 | cp -p $$file $(distdir) || exit 1; \ 226 | else \ 227 | cp -p $(srcdir)/$$file $(distdir) || exit 1; \ 228 | fi; \ 229 | done 230 | 231 | Makefile: Makefile.in.in Makevars $(top_builddir)/config.status 232 | cd $(top_builddir) && @SHELL@ ./config.status $(subdir)/$@.in po-directories; 233 | 234 | mostlyclean clean: 235 | rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po 236 | rm -fr *.o 237 | 238 | maintainer-clean distclean: clean 239 | rm -f Makefile Makefile.in *.mo *.gmo 240 | -------------------------------------------------------------------------------- /src/msgmerge.c: -------------------------------------------------------------------------------- 1 | /* msgfmt utility (C) 2012 rofl0r 2 | * released under the MIT license, see LICENSE for details */ 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "poparser.h" 9 | #include "StringEscape.h" 10 | 11 | __attribute__((noreturn)) 12 | static void syntax(void) { 13 | fprintf(stdout, 14 | "Usage: msgmerge [OPTION] def.po ref.pot\n"); 15 | exit(1); 16 | } 17 | 18 | __attribute__((noreturn)) 19 | static void version(void) { 20 | fprintf(stdout, 21 | "msgmerge (GNU gettext-tools compatible) 99.9999.9999\n"); 22 | exit(0); 23 | } 24 | 25 | #define streq(A, B) (!strcmp(A, B)) 26 | #define strstarts(S, W) (memcmp(S, W, sizeof(W) - 1) ? NULL : (S + (sizeof(W) - 1))) 27 | 28 | struct fiLes { 29 | FILE *out; 30 | /* we can haz 3 different input files: 31 | * the .pot, which is the file containing only the ripped out strings from the program 32 | * (and no translations) 33 | * a .po, which contains translations and strings made from a previous .pot from that same source file, 34 | * a compendium, which is basically a huge po file containing all sorts of strings (msgid's) and translations (msgstr's) 35 | */ 36 | FILE *po; 37 | FILE *pot; 38 | FILE *compend; 39 | 40 | // the biggest length of a string 41 | enum po_stage stage; 42 | size_t len; 43 | char *buf; 44 | }; 45 | 46 | /* currently we only output input strings as output strings 47 | * i.e. there is no translation lookup at all */ 48 | int process_line_callback(po_message_t msg, void* user) { 49 | struct fiLes* file = (struct fiLes*) user; 50 | int i, j, k; 51 | switch (file->stage) { 52 | case ps_size: 53 | if (msg->ctxt_len > file->len) 54 | file->len = msg->ctxt_len + 1; 55 | 56 | if (msg->id_len > file->len) 57 | file->len = msg->id_len + 1; 58 | 59 | if (msg->plural_len > file->len) 60 | file->len = msg->plural_len + 1; 61 | 62 | for (i=0; i < MAX_NPLURALS; i++) 63 | if (msg->strlen[i] > file->len) 64 | file->len = msg->strlen[i] + 1; 65 | 66 | file->len += 1; 67 | break; 68 | case ps_parse: 69 | if (msg->ctxt_len) { 70 | escape(msg->ctxt, file->buf, file->len); 71 | fprintf(file->out, "msgctxt \"%.1024s\"\n", file->buf); 72 | k = strlen(file->buf); 73 | for (j = 1024; j < k; j += 1024) 74 | fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]); 75 | } 76 | 77 | escape(msg->id, file->buf, file->len); 78 | fprintf(file->out, "msgid \"%.1024s\"\n", file->buf); 79 | k = strlen(file->buf); 80 | for (j = 1024; j < k; j += 1024) 81 | fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]); 82 | 83 | if (msg->plural_len) { 84 | escape(msg->plural, file->buf, file->len); 85 | fprintf(file->out, "msgid_plural \"%.1024s\"\n", file->buf); 86 | k = strlen(file->buf); 87 | for (j = 1024; j < k; j += 1024) 88 | fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]); 89 | } 90 | 91 | if (msg->plural_len) { 92 | for (i=0; i < MAX_NPLURALS && msg->strlen[i]; i++) { 93 | escape(msg->str[i], file->buf, file->len); 94 | fprintf(file->out, "msgstr[%d] \"%.1024s\"\n", i, file->buf); 95 | k = strlen(file->buf); 96 | for (j = 1024; j < k; j += 1024) 97 | fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]); 98 | } 99 | if (!msg->strlen[0]) { 100 | fprintf(file->out, "msgstr[0] \"\"\n"); 101 | } 102 | } else { 103 | escape(msg->str[0], file->buf, file->len); 104 | fprintf(file->out, "msgstr \"%.1024s\"\n", file->buf); 105 | k = strlen(file->buf); 106 | for (j = 1024; j < k; j += 1024) 107 | fprintf(file->out, "\"%.1024s\"\n", &file->buf[j]); 108 | } 109 | 110 | fputc('\n', file->out); 111 | break; 112 | } 113 | return 0; 114 | } 115 | 116 | int process(struct fiLes *files, int update, int backup) { 117 | (void) update; (void) backup; 118 | enum po_error t; 119 | struct po_parser pb, *p = &pb; 120 | char line[8192], conv[32768], *lb; 121 | 122 | files->stage = ps_size; 123 | files->len = 0; 124 | poparser_init(p, conv, sizeof(conv), process_line_callback, files); 125 | while((lb = fgets(line, sizeof(line), files->po))) { 126 | if ((t = poparser_feed_line(p, lb, strlen(line))) != po_success) 127 | return t; 128 | } 129 | if ((t = poparser_finish(p)) != po_success) 130 | free(files->buf); 131 | 132 | files->stage = ps_parse; 133 | files->len *= 2; 134 | files->buf = (char*)malloc(files->len); 135 | fseek(files->po, 0, SEEK_SET); 136 | 137 | while((lb = fgets(line, sizeof(line), files->po))) { 138 | if ((t = poparser_feed_line(p, lb, strlen(line))) != po_success) { 139 | free(files->buf); 140 | return t; 141 | } 142 | } 143 | if ((t = poparser_finish(p)) != po_success) { 144 | free(files->buf); 145 | return t; 146 | } 147 | 148 | free(files->buf); 149 | return 0; 150 | } 151 | 152 | void set_file(int out, char* fn, FILE** dest) { 153 | if(streq(fn, "-")) { 154 | *dest = out ? stdout : stdin; 155 | } else { 156 | *dest = fopen(fn, out ? "w" : "r"); 157 | } 158 | if(!*dest) { 159 | perror("fopen"); 160 | exit(1); 161 | } 162 | } 163 | 164 | int getbackuptype(char* str) { 165 | if(!str || !*str || streq(str, "none") || streq(str, "off")) 166 | return 0; 167 | else if(streq(str, "t") || streq(str, "numbered")) 168 | return 1; 169 | else if(streq(str, "nil") || streq(str, "existing")) 170 | return 2; 171 | else if(streq(str, "simple") || streq(str, "never")) 172 | return 3; 173 | else syntax(); 174 | } 175 | 176 | int main(int argc, char**argv) { 177 | if(argc == 1) syntax(); 178 | int arg = 1; 179 | struct expect { 180 | int out; 181 | int po; 182 | int pot; 183 | int compend; 184 | } expect_fn = { 185 | .out = 0, 186 | .po = 1, 187 | .pot = 0, 188 | .compend = 0, 189 | }; 190 | struct fiLes files = {0,0,0,0,1,0}; 191 | char* backup_suffix = getenv("SIMPLE_BACKUP_SUFFIX"); 192 | if(!backup_suffix) backup_suffix = "~"; 193 | int update = 0; 194 | int backup = getbackuptype(getenv("VERSION_CONTROL")); 195 | char* dest; 196 | set_file(1, "-", &files.out); 197 | #define A argv[arg] 198 | for(; arg < argc; arg++) { 199 | if(A[0] == '-') { 200 | if(A[1] == '-') { 201 | if( 202 | streq(A+2, "strict") || 203 | streq(A+2, "properties-input") || 204 | streq(A+2, "properties-output") || 205 | streq(A+2, "stringtable-input") || 206 | streq(A+2, "stringtable-output") || 207 | streq(A+2, "no-fuzzy-matching") || 208 | streq(A+2, "multi-domain") || 209 | streq(A+2, "previous") || 210 | streq(A+2, "escape") || 211 | streq(A+2, "no-escape") || 212 | streq(A+2, "force-po") || 213 | streq(A+2, "indent") || 214 | streq(A+2, "add-location") || 215 | streq(A+2, "no-location") || 216 | streq(A+2, "no-wrap") || 217 | streq(A+2, "sort-output") || 218 | streq(A+2, "sort-by-file") || 219 | 220 | strstarts(A+2, "lang=") || 221 | strstarts(A+2, "color") || // can be --color or --color=xxx 222 | strstarts(A+2, "style=") || 223 | strstarts(A+2, "width=") || 224 | 225 | streq(A+2, "verbose") || 226 | streq(A+2, "quiet") || 227 | streq(A+2, "silent") ) { 228 | } else if(streq(A+2, "version")) { 229 | version(); 230 | } else if((dest = strstarts(A+2, "output-file="))) { 231 | set_file(1, dest, &files.out); 232 | } else if((dest = strstarts(A+2, "compendium="))) { 233 | set_file(1, dest, &files.compend); 234 | } else if((dest = strstarts(A+2, "suffix="))) { 235 | backup_suffix = dest; 236 | } else if((dest = strstarts(A+2, "directory="))) { 237 | goto nodir; 238 | } else if((dest = strstarts(A+2, "backup"))) { 239 | if (*dest == '=') 240 | backup = getbackuptype(dest + 1); 241 | else 242 | backup = 0; 243 | } else if(streq(A+2, "update")) { 244 | set_update: 245 | update = 1; 246 | } else if(streq(A+2, "help")) syntax(); 247 | 248 | } else if(streq(A + 1, "o")) { 249 | expect_fn.out = 1; 250 | } else if(streq(A + 1, "C")) { 251 | expect_fn.compend = 1; 252 | } else if(streq(A + 1, "U")) { 253 | goto set_update; 254 | } else if( 255 | streq(A+1, "m") || 256 | streq(A+1, "N") || 257 | streq(A+1, "P") || 258 | streq(A+1, "e") || 259 | streq(A+1, "E") || 260 | streq(A+1, "i") || 261 | streq(A+1, "p") || 262 | streq(A+1, "w") || 263 | streq(A+1, "s") || 264 | streq(A+1, "F") || 265 | streq(A+1, "V") || 266 | streq(A+1, "q") 267 | ) { 268 | 269 | } else if (streq(A+1, "v")) { 270 | version(); 271 | } else if (streq(A+1, "D")) { 272 | // no support for -D at this time 273 | nodir: 274 | fprintf(stderr, "EINVAL\n"); 275 | exit(1); 276 | } else if (streq(A+1, "h")) { 277 | syntax(); 278 | } else if(expect_fn.out) { 279 | if(update && streq(A, "/dev/null")) return 0; 280 | set_file(1, A, &files.out); 281 | expect_fn.out = 0; 282 | } else if(expect_fn.compend) { 283 | set_file(1, A, &files.compend); 284 | expect_fn.compend = 0; 285 | } else if(expect_fn.po) { 286 | if(update && streq(A, "/dev/null")) return 0; 287 | set_file(0, A, &files.po); 288 | expect_fn.po = 0; 289 | expect_fn.pot = 1; 290 | } else if(expect_fn.pot) { 291 | if(update && streq(A, "/dev/null")) return 0; 292 | set_file(0, A, &files.pot); 293 | expect_fn.pot = 0; 294 | } 295 | 296 | } else if(expect_fn.out) { 297 | if(update && streq(A, "/dev/null")) return 0; 298 | set_file(1, A, &files.out); 299 | expect_fn.out = 0; 300 | } else if(expect_fn.compend) { 301 | set_file(1, A, &files.compend); 302 | expect_fn.compend = 0; 303 | } else if(expect_fn.po) { 304 | if(update && streq(A, "/dev/null")) return 0; 305 | set_file(0, A, &files.po); 306 | expect_fn.po = 0; 307 | expect_fn.pot = 1; 308 | } else if(expect_fn.pot) { 309 | if(update && streq(A, "/dev/null")) return 0; 310 | set_file(0, A, &files.pot); 311 | expect_fn.pot = 0; 312 | } 313 | } 314 | if(update) { 315 | fprintf(stdout, "warning: update functionality unimplemented\n"); 316 | return 0; 317 | } 318 | if(!files.out || !files.po || !files.pot) syntax(); 319 | int ret = process(&files, update, backup); 320 | FILE** filearr = (FILE**) &files; 321 | unsigned i; 322 | for (i = 0; i < 4; i++) { 323 | if(filearr[i] != NULL) fflush(filearr[i]); 324 | } 325 | for (i = 0; i < 4; i++) { 326 | if( 327 | filearr[i] != NULL && 328 | filearr[i] != stdout && 329 | filearr[i] != stdin 330 | ) fclose(filearr[i]); 331 | } 332 | return ret; 333 | } 334 | -------------------------------------------------------------------------------- /m4/lib-prefix.m4: -------------------------------------------------------------------------------- 1 | # lib-prefix.m4 serial 8 2 | dnl Copyright (C) 2001-2005, 2008-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and 10 | dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't 11 | dnl require excessive bracketing. 12 | ifdef([AC_HELP_STRING], 13 | [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], 14 | [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) 15 | 16 | dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed 17 | dnl to access previously installed libraries. The basic assumption is that 18 | dnl a user will want packages to use other packages he previously installed 19 | dnl with the same --prefix option. 20 | dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate 21 | dnl libraries, but is otherwise very convenient. 22 | AC_DEFUN([AC_LIB_PREFIX], 23 | [ 24 | AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) 25 | AC_REQUIRE([AC_PROG_CC]) 26 | AC_REQUIRE([AC_CANONICAL_HOST]) 27 | AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) 28 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 29 | dnl By default, look in $includedir and $libdir. 30 | use_additional=yes 31 | AC_LIB_WITH_FINAL_PREFIX([ 32 | eval additional_includedir=\"$includedir\" 33 | eval additional_libdir=\"$libdir\" 34 | ]) 35 | AC_LIB_ARG_WITH([lib-prefix], 36 | [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib 37 | --without-lib-prefix don't search for libraries in includedir and libdir], 38 | [ 39 | if test "X$withval" = "Xno"; then 40 | use_additional=no 41 | else 42 | if test "X$withval" = "X"; then 43 | AC_LIB_WITH_FINAL_PREFIX([ 44 | eval additional_includedir=\"$includedir\" 45 | eval additional_libdir=\"$libdir\" 46 | ]) 47 | else 48 | additional_includedir="$withval/include" 49 | additional_libdir="$withval/$acl_libdirstem" 50 | fi 51 | fi 52 | ]) 53 | if test $use_additional = yes; then 54 | dnl Potentially add $additional_includedir to $CPPFLAGS. 55 | dnl But don't add it 56 | dnl 1. if it's the standard /usr/include, 57 | dnl 2. if it's already present in $CPPFLAGS, 58 | dnl 3. if it's /usr/local/include and we are using GCC on Linux, 59 | dnl 4. if it doesn't exist as a directory. 60 | if test "X$additional_includedir" != "X/usr/include"; then 61 | haveit= 62 | for x in $CPPFLAGS; do 63 | AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 64 | if test "X$x" = "X-I$additional_includedir"; then 65 | haveit=yes 66 | break 67 | fi 68 | done 69 | if test -z "$haveit"; then 70 | if test "X$additional_includedir" = "X/usr/local/include"; then 71 | if test -n "$GCC"; then 72 | case $host_os in 73 | linux* | gnu* | k*bsd*-gnu) haveit=yes;; 74 | esac 75 | fi 76 | fi 77 | if test -z "$haveit"; then 78 | if test -d "$additional_includedir"; then 79 | dnl Really add $additional_includedir to $CPPFLAGS. 80 | CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" 81 | fi 82 | fi 83 | fi 84 | fi 85 | dnl Potentially add $additional_libdir to $LDFLAGS. 86 | dnl But don't add it 87 | dnl 1. if it's the standard /usr/lib, 88 | dnl 2. if it's already present in $LDFLAGS, 89 | dnl 3. if it's /usr/local/lib and we are using GCC on Linux, 90 | dnl 4. if it doesn't exist as a directory. 91 | if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then 92 | haveit= 93 | for x in $LDFLAGS; do 94 | AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 95 | if test "X$x" = "X-L$additional_libdir"; then 96 | haveit=yes 97 | break 98 | fi 99 | done 100 | if test -z "$haveit"; then 101 | if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then 102 | if test -n "$GCC"; then 103 | case $host_os in 104 | linux*) haveit=yes;; 105 | esac 106 | fi 107 | fi 108 | if test -z "$haveit"; then 109 | if test -d "$additional_libdir"; then 110 | dnl Really add $additional_libdir to $LDFLAGS. 111 | LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" 112 | fi 113 | fi 114 | fi 115 | fi 116 | fi 117 | ]) 118 | 119 | dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, 120 | dnl acl_final_exec_prefix, containing the values to which $prefix and 121 | dnl $exec_prefix will expand at the end of the configure script. 122 | AC_DEFUN([AC_LIB_PREPARE_PREFIX], 123 | [ 124 | dnl Unfortunately, prefix and exec_prefix get only finally determined 125 | dnl at the end of configure. 126 | if test "X$prefix" = "XNONE"; then 127 | acl_final_prefix="$ac_default_prefix" 128 | else 129 | acl_final_prefix="$prefix" 130 | fi 131 | if test "X$exec_prefix" = "XNONE"; then 132 | acl_final_exec_prefix='${prefix}' 133 | else 134 | acl_final_exec_prefix="$exec_prefix" 135 | fi 136 | acl_save_prefix="$prefix" 137 | prefix="$acl_final_prefix" 138 | eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" 139 | prefix="$acl_save_prefix" 140 | ]) 141 | 142 | dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the 143 | dnl variables prefix and exec_prefix bound to the values they will have 144 | dnl at the end of the configure script. 145 | AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], 146 | [ 147 | acl_save_prefix="$prefix" 148 | prefix="$acl_final_prefix" 149 | acl_save_exec_prefix="$exec_prefix" 150 | exec_prefix="$acl_final_exec_prefix" 151 | $1 152 | exec_prefix="$acl_save_exec_prefix" 153 | prefix="$acl_save_prefix" 154 | ]) 155 | 156 | dnl AC_LIB_PREPARE_MULTILIB creates 157 | dnl - a variable acl_libdirstem, containing the basename of the libdir, either 158 | dnl "lib" or "lib64" or "lib/64", 159 | dnl - a variable acl_libdirstem2, as a secondary possible value for 160 | dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or 161 | dnl "lib/amd64". 162 | AC_DEFUN([AC_LIB_PREPARE_MULTILIB], 163 | [ 164 | dnl There is no formal standard regarding lib and lib64. 165 | dnl On glibc systems, the current practice is that on a system supporting 166 | dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under 167 | dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine 168 | dnl the compiler's default mode by looking at the compiler's library search 169 | dnl path. If at least one of its elements ends in /lib64 or points to a 170 | dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. 171 | dnl Otherwise we use the default, namely "lib". 172 | dnl On Solaris systems, the current practice is that on a system supporting 173 | dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under 174 | dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or 175 | dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. 176 | AC_REQUIRE([AC_CANONICAL_HOST]) 177 | dnl Allow the user to override the result by setting acl_cv_libdirstems. 178 | AC_CACHE_CHECK([for the common suffixes of directories in the library search path], 179 | [acl_cv_libdirstems], 180 | [acl_libdirstem=lib 181 | acl_libdirstem2= 182 | case "$host_os" in 183 | solaris*) 184 | dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment 185 | dnl . 186 | dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." 187 | dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the 188 | dnl symlink is missing, so we set acl_libdirstem2 too. 189 | AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], 190 | [AC_EGREP_CPP([sixtyfour bits], [ 191 | #ifdef _LP64 192 | sixtyfour bits 193 | #endif 194 | ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) 195 | ]) 196 | if test $gl_cv_solaris_64bit = yes; then 197 | acl_libdirstem=lib/64 198 | case "$host_cpu" in 199 | sparc*) acl_libdirstem2=lib/sparcv9 ;; 200 | i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; 201 | esac 202 | fi 203 | ;; 204 | *) 205 | dnl The result is a property of the system. However, non-system 206 | dnl compilers sometimes have odd library search paths. Therefore 207 | dnl prefer asking /usr/bin/gcc, if available, rather than $CC. 208 | searchpath=`(if test -f /usr/bin/gcc \ 209 | && LC_ALL=C /usr/bin/gcc -print-search-dirs >/dev/null 2>/dev/null; then \ 210 | LC_ALL=C /usr/bin/gcc -print-search-dirs; \ 211 | else \ 212 | LC_ALL=C $CC -print-search-dirs; \ 213 | fi) 2>/dev/null \ 214 | | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` 215 | if test -n "$searchpath"; then 216 | acl_save_IFS="${IFS= }"; IFS=":" 217 | for searchdir in $searchpath; do 218 | if test -d "$searchdir"; then 219 | case "$searchdir" in 220 | */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; 221 | */../ | */.. ) 222 | # Better ignore directories of this form. They are misleading. 223 | ;; 224 | *) searchdir=`cd "$searchdir" && pwd` 225 | case "$searchdir" in 226 | */lib64 ) acl_libdirstem=lib64 ;; 227 | esac ;; 228 | esac 229 | fi 230 | done 231 | IFS="$acl_save_IFS" 232 | fi 233 | ;; 234 | esac 235 | test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" 236 | acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2" 237 | ]) 238 | # Decompose acl_cv_libdirstems into acl_libdirstem and acl_libdirstem2. 239 | acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'` 240 | acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e '/,/s/.*,//'` 241 | ]) 242 | -------------------------------------------------------------------------------- /m4/iconv.m4: -------------------------------------------------------------------------------- 1 | # iconv.m4 serial 20 2 | dnl Copyright (C) 2000-2002, 2007-2014, 2016 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], 10 | [ 11 | dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. 12 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 13 | AC_REQUIRE([AC_LIB_RPATH]) 14 | 15 | dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV 16 | dnl accordingly. 17 | AC_LIB_LINKFLAGS_BODY([iconv]) 18 | ]) 19 | 20 | AC_DEFUN([AM_ICONV_LINK], 21 | [ 22 | dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and 23 | dnl those with the standalone portable GNU libiconv installed). 24 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 25 | 26 | dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV 27 | dnl accordingly. 28 | AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) 29 | 30 | dnl Add $INCICONV to CPPFLAGS before performing the following checks, 31 | dnl because if the user has installed libiconv and not disabled its use 32 | dnl via --without-libiconv-prefix, he wants to use it. The first 33 | dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. 34 | am_save_CPPFLAGS="$CPPFLAGS" 35 | AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) 36 | 37 | AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ 38 | am_cv_func_iconv="no, consider installing GNU libiconv" 39 | am_cv_lib_iconv=no 40 | AC_LINK_IFELSE( 41 | [AC_LANG_PROGRAM( 42 | [[ 43 | #include 44 | #include 45 | ]], 46 | [[iconv_t cd = iconv_open("",""); 47 | iconv(cd,NULL,NULL,NULL,NULL); 48 | iconv_close(cd);]])], 49 | [am_cv_func_iconv=yes]) 50 | if test "$am_cv_func_iconv" != yes; then 51 | am_save_LIBS="$LIBS" 52 | LIBS="$LIBS $LIBICONV" 53 | AC_LINK_IFELSE( 54 | [AC_LANG_PROGRAM( 55 | [[ 56 | #include 57 | #include 58 | ]], 59 | [[iconv_t cd = iconv_open("",""); 60 | iconv(cd,NULL,NULL,NULL,NULL); 61 | iconv_close(cd);]])], 62 | [am_cv_lib_iconv=yes] 63 | [am_cv_func_iconv=yes]) 64 | LIBS="$am_save_LIBS" 65 | fi 66 | ]) 67 | if test "$am_cv_func_iconv" = yes; then 68 | AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ 69 | dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, 70 | dnl Solaris 10. 71 | am_save_LIBS="$LIBS" 72 | if test $am_cv_lib_iconv = yes; then 73 | LIBS="$LIBS $LIBICONV" 74 | fi 75 | am_cv_func_iconv_works=no 76 | for ac_iconv_const in '' 'const'; do 77 | AC_RUN_IFELSE( 78 | [AC_LANG_PROGRAM( 79 | [[ 80 | #include 81 | #include 82 | 83 | #ifndef ICONV_CONST 84 | # define ICONV_CONST $ac_iconv_const 85 | #endif 86 | ]], 87 | [[int result = 0; 88 | /* Test against AIX 5.1 bug: Failures are not distinguishable from successful 89 | returns. */ 90 | { 91 | iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); 92 | if (cd_utf8_to_88591 != (iconv_t)(-1)) 93 | { 94 | static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ 95 | char buf[10]; 96 | ICONV_CONST char *inptr = input; 97 | size_t inbytesleft = strlen (input); 98 | char *outptr = buf; 99 | size_t outbytesleft = sizeof (buf); 100 | size_t res = iconv (cd_utf8_to_88591, 101 | &inptr, &inbytesleft, 102 | &outptr, &outbytesleft); 103 | if (res == 0) 104 | result |= 1; 105 | iconv_close (cd_utf8_to_88591); 106 | } 107 | } 108 | /* Test against Solaris 10 bug: Failures are not distinguishable from 109 | successful returns. */ 110 | { 111 | iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); 112 | if (cd_ascii_to_88591 != (iconv_t)(-1)) 113 | { 114 | static ICONV_CONST char input[] = "\263"; 115 | char buf[10]; 116 | ICONV_CONST char *inptr = input; 117 | size_t inbytesleft = strlen (input); 118 | char *outptr = buf; 119 | size_t outbytesleft = sizeof (buf); 120 | size_t res = iconv (cd_ascii_to_88591, 121 | &inptr, &inbytesleft, 122 | &outptr, &outbytesleft); 123 | if (res == 0) 124 | result |= 2; 125 | iconv_close (cd_ascii_to_88591); 126 | } 127 | } 128 | /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ 129 | { 130 | iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); 131 | if (cd_88591_to_utf8 != (iconv_t)(-1)) 132 | { 133 | static ICONV_CONST char input[] = "\304"; 134 | static char buf[2] = { (char)0xDE, (char)0xAD }; 135 | ICONV_CONST char *inptr = input; 136 | size_t inbytesleft = 1; 137 | char *outptr = buf; 138 | size_t outbytesleft = 1; 139 | size_t res = iconv (cd_88591_to_utf8, 140 | &inptr, &inbytesleft, 141 | &outptr, &outbytesleft); 142 | if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) 143 | result |= 4; 144 | iconv_close (cd_88591_to_utf8); 145 | } 146 | } 147 | #if 0 /* This bug could be worked around by the caller. */ 148 | /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ 149 | { 150 | iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); 151 | if (cd_88591_to_utf8 != (iconv_t)(-1)) 152 | { 153 | static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; 154 | char buf[50]; 155 | ICONV_CONST char *inptr = input; 156 | size_t inbytesleft = strlen (input); 157 | char *outptr = buf; 158 | size_t outbytesleft = sizeof (buf); 159 | size_t res = iconv (cd_88591_to_utf8, 160 | &inptr, &inbytesleft, 161 | &outptr, &outbytesleft); 162 | if ((int)res > 0) 163 | result |= 8; 164 | iconv_close (cd_88591_to_utf8); 165 | } 166 | } 167 | #endif 168 | /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is 169 | provided. */ 170 | if (/* Try standardized names. */ 171 | iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) 172 | /* Try IRIX, OSF/1 names. */ 173 | && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) 174 | /* Try AIX names. */ 175 | && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) 176 | /* Try HP-UX names. */ 177 | && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) 178 | result |= 16; 179 | return result; 180 | ]])], 181 | [am_cv_func_iconv_works=yes], , 182 | [case "$host_os" in 183 | aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; 184 | *) am_cv_func_iconv_works="guessing yes" ;; 185 | esac]) 186 | test "$am_cv_func_iconv_works" = no || break 187 | done 188 | LIBS="$am_save_LIBS" 189 | ]) 190 | case "$am_cv_func_iconv_works" in 191 | *no) am_func_iconv=no am_cv_lib_iconv=no ;; 192 | *) am_func_iconv=yes ;; 193 | esac 194 | else 195 | am_func_iconv=no am_cv_lib_iconv=no 196 | fi 197 | if test "$am_func_iconv" = yes; then 198 | AC_DEFINE([HAVE_ICONV], [1], 199 | [Define if you have the iconv() function and it works.]) 200 | fi 201 | if test "$am_cv_lib_iconv" = yes; then 202 | AC_MSG_CHECKING([how to link with libiconv]) 203 | AC_MSG_RESULT([$LIBICONV]) 204 | else 205 | dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV 206 | dnl either. 207 | CPPFLAGS="$am_save_CPPFLAGS" 208 | LIBICONV= 209 | LTLIBICONV= 210 | fi 211 | AC_SUBST([LIBICONV]) 212 | AC_SUBST([LTLIBICONV]) 213 | ]) 214 | 215 | dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to 216 | dnl avoid warnings like 217 | dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". 218 | dnl This is tricky because of the way 'aclocal' is implemented: 219 | dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. 220 | dnl Otherwise aclocal's initial scan pass would miss the macro definition. 221 | dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. 222 | dnl Otherwise aclocal would emit many "Use of uninitialized value $1" 223 | dnl warnings. 224 | m4_define([gl_iconv_AC_DEFUN], 225 | m4_version_prereq([2.64], 226 | [[AC_DEFUN_ONCE( 227 | [$1], [$2])]], 228 | [m4_ifdef([gl_00GNULIB], 229 | [[AC_DEFUN_ONCE( 230 | [$1], [$2])]], 231 | [[AC_DEFUN( 232 | [$1], [$2])]])])) 233 | gl_iconv_AC_DEFUN([AM_ICONV], 234 | [ 235 | AM_ICONV_LINK 236 | if test "$am_cv_func_iconv" = yes; then 237 | AC_MSG_CHECKING([for iconv declaration]) 238 | AC_CACHE_VAL([am_cv_proto_iconv], [ 239 | AC_COMPILE_IFELSE( 240 | [AC_LANG_PROGRAM( 241 | [[ 242 | #include 243 | #include 244 | extern 245 | #ifdef __cplusplus 246 | "C" 247 | #endif 248 | #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) 249 | size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); 250 | #else 251 | size_t iconv(); 252 | #endif 253 | ]], 254 | [[]])], 255 | [am_cv_proto_iconv_arg1=""], 256 | [am_cv_proto_iconv_arg1="const"]) 257 | am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) 258 | am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` 259 | AC_MSG_RESULT([ 260 | $am_cv_proto_iconv]) 261 | else 262 | dnl When compiling GNU libiconv on a system that does not have iconv yet, 263 | dnl pick the POSIX compliant declaration without 'const'. 264 | am_cv_proto_iconv_arg1="" 265 | fi 266 | AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], 267 | [Define as const if the declaration of iconv() needs const.]) 268 | dnl Also substitute ICONV_CONST in the gnulib generated . 269 | m4_ifdef([gl_ICONV_H_DEFAULTS], 270 | [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) 271 | if test -n "$am_cv_proto_iconv_arg1"; then 272 | ICONV_CONST="const" 273 | fi 274 | ]) 275 | ]) 276 | -------------------------------------------------------------------------------- /src/msgfmt.c: -------------------------------------------------------------------------------- 1 | /* msgfmt utility (C) 2012 rofl0r 2 | * released under the MIT license, see LICENSE for details */ 3 | #define _BSD_SOURCE 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "poparser.h" 12 | 13 | enum mode { 14 | m_normal = 0, 15 | m_java, 16 | m_java2, 17 | m_csharp, 18 | m_csharp_resources, 19 | m_tcl, 20 | m_qt, 21 | m_desktop, 22 | m_xml 23 | }; 24 | 25 | static void syntax(void) { 26 | fprintf(stdout, "Usage: msgfmt [OPTION] filename.po ...\n"); 27 | } 28 | 29 | static void version(void) { 30 | fprintf(stdout, "msgfmt (GNU gettext-tools compatible) 99.9999.9999\n"); 31 | } 32 | 33 | #define streq(A, B) (!strcmp(A, B)) 34 | #define strstarts(S, W) (memcmp(S, W, sizeof(W) - 1) ? NULL : (S + (sizeof(W) - 1))) 35 | 36 | struct mo_hdr { 37 | unsigned magic; 38 | int rev; 39 | unsigned numstring; 40 | unsigned off_tbl_org; 41 | unsigned off_tbl_trans; 42 | unsigned hash_tbl_size; 43 | unsigned off_tbl_hash; 44 | }; 45 | 46 | /* file layout: 47 | header 48 | strtable (lengths/offsets) 49 | transtable (lengths/offsets) 50 | [hashtable] 51 | strings section 52 | translations section */ 53 | 54 | const struct mo_hdr def_hdr = { 55 | 0x950412de, 56 | 0, 57 | 0, 58 | sizeof(struct mo_hdr), 59 | 0, 60 | 0, 61 | 0, 62 | }; 63 | 64 | struct strtbl { 65 | uint32_t len, off; 66 | }; 67 | 68 | struct strmap { 69 | struct strtbl str; 70 | struct strtbl trans; 71 | }; 72 | 73 | struct callbackdata { 74 | FILE* out; 75 | enum po_stage stage; 76 | size_t cnt; 77 | size_t len[2]; 78 | char* buf[2]; 79 | struct strmap *list; 80 | }; 81 | 82 | static struct callbackdata *cb_for_qsort; 83 | int strtbl_cmp(const void *a_, const void *b_) { 84 | const struct strmap *a = a_, *b = b_; 85 | return strcmp(cb_for_qsort->buf[0] + a->str.off, cb_for_qsort->buf[0] + b->str.off); 86 | } 87 | 88 | int process_line_callback(po_message_t msg, void* user) { 89 | struct callbackdata *d = (struct callbackdata *) user; 90 | struct strtbl *str, *trans; 91 | size_t m; 92 | int i, j, k = msg->sysdep; 93 | 94 | if (msg->flags & PO_FUZZY) return 0; 95 | if (msg->strlen[0] == 0) return 0; 96 | 97 | switch(d->stage) { 98 | case ps_size: 99 | m = 0; 100 | m += msg->id_len + 1; 101 | 102 | if (msg->plural_len) 103 | m += msg->plural_len + 1; 104 | 105 | if (msg->ctxt_len) 106 | m += msg->ctxt_len + 1; 107 | 108 | d->len[0] += m * k; 109 | 110 | m = 0; 111 | for (i=0; msg->strlen[i]; i++) { 112 | m += msg->strlen[i] + 1; 113 | } 114 | d->len[1] += m * k; 115 | 116 | d->cnt += k; 117 | break; 118 | case ps_parse: 119 | for (j=0; j < k; j++) { 120 | str = &d->list[d->cnt].str; 121 | trans = &d->list[d->cnt].trans; 122 | 123 | str->off = d->len[0]; 124 | str->len = 0; 125 | 126 | if (msg->ctxt_len) { 127 | m = poparser_sysdep(msg->ctxt, &d->buf[0][d->len[0]], j); 128 | str->len += m + 1; 129 | d->buf[0][d->len[0]+m] = 0x4; 130 | d->len[0] += m + 1; 131 | } 132 | 133 | m = poparser_sysdep(msg->id, &d->buf[0][d->len[0]], j); 134 | str->len += m; 135 | d->len[0] += m + 1; 136 | 137 | if (msg->plural_len) { 138 | m = poparser_sysdep(msg->plural, &d->buf[0][d->len[0]], j); 139 | str->len += m + 1; 140 | d->len[0] += m + 1; 141 | } 142 | 143 | trans->off = d->len[1]; 144 | trans->len = -1; 145 | for (i=0; msg->strlen[i]; i++) { 146 | m = poparser_sysdep(msg->str[i], &d->buf[1][d->len[1]], j); 147 | trans->len += m + 1; 148 | d->len[1] += m + 1; 149 | } 150 | 151 | d->cnt++; 152 | } 153 | 154 | break; 155 | default: 156 | abort(); 157 | } 158 | return 0; 159 | } 160 | 161 | int process(FILE *in, FILE *out, bool strict) { 162 | struct mo_hdr mohdr = def_hdr; 163 | char line[8192]; char *lp; 164 | size_t off, i; 165 | enum po_error t; 166 | char convbuf[32768]; 167 | 168 | struct callbackdata d = { 169 | .len = {0, 0}, 170 | .cnt = 0, 171 | .out = out, 172 | }; 173 | 174 | struct po_parser pb, *p = &pb; 175 | 176 | mohdr.off_tbl_trans = mohdr.off_tbl_org; 177 | 178 | poparser_init(p, convbuf, sizeof(convbuf), process_line_callback, &d); 179 | p->strict = strict; 180 | d.stage = p->stage; 181 | 182 | while((lp = fgets(line, sizeof(line), in))) { 183 | if ((t = poparser_feed_line(p, lp, strlen(line))) != po_success) 184 | return t; 185 | } 186 | if ((t = poparser_finish(p)) != po_success) 187 | return t; 188 | 189 | if (strict && d.cnt == 0) return -(po_error_last+1); 190 | 191 | d.list = (struct strmap*)malloc(sizeof(struct strmap)*d.cnt); 192 | d.buf[0] = (char*)malloc(d.len[0]); 193 | d.buf[1] = (char*)malloc(d.len[1]); 194 | d.len[0] = 0; 195 | d.len[1] = 0; 196 | d.cnt = 0; 197 | d.stage = p->stage; 198 | 199 | fseek(in, 0, SEEK_SET); 200 | while ((lp = fgets(line, sizeof(line), in))) { 201 | if ((t = poparser_feed_line(p, lp, strlen(line))) != po_success) { 202 | free(d.list); 203 | free(d.buf[0]); 204 | free(d.buf[1]); 205 | return t; 206 | } 207 | } 208 | if ((t = poparser_finish(p)) != po_success) { 209 | free(d.list); 210 | free(d.buf[0]); 211 | free(d.buf[1]); 212 | return t; 213 | } 214 | 215 | cb_for_qsort = &d; 216 | qsort(d.list, d.cnt, sizeof(struct strmap), strtbl_cmp); 217 | cb_for_qsort = NULL; 218 | 219 | // print header 220 | mohdr.numstring = d.cnt; 221 | mohdr.off_tbl_org = sizeof(struct mo_hdr); 222 | mohdr.off_tbl_trans = mohdr.off_tbl_org + d.cnt * sizeof(struct strtbl); 223 | fwrite(&mohdr, sizeof(mohdr), 1, out); 224 | 225 | off = mohdr.off_tbl_trans + d.cnt * sizeof(struct strtbl); 226 | for (i = 0; i < d.cnt; i++) { 227 | d.list[i].str.off += off; 228 | fwrite(&d.list[i].str, sizeof(struct strtbl), 1, d.out); 229 | } 230 | 231 | off += d.len[0]; 232 | for (i = 0; i < d.cnt; i++) { 233 | d.list[i].trans.off += off; 234 | fwrite(&d.list[i].trans, sizeof(struct strtbl), 1, d.out); 235 | } 236 | 237 | fwrite(d.buf[0], d.len[0], 1, d.out); 238 | fwrite(d.buf[1], d.len[1], 1, d.out); 239 | 240 | free(d.list); 241 | free(d.buf[0]); 242 | free(d.buf[1]); 243 | 244 | return 0; 245 | } 246 | 247 | void set_file(int out, char* fn, FILE** dest) { 248 | char b[4096]; 249 | size_t n; 250 | FILE *tmpf = NULL; 251 | 252 | if(streq(fn, "-")) { 253 | if(out) { 254 | *dest = stdout; 255 | } else { 256 | tmpf = tmpfile(); 257 | if(!tmpf) { 258 | perror("tmpfile"); 259 | exit(1); 260 | } 261 | *dest = tmpf; 262 | 263 | while((n=fread(b, sizeof(*b), sizeof(b), stdin)) > 0) 264 | fwrite(b, sizeof(*b), n, tmpf); 265 | 266 | fseek(tmpf, 0, SEEK_SET); 267 | } 268 | } else { 269 | *dest = fopen(fn, out ? "w" : "r"); 270 | } 271 | 272 | if(!*dest) { 273 | perror("fopen"); 274 | exit(1); 275 | } 276 | } 277 | 278 | int main(int argc, char**argv) { 279 | if (argc == 1) { 280 | syntax(); 281 | return 1; 282 | } 283 | 284 | int arg = 1; 285 | enum mode mode = m_normal; 286 | bool strict = false; 287 | FILE *out = NULL; 288 | FILE *in = NULL; 289 | int expect_in_fn = 0; 290 | char path[PATH_MAX]; 291 | char buf[4096]; 292 | size_t n; 293 | int ret = 0; 294 | char* locale = NULL; 295 | char* dest = NULL; 296 | 297 | #define A argv[arg] 298 | for(; arg < argc; arg++) { 299 | if(A[0] == '-') { 300 | if(A[1] == '-') { 301 | if( 302 | streq(A+2, "template") || 303 | streq(A+2, "strict") || 304 | streq(A+2, "properties-input") || 305 | streq(A+2, "stringtable-input") || 306 | streq(A+2, "use-fuzzy") || 307 | strstarts(A+2, "alignment=") || 308 | streq(A+2, "check-format") || 309 | streq(A+2, "check-header") || 310 | streq(A+2, "check-domain") || 311 | streq(A+2, "check-compatibility") || 312 | streq(A+2, "check-accelerators") || 313 | streq(A+2, "no-hash") || 314 | streq(A+2, "verbose") || 315 | streq(A+2, "statistics") || 316 | strstarts(A+2, "keyword=") || 317 | strstarts(A+2, "check-accelerators=") || 318 | strstarts(A+2, "resource=") 319 | ) { 320 | } else if(streq(A+2, "java")) { 321 | mode = m_java; 322 | } else if(streq(A+2, "java2")) { 323 | mode = m_java2; 324 | } else if(streq(A+2, "csharp")) { 325 | mode = m_csharp; 326 | } else if(streq(A+2, "csharp-resources")) { 327 | mode = m_csharp_resources; 328 | } else if(streq(A+2, "tcl")) { 329 | mode = m_tcl; 330 | } else if(streq(A+2, "qt")) { 331 | mode = m_qt; 332 | } else if(streq(A+2, "desktop")) { 333 | mode = m_desktop; 334 | } else if(streq(A+2, "xml")) { 335 | mode = m_xml; 336 | } else if(streq(A+2, "keyword")) { 337 | arg++; 338 | } else if((locale = strstarts(A+2, "locale="))) { 339 | } else if(streq(A+2, "check")) { 340 | strict = true; 341 | } else if(strstarts(A+2, "template=")) { 342 | set_file(0, A+11, &in); 343 | expect_in_fn = 0; 344 | } else if(strstarts(A+2, "output-file=")) { 345 | set_file(1, A+14, &out); 346 | } else if(strstarts(A+2, "output=")) { 347 | set_file(1, A+9, &out); 348 | } else if(streq(A+2, "version")) { 349 | version(); 350 | return 0; 351 | } else if(streq(A+2, "help")) { 352 | syntax(); 353 | return 0; 354 | } else expect_in_fn = 1; 355 | } else if(streq(A + 1, "o")) { 356 | arg++; 357 | set_file(1, A, &out); 358 | } else if( 359 | streq(A+1, "j") || 360 | streq(A+1, "r") || 361 | streq(A+1, "P") || 362 | streq(A+1, "f") || 363 | streq(A+1, "a") || 364 | streq(A+1, "v") || 365 | streq(A+1, "C") 366 | ) { 367 | } else if (streq(A+1, "c")) { 368 | strict = true; 369 | } else if (streq(A+1, "V")) { 370 | version(); 371 | return 0; 372 | } else if ( 373 | streq(A+1, "h") || 374 | // D means find input files in the specific directory 375 | // we should fail this option explicitly 376 | streq(A+1, "D") 377 | ) { 378 | syntax(); 379 | return 1; 380 | } else if (streq(A+1, "l")) { 381 | arg++; 382 | locale = A; 383 | } else if (streq(A+1, "d")) { 384 | arg++; 385 | dest = A; 386 | } else expect_in_fn = 1; 387 | } else expect_in_fn = 1; 388 | 389 | if (expect_in_fn) { 390 | set_file(0, A, &in); 391 | expect_in_fn = 0; 392 | } 393 | } 394 | 395 | switch (mode) { 396 | case m_tcl: 397 | if (locale == NULL || dest == NULL) { 398 | return -1; 399 | } 400 | 401 | snprintf(path, sizeof(path), "%s/%s.msg", dest, locale); 402 | out = fopen(path, "w"); 403 | 404 | if (out == NULL) { 405 | perror("fopen"); 406 | ret = -1; 407 | } 408 | break; 409 | case m_desktop: 410 | case m_xml: 411 | while((n = fread(buf, sizeof(buf[0]), sizeof(buf), in)) > 0) 412 | fwrite(buf, sizeof(buf[0]), n, out); 413 | 414 | break; 415 | case m_normal: 416 | if(out == NULL) { 417 | set_file(1, "messages.mo", &out); 418 | } 419 | 420 | if(in == NULL || out == NULL) { 421 | return -1; 422 | } 423 | 424 | ret = process(in, out, strict); 425 | break; 426 | default: 427 | fprintf(stderr, "unsupported mode %d\n", mode); 428 | ret = -1; 429 | } 430 | 431 | if(in == stdin) 432 | fflush(in); 433 | else 434 | fclose(in); 435 | 436 | if(out == stdout) 437 | fflush(out); 438 | else 439 | fclose(out); 440 | 441 | if (ret < 0) remove(dest); 442 | return ret; 443 | } 444 | -------------------------------------------------------------------------------- /src/poparser.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "poparser.h" 7 | #include "StringEscape.h" 8 | 9 | #define strstarts(S, W) (memcmp(S, W, sizeof(W) - 1) ? NULL : (S + (sizeof(W) - 1))) 10 | 11 | #define PO_SYSDEP_PRIU32 (1 << st_priu32) 12 | #define PO_SYSDEP_PRIU64 (1 << st_priu64) 13 | // for complement, no usage 14 | #define PO_SYSDEP_PRIUMAX 0 15 | 16 | static const char* sysdep_str[st_max]={ 17 | [st_priu32] = "", 18 | [st_priu64] = "", 19 | [st_priumax] = "", 20 | }; 21 | 22 | static const char* sysdep_repl[st_max][3]={ 23 | [st_priu32] = {"u", "lu", "u"}, 24 | [st_priu64] = {"lu", "llu", "llu"}, 25 | [st_priumax] = {"ju", "ju", "ju"}, 26 | }; 27 | 28 | static const int sysdep[st_max]={ 29 | [st_priu32] = PO_SYSDEP_PRIU32, 30 | [st_priu64] = PO_SYSDEP_PRIU64, 31 | [st_priumax] = PO_SYSDEP_PRIUMAX, 32 | }; 33 | 34 | void poparser_init(struct po_parser *p, char* workbuf, size_t bufsize, poparser_callback cb, void* cbdata) { 35 | int cnt; 36 | memset(p, 0, sizeof(struct po_parser)); 37 | p->buf = workbuf; 38 | p->bufsize = bufsize; 39 | p->cb = cb; 40 | p->cbdata = cbdata; 41 | p->hdr.nplurals = MAX_NPLURALS; 42 | p->max_ctxt_len = 1; 43 | p->max_id_len = 1; 44 | p->max_plural_len = 1; 45 | for (cnt = 0; cnt < MAX_NPLURALS; cnt++) 46 | p->max_strlen[cnt] = 1; 47 | p->strcnt = 0; 48 | p->first = true; 49 | } 50 | 51 | static inline enum po_error poparser_feed_hdr(struct po_parser *p, char* msg) { 52 | char *x, *y; 53 | if (p->first && msg) { 54 | if ((x = strstr(msg, "charset="))) { 55 | for (y = x; *y && *y != '\\' && !isspace(*y); y++); 56 | 57 | if ((uintptr_t)(y-x-7) > sizeof(p->hdr.charset)) 58 | return -po_unsupported_charset; 59 | 60 | memcpy(p->hdr.charset, x+8, y-x-8); 61 | p->hdr.charset[y-x-8] = 0; 62 | 63 | p->cd = iconv_open("UTF-8", p->hdr.charset); 64 | if (p->cd == (iconv_t)-1) { 65 | p->cd = 0; 66 | if (p->strict) return -po_unsupported_charset; 67 | } 68 | } 69 | 70 | if ((x = strstr(msg, "nplurals="))) { 71 | p->hdr.nplurals = *(x+9) - '0'; 72 | } 73 | } 74 | 75 | return po_success; 76 | } 77 | 78 | static inline enum po_error poparser_clean(struct po_parser *p, po_message_t msg) { 79 | if (p->strcnt) { 80 | if (p->first) p->first = false; 81 | 82 | msg->strlen[p->strcnt] = 0; 83 | 84 | // PO_SYSDEP_PRIUMAX == 0, it has no effects to our codes 85 | switch (msg->sysdep) { 86 | case PO_SYSDEP_PRIU32: 87 | case PO_SYSDEP_PRIU64: 88 | msg->sysdep = 2; 89 | break; 90 | case PO_SYSDEP_PRIU32|PO_SYSDEP_PRIU64: 91 | msg->sysdep = 3; 92 | break; 93 | default: 94 | msg->sysdep = 1; 95 | break; 96 | } 97 | 98 | // met a new block starting with msgid 99 | if (p->cb) 100 | p->cb(msg, p->cbdata); 101 | 102 | msg->sysdep = 0; 103 | msg->ctxt_len = 0; 104 | msg->id_len = 0; 105 | msg->plural_len = 0; 106 | msg->flags = 0; 107 | p->strcnt = 0; 108 | } 109 | 110 | return po_success; 111 | } 112 | 113 | enum po_error poparser_feed_line(struct po_parser *p, char* in, size_t in_len) { 114 | char *line = in; 115 | size_t line_len = in_len; 116 | po_message_t msg = &p->msg; 117 | int cnt = 0; 118 | enum po_error t; 119 | size_t len; 120 | char *x, *y, *z; 121 | 122 | if (line_len == 0 || line[0] == '\n') { 123 | // ignore blank lines 124 | return po_success; 125 | } else if (line[0] == '#') { 126 | if (p->previous == po_str) { 127 | if ( (t = poparser_clean(p, msg)) != po_success) 128 | return t; 129 | } 130 | 131 | switch (line[1]) { 132 | case ',': 133 | x = &line[2]; 134 | while (*x && (y = strpbrk(x, " ,\n"))) { 135 | if (y != x && !memcmp(x, "fuzzy", y-x)) { 136 | msg->flags |= PO_FUZZY; 137 | } 138 | x = y + strspn(y, " ,\n"); 139 | } 140 | break; 141 | case '.': 142 | // extracted comments for translators, ignore 143 | case ':': 144 | // reference comments for translators, ignore 145 | case '|': 146 | // previous untranslated strings for translators, ignore 147 | default: 148 | // ignore normal comments 149 | return po_success; 150 | } 151 | } else if (line[0] == '"') { 152 | if ( (y = strrchr(x = &line[1], '"')) == NULL) 153 | return -po_excepted_token; 154 | 155 | len = y - x; 156 | *y = 0; 157 | 158 | if (p->cd) { 159 | line = x; 160 | line_len = len + 1; 161 | x = p->buf; 162 | len = p->bufsize; 163 | if (iconv(p->cd, &line, &line_len, &x, &len) == (size_t)-1) 164 | return -po_failed_iconv; 165 | 166 | if (line_len != 0) 167 | return -po_failed_iconv; 168 | 169 | len = x - p->buf; 170 | x = p->buf; 171 | } 172 | 173 | for (cnt = 0; cnt < st_max; cnt++) { 174 | if (strstr(x, sysdep_str[cnt])) { 175 | msg->sysdep |= sysdep[cnt]; 176 | } 177 | } 178 | 179 | switch (p->previous) { 180 | case po_str: 181 | if ((t = poparser_feed_hdr(p, x)) != po_success) { 182 | return t; 183 | } 184 | 185 | cnt = p->strcnt - 1; 186 | if (p->stage == ps_parse) { 187 | len = unescape(x, &msg->str[cnt][msg->strlen[cnt]], p->max_strlen[cnt]); 188 | } 189 | 190 | msg->strlen[cnt] += len; 191 | break; 192 | case po_plural: 193 | if (p->stage == ps_parse) { 194 | len = unescape(x, &msg->plural[msg->plural_len], p->max_plural_len); 195 | } 196 | 197 | msg->plural_len += len; 198 | break; 199 | case po_id: 200 | if (p->stage == ps_parse) { 201 | len = unescape(x, &msg->id[msg->id_len], p->max_id_len); 202 | } 203 | 204 | msg->id_len += len; 205 | break; 206 | case po_ctxt: 207 | if (p->stage == ps_parse) { 208 | len = unescape(x, &msg->ctxt[msg->ctxt_len], p->max_ctxt_len); 209 | } 210 | 211 | msg->ctxt_len += len; 212 | break; 213 | default: 214 | return -po_invalid_entry; 215 | } 216 | } else if ((z = strstarts(line, "msg"))) { 217 | if ( (x = strchr(z, '"')) == NULL) 218 | return -po_excepted_token; 219 | 220 | if ( (y = strrchr(x+1, '"')) == NULL) 221 | return -po_excepted_token; 222 | 223 | len = y - ++x; 224 | *y = 0; 225 | 226 | if (p->cd) { 227 | line = x; 228 | line_len = len + 1; 229 | x = p->buf; 230 | len = p->bufsize; 231 | 232 | if (iconv(p->cd, &line, &line_len, &x, &len) == (size_t)-1) 233 | return -po_failed_iconv; 234 | 235 | if (line_len != 0) 236 | return -po_failed_iconv; 237 | 238 | len = x - p->buf; 239 | x = p->buf; 240 | } 241 | 242 | if ((y = strstarts(z, "ctxt")) && isspace(*y)) { 243 | if ( (t = poparser_clean(p, msg)) != po_success) 244 | return t; 245 | 246 | if (msg->id_len || msg->plural_len) 247 | return -po_invalid_entry; 248 | 249 | for (cnt = 0; cnt < st_max; cnt++) { 250 | if (strstr(x, sysdep_str[cnt])) { 251 | msg->sysdep |= sysdep[cnt]; 252 | } 253 | } 254 | 255 | if (p->stage == ps_parse) { 256 | if (msg->ctxt == NULL) { 257 | return -po_internal; 258 | } 259 | 260 | len = unescape(x, msg->ctxt, p->max_ctxt_len); 261 | } 262 | 263 | msg->ctxt_len = len; 264 | p->previous = po_ctxt; 265 | } else if ((y = strstarts(z, "id")) && isspace(*y)) { 266 | if ( (t = poparser_clean(p, msg)) != po_success) 267 | return t; 268 | 269 | if (msg->plural_len) 270 | return -po_invalid_entry; 271 | 272 | for (cnt = 0; cnt < st_max; cnt++) { 273 | if (strstr(x, sysdep_str[cnt])) { 274 | msg->sysdep |= sysdep[cnt]; 275 | } 276 | } 277 | 278 | if (p->stage == ps_parse) { 279 | if (msg->id == NULL) { 280 | return -po_internal; 281 | } 282 | 283 | len = unescape(x, msg->id, p->max_id_len); 284 | } 285 | 286 | msg->id_len = len; 287 | p->previous = po_id; 288 | } else if ((y = strstarts(z, "id_plural")) && isspace(*y)) { 289 | if (!msg->id_len || p->strcnt) 290 | return -po_invalid_entry; 291 | 292 | if (p->stage == ps_parse) { 293 | if (msg->plural == NULL) { 294 | return -po_internal; 295 | } 296 | 297 | len = unescape(x, msg->plural, p->max_plural_len); 298 | } 299 | 300 | msg->plural_len = len; 301 | p->previous = po_plural; 302 | } else if ((y = strstarts(z, "str"))) { 303 | if (!msg->id_len && !p->first) 304 | return -po_invalid_entry; 305 | 306 | if (isspace(*y)) { 307 | if (p->strcnt || msg->plural_len) 308 | return -po_invalid_entry; 309 | 310 | cnt = (p->strcnt = 1) - 1; 311 | } else if (*y == '[') { 312 | if (!msg->plural_len) 313 | return -po_invalid_entry; 314 | 315 | if (y[2] != ']' || !isspace(y[3])) return -po_excepted_token; 316 | 317 | p->strcnt = (cnt = y[1] - '0') + 1; 318 | 319 | if (p->strict && p->strcnt > p->hdr.nplurals) { 320 | return -po_plurals_overflow; 321 | } 322 | } else { 323 | return -po_excepted_token; 324 | } 325 | 326 | if ((t = poparser_feed_hdr(p, x)) != po_success) { 327 | return t; 328 | } 329 | 330 | if (p->stage == ps_parse) { 331 | if (msg->str[cnt] == NULL) { 332 | return -po_internal; 333 | } 334 | 335 | len = unescape(x, msg->str[cnt], p->max_strlen[cnt]); 336 | } 337 | 338 | msg->strlen[cnt] = len; 339 | p->previous = po_str; 340 | } else { 341 | return -po_invalid_entry; 342 | } 343 | } 344 | 345 | if (p->stage == ps_size) { 346 | if (p->max_strlen[cnt] < msg->strlen[cnt]) 347 | p->max_strlen[cnt] = msg->strlen[cnt] + 1; 348 | if (p->max_plural_len < msg->plural_len) 349 | p->max_plural_len = msg->plural_len + 1; 350 | if (p->max_id_len < msg->id_len) 351 | p->max_id_len = msg->id_len + 1; 352 | if (p->max_ctxt_len < msg->ctxt_len) 353 | p->max_ctxt_len = msg->ctxt_len + 1; 354 | } 355 | 356 | return po_success; 357 | } 358 | 359 | enum po_error poparser_finish(struct po_parser *p) { 360 | size_t len; 361 | int cnt; 362 | enum po_error t; 363 | po_message_t msg = &p->msg; 364 | 365 | if (p->stage == ps_size) { 366 | if ( (t = poparser_clean(p, msg)) != po_success) 367 | return t; 368 | 369 | len = p->max_ctxt_len; 370 | len += p->max_id_len; 371 | len += p->max_plural_len; 372 | for (cnt = 0; cnt < MAX_NPLURALS; cnt++) 373 | len += p->max_strlen[cnt]; 374 | 375 | memset(msg, 0, sizeof(struct po_message)); 376 | msg->ctxt = (char*)malloc(len); 377 | msg->id = msg->ctxt + p->max_ctxt_len; 378 | msg->plural = msg->id + p->max_id_len; 379 | msg->str[0] = msg->plural + p->max_plural_len; 380 | for (cnt = 1; cnt < MAX_NPLURALS; cnt++) 381 | msg->str[cnt] = msg->str[cnt-1] + p->max_strlen[cnt-1]; 382 | 383 | p->hdr.nplurals = 2; 384 | p->first = true; 385 | } else { 386 | if ( (t = poparser_clean(p, msg)) != po_success) 387 | return t; 388 | if (msg->ctxt) free(msg->ctxt); 389 | if (p->cd) iconv_close(p->cd); 390 | } 391 | 392 | if (p->stage < ps_parse) p->stage++; 393 | 394 | return po_success; 395 | } 396 | 397 | size_t poparser_sysdep(const char *in, char *out, int num) { 398 | const char *x, *y, *outs; 399 | size_t m; 400 | int n; 401 | outs = out; 402 | x = in; 403 | 404 | while ((y = strchr(x, '%'))) { 405 | y++; 406 | if (outs) 407 | memcpy(out, x, y-x); 408 | out += y-x; 409 | x = y; 410 | 411 | for (n=0; n < st_max; n++) { 412 | m = strlen(sysdep_str[n]); 413 | if (!strncmp(y, sysdep_str[n], m)) { 414 | x = y + m; 415 | 416 | y = sysdep_repl[n][num]; 417 | m = strlen(y); 418 | if (outs) 419 | memcpy(out, y, m); 420 | out += m; 421 | 422 | break; 423 | } 424 | } 425 | } 426 | 427 | m = strlen(x); 428 | if (outs) 429 | memcpy(out, x, m+1); 430 | out += m; 431 | return out - outs; 432 | } 433 | -------------------------------------------------------------------------------- /m4/intl.m4: -------------------------------------------------------------------------------- 1 | # intl.m4 serial 29 (gettext-0.19) 2 | dnl Copyright (C) 1995-2014, 2016 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | dnl 7 | dnl This file can be used in projects which are not available under 8 | dnl the GNU General Public License or the GNU Library General Public 9 | dnl License but which still want to provide support for the GNU gettext 10 | dnl functionality. 11 | dnl Please note that the actual code of the GNU gettext library is covered 12 | dnl by the GNU Library General Public License, and the rest of the GNU 13 | dnl gettext package is covered by the GNU General Public License. 14 | dnl They are *not* in the public domain. 15 | 16 | dnl Authors: 17 | dnl Ulrich Drepper , 1995-2000. 18 | dnl Bruno Haible , 2000-2009. 19 | 20 | AC_PREREQ([2.60]) 21 | 22 | dnl Checks for all prerequisites of the intl subdirectory, 23 | dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, 24 | dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL. 25 | AC_DEFUN([AM_INTL_SUBDIR], 26 | [ 27 | AC_REQUIRE([AC_PROG_INSTALL])dnl 28 | AC_REQUIRE([AC_PROG_MKDIR_P])dnl 29 | AC_REQUIRE([AC_PROG_CC])dnl 30 | AC_REQUIRE([AC_CANONICAL_HOST])dnl 31 | AC_REQUIRE([gt_GLIBC2])dnl 32 | AC_REQUIRE([AC_PROG_RANLIB])dnl 33 | AC_REQUIRE([gl_VISIBILITY])dnl 34 | AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl 35 | AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl 36 | AC_REQUIRE([gt_TYPE_WCHAR_T])dnl 37 | AC_REQUIRE([gt_TYPE_WINT_T])dnl 38 | AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) 39 | AC_REQUIRE([gt_TYPE_INTMAX_T]) 40 | AC_REQUIRE([gt_PRINTF_POSIX]) 41 | AC_REQUIRE([gl_GLIBC21])dnl 42 | AC_REQUIRE([gl_XSIZE])dnl 43 | AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl 44 | AC_REQUIRE([gt_INTL_MACOSX])dnl 45 | AC_REQUIRE([gl_EXTERN_INLINE])dnl 46 | AC_REQUIRE([gt_GL_ATTRIBUTE])dnl 47 | 48 | dnl Support for automake's --enable-silent-rules. 49 | case "$enable_silent_rules" in 50 | yes) INTL_DEFAULT_VERBOSITY=0;; 51 | no) INTL_DEFAULT_VERBOSITY=1;; 52 | *) INTL_DEFAULT_VERBOSITY=1;; 53 | esac 54 | AC_SUBST([INTL_DEFAULT_VERBOSITY]) 55 | 56 | AC_CHECK_TYPE([ptrdiff_t], , 57 | [AC_DEFINE([ptrdiff_t], [long], 58 | [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) 59 | ]) 60 | AC_CHECK_HEADERS([features.h stddef.h stdlib.h string.h]) 61 | AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \ 62 | snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) 63 | 64 | dnl Use the _snprintf function only if it is declared (because on NetBSD it 65 | dnl is defined as a weak alias of snprintf; we prefer to use the latter). 66 | AC_CHECK_DECLS([_snprintf, _snwprintf], , , [#include ]) 67 | 68 | dnl Use the *_unlocked functions only if they are declared. 69 | dnl (because some of them were defined without being declared in Solaris 70 | dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built 71 | dnl on Solaris 2.5.1 to run on Solaris 2.6). 72 | AC_CHECK_DECLS([getc_unlocked], , , [#include ]) 73 | 74 | case $gt_cv_func_printf_posix in 75 | *yes) HAVE_POSIX_PRINTF=1 ;; 76 | *) HAVE_POSIX_PRINTF=0 ;; 77 | esac 78 | AC_SUBST([HAVE_POSIX_PRINTF]) 79 | if test "$ac_cv_func_asprintf" = yes; then 80 | HAVE_ASPRINTF=1 81 | else 82 | HAVE_ASPRINTF=0 83 | fi 84 | AC_SUBST([HAVE_ASPRINTF]) 85 | if test "$ac_cv_func_snprintf" = yes; then 86 | HAVE_SNPRINTF=1 87 | else 88 | HAVE_SNPRINTF=0 89 | fi 90 | AC_SUBST([HAVE_SNPRINTF]) 91 | if test "$ac_cv_func_newlocale" = yes; then 92 | HAVE_NEWLOCALE=1 93 | else 94 | HAVE_NEWLOCALE=0 95 | fi 96 | AC_SUBST([HAVE_NEWLOCALE]) 97 | if test "$ac_cv_func_wprintf" = yes; then 98 | HAVE_WPRINTF=1 99 | else 100 | HAVE_WPRINTF=0 101 | fi 102 | AC_SUBST([HAVE_WPRINTF]) 103 | 104 | AM_LANGINFO_CODESET 105 | gt_LC_MESSAGES 106 | 107 | dnl Compilation on mingw and Cygwin needs special Makefile rules, because 108 | dnl 1. when we install a shared library, we must arrange to export 109 | dnl auxiliary pointer variables for every exported variable, 110 | dnl 2. when we install a shared library and a static library simultaneously, 111 | dnl the include file specifies __declspec(dllimport) and therefore we 112 | dnl must arrange to define the auxiliary pointer variables for the 113 | dnl exported variables _also_ in the static library. 114 | if test "$enable_shared" = yes; then 115 | case "$host_os" in 116 | mingw* | cygwin*) is_woe32dll=yes ;; 117 | *) is_woe32dll=no ;; 118 | esac 119 | else 120 | is_woe32dll=no 121 | fi 122 | WOE32DLL=$is_woe32dll 123 | AC_SUBST([WOE32DLL]) 124 | 125 | dnl On mingw and Cygwin, we can activate special Makefile rules which add 126 | dnl version information to the shared libraries and executables. 127 | case "$host_os" in 128 | mingw* | cygwin*) is_woe32=yes ;; 129 | *) is_woe32=no ;; 130 | esac 131 | WOE32=$is_woe32 132 | AC_SUBST([WOE32]) 133 | if test $WOE32 = yes; then 134 | dnl Check for a program that compiles Windows resource files. 135 | AC_CHECK_TOOL([WINDRES], [windres]) 136 | fi 137 | 138 | dnl Determine whether when creating a library, "-lc" should be passed to 139 | dnl libtool or not. On many platforms, it is required for the libtool option 140 | dnl -no-undefined to work. On HP-UX, however, the -lc - stored by libtool 141 | dnl in the *.la files - makes it impossible to create multithreaded programs, 142 | dnl because libtool also reorders the -lc to come before the -pthread, and 143 | dnl this disables pthread_create() . 144 | case "$host_os" in 145 | hpux*) LTLIBC="" ;; 146 | *) LTLIBC="-lc" ;; 147 | esac 148 | AC_SUBST([LTLIBC]) 149 | 150 | dnl Rename some macros and functions used for locking. 151 | AH_BOTTOM([ 152 | #define __libc_lock_t gl_lock_t 153 | #define __libc_lock_define gl_lock_define 154 | #define __libc_lock_define_initialized gl_lock_define_initialized 155 | #define __libc_lock_init gl_lock_init 156 | #define __libc_lock_lock gl_lock_lock 157 | #define __libc_lock_unlock gl_lock_unlock 158 | #define __libc_lock_recursive_t gl_recursive_lock_t 159 | #define __libc_lock_define_recursive gl_recursive_lock_define 160 | #define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized 161 | #define __libc_lock_init_recursive gl_recursive_lock_init 162 | #define __libc_lock_lock_recursive gl_recursive_lock_lock 163 | #define __libc_lock_unlock_recursive gl_recursive_lock_unlock 164 | #define glthread_in_use libintl_thread_in_use 165 | #define glthread_lock_init_func libintl_lock_init_func 166 | #define glthread_lock_lock_func libintl_lock_lock_func 167 | #define glthread_lock_unlock_func libintl_lock_unlock_func 168 | #define glthread_lock_destroy_func libintl_lock_destroy_func 169 | #define glthread_rwlock_init_multithreaded libintl_rwlock_init_multithreaded 170 | #define glthread_rwlock_init_func libintl_rwlock_init_func 171 | #define glthread_rwlock_rdlock_multithreaded libintl_rwlock_rdlock_multithreaded 172 | #define glthread_rwlock_rdlock_func libintl_rwlock_rdlock_func 173 | #define glthread_rwlock_wrlock_multithreaded libintl_rwlock_wrlock_multithreaded 174 | #define glthread_rwlock_wrlock_func libintl_rwlock_wrlock_func 175 | #define glthread_rwlock_unlock_multithreaded libintl_rwlock_unlock_multithreaded 176 | #define glthread_rwlock_unlock_func libintl_rwlock_unlock_func 177 | #define glthread_rwlock_destroy_multithreaded libintl_rwlock_destroy_multithreaded 178 | #define glthread_rwlock_destroy_func libintl_rwlock_destroy_func 179 | #define glthread_recursive_lock_init_multithreaded libintl_recursive_lock_init_multithreaded 180 | #define glthread_recursive_lock_init_func libintl_recursive_lock_init_func 181 | #define glthread_recursive_lock_lock_multithreaded libintl_recursive_lock_lock_multithreaded 182 | #define glthread_recursive_lock_lock_func libintl_recursive_lock_lock_func 183 | #define glthread_recursive_lock_unlock_multithreaded libintl_recursive_lock_unlock_multithreaded 184 | #define glthread_recursive_lock_unlock_func libintl_recursive_lock_unlock_func 185 | #define glthread_recursive_lock_destroy_multithreaded libintl_recursive_lock_destroy_multithreaded 186 | #define glthread_recursive_lock_destroy_func libintl_recursive_lock_destroy_func 187 | #define glthread_once_func libintl_once_func 188 | #define glthread_once_singlethreaded libintl_once_singlethreaded 189 | #define glthread_once_multithreaded libintl_once_multithreaded 190 | ]) 191 | ]) 192 | 193 | 194 | dnl Checks for the core files of the intl subdirectory: 195 | dnl dcigettext.c 196 | dnl eval-plural.h 197 | dnl explodename.c 198 | dnl finddomain.c 199 | dnl gettextP.h 200 | dnl gmo.h 201 | dnl hash-string.h hash-string.c 202 | dnl l10nflist.c 203 | dnl libgnuintl.h.in (except the *printf stuff) 204 | dnl loadinfo.h 205 | dnl loadmsgcat.c 206 | dnl localealias.c 207 | dnl log.c 208 | dnl plural-exp.h plural-exp.c 209 | dnl plural.y 210 | dnl Used by libglocale. 211 | AC_DEFUN([gt_INTL_SUBDIR_CORE], 212 | [ 213 | AC_REQUIRE([AC_C_INLINE])dnl 214 | AC_REQUIRE([AC_TYPE_SIZE_T])dnl 215 | AC_REQUIRE([gl_AC_HEADER_STDINT_H]) 216 | AC_REQUIRE([AC_FUNC_ALLOCA])dnl 217 | AC_REQUIRE([AC_FUNC_MMAP])dnl 218 | AC_REQUIRE([gt_INTDIV0])dnl 219 | AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl 220 | AC_REQUIRE([gt_INTTYPES_PRI])dnl 221 | AC_REQUIRE([gl_LOCK])dnl 222 | 223 | AC_LINK_IFELSE( 224 | [AC_LANG_PROGRAM( 225 | [[int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }]], 226 | [[]])], 227 | [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], 228 | [Define to 1 if the compiler understands __builtin_expect.])]) 229 | 230 | AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h]) 231 | AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \ 232 | stpcpy strcasecmp strdup strtoul tsearch uselocale argz_count \ 233 | argz_stringify argz_next __fsetlocking]) 234 | 235 | dnl Solaris 12 provides getlocalename_l, while Illumos doesn't have 236 | dnl it nor the equivalent. 237 | if test $ac_cv_func_uselocale = yes; then 238 | AC_CHECK_FUNCS([getlocalename_l]) 239 | fi 240 | 241 | dnl Use the *_unlocked functions only if they are declared. 242 | dnl (because some of them were defined without being declared in Solaris 243 | dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built 244 | dnl on Solaris 2.5.1 to run on Solaris 2.6). 245 | AC_CHECK_DECLS([feof_unlocked, fgets_unlocked], , , [#include ]) 246 | 247 | AM_ICONV 248 | 249 | dnl intl/plural.c is generated from intl/plural.y. It requires bison, 250 | dnl because plural.y uses bison specific features. It requires at least 251 | dnl bison-2.7 for %define api.pure. 252 | dnl bison is only needed for the maintainer (who touches plural.y). But in 253 | dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put 254 | dnl the rule in general Makefile. Now, some people carelessly touch the 255 | dnl files or have a broken "make" program, hence the plural.c rule will 256 | dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not 257 | dnl present or too old. 258 | AC_CHECK_PROGS([INTLBISON], [bison]) 259 | if test -z "$INTLBISON"; then 260 | ac_verc_fail=yes 261 | else 262 | dnl Found it, now check the version. 263 | AC_MSG_CHECKING([version of bison]) 264 | changequote(<<,>>)dnl 265 | ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` 266 | case $ac_prog_version in 267 | '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; 268 | 2.[7-9]* | [3-9].*) 269 | changequote([,])dnl 270 | ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; 271 | *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; 272 | esac 273 | AC_MSG_RESULT([$ac_prog_version]) 274 | fi 275 | if test $ac_verc_fail = yes; then 276 | INTLBISON=: 277 | fi 278 | ]) 279 | 280 | dnl Copies _GL_UNUSED and _GL_ATTRIBUTE_PURE definitions from 281 | dnl gnulib-common.m4 as a fallback, if the project isn't using Gnulib. 282 | AC_DEFUN([gt_GL_ATTRIBUTE], [ 283 | m4_ifndef([gl_[]COMMON], 284 | AH_VERBATIM([gt_gl_attribute], 285 | [/* Define as a marker that can be attached to declarations that might not 286 | be used. This helps to reduce warnings, such as from 287 | GCC -Wunused-parameter. */ 288 | #ifndef _GL_UNUSED 289 | # if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 290 | # define _GL_UNUSED __attribute__ ((__unused__)) 291 | # else 292 | # define _GL_UNUSED 293 | # endif 294 | #endif 295 | 296 | /* The __pure__ attribute was added in gcc 2.96. */ 297 | #ifndef _GL_ATTRIBUTE_PURE 298 | # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 299 | # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 300 | # else 301 | # define _GL_ATTRIBUTE_PURE /* empty */ 302 | # endif 303 | #endif 304 | ]))]) 305 | -------------------------------------------------------------------------------- /m4/threadlib.m4: -------------------------------------------------------------------------------- 1 | # threadlib.m4 serial 12 2 | dnl Copyright (C) 2005-2017 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | dnl gl_THREADLIB 10 | dnl ------------ 11 | dnl Tests for a multithreading library to be used. 12 | dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO 13 | dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the 14 | dnl default is 'no', otherwise it is system dependent. In both cases, the user 15 | dnl can change the choice through the options --enable-threads=choice or 16 | dnl --disable-threads. 17 | dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, 18 | dnl USE_PTH_THREADS, USE_WINDOWS_THREADS 19 | dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use 20 | dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with 21 | dnl libtool). 22 | dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for 23 | dnl programs that really need multithread functionality. The difference 24 | dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak 25 | dnl symbols, typically LIBTHREAD is empty whereas LIBMULTITHREAD is not. 26 | dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for 27 | dnl multithread-safe programs. 28 | 29 | AC_DEFUN([gl_THREADLIB_EARLY], 30 | [ 31 | AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) 32 | ]) 33 | 34 | dnl The guts of gl_THREADLIB_EARLY. Needs to be expanded only once. 35 | 36 | AC_DEFUN([gl_THREADLIB_EARLY_BODY], 37 | [ 38 | dnl Ordering constraints: This macro modifies CPPFLAGS in a way that 39 | dnl influences the result of the autoconf tests that test for *_unlocked 40 | dnl declarations, on AIX 5 at least. Therefore it must come early. 41 | AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl 42 | AC_BEFORE([$0], [gl_ARGP])dnl 43 | 44 | AC_REQUIRE([AC_CANONICAL_HOST]) 45 | dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems. 46 | dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes 47 | dnl AC_GNU_SOURCE. 48 | m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], 49 | [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], 50 | [AC_REQUIRE([AC_GNU_SOURCE])]) 51 | dnl Check for multithreading. 52 | m4_ifdef([gl_THREADLIB_DEFAULT_NO], 53 | [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], 54 | [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) 55 | AC_ARG_ENABLE([threads], 56 | AC_HELP_STRING([--enable-threads={posix|solaris|pth|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ 57 | AC_HELP_STRING([--disable-threads], [build without multithread safety])]), 58 | [gl_use_threads=$enableval], 59 | [if test -n "$gl_use_threads_default"; then 60 | gl_use_threads="$gl_use_threads_default" 61 | else 62 | changequote(,)dnl 63 | case "$host_os" in 64 | dnl Disable multithreading by default on OSF/1, because it interferes 65 | dnl with fork()/exec(): When msgexec is linked with -lpthread, its 66 | dnl child process gets an endless segmentation fault inside execvp(). 67 | dnl Disable multithreading by default on Cygwin 1.5.x, because it has 68 | dnl bugs that lead to endless loops or crashes. See 69 | dnl . 70 | osf*) gl_use_threads=no ;; 71 | cygwin*) 72 | case `uname -r` in 73 | 1.[0-5].*) gl_use_threads=no ;; 74 | *) gl_use_threads=yes ;; 75 | esac 76 | ;; 77 | *) gl_use_threads=yes ;; 78 | esac 79 | changequote([,])dnl 80 | fi 81 | ]) 82 | if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then 83 | # For using : 84 | case "$host_os" in 85 | osf*) 86 | # On OSF/1, the compiler needs the flag -D_REENTRANT so that it 87 | # groks . cc also understands the flag -pthread, but 88 | # we don't use it because 1. gcc-2.95 doesn't understand -pthread, 89 | # 2. putting a flag into CPPFLAGS that has an effect on the linker 90 | # causes the AC_LINK_IFELSE test below to succeed unexpectedly, 91 | # leading to wrong values of LIBTHREAD and LTLIBTHREAD. 92 | CPPFLAGS="$CPPFLAGS -D_REENTRANT" 93 | ;; 94 | esac 95 | # Some systems optimize for single-threaded programs by default, and 96 | # need special flags to disable these optimizations. For example, the 97 | # definition of 'errno' in . 98 | case "$host_os" in 99 | aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; 100 | solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; 101 | esac 102 | fi 103 | ]) 104 | 105 | dnl The guts of gl_THREADLIB. Needs to be expanded only once. 106 | 107 | AC_DEFUN([gl_THREADLIB_BODY], 108 | [ 109 | AC_REQUIRE([gl_THREADLIB_EARLY_BODY]) 110 | gl_threads_api=none 111 | LIBTHREAD= 112 | LTLIBTHREAD= 113 | LIBMULTITHREAD= 114 | LTLIBMULTITHREAD= 115 | if test "$gl_use_threads" != no; then 116 | dnl Check whether the compiler and linker support weak declarations. 117 | AC_CACHE_CHECK([whether imported symbols can be declared weak], 118 | [gl_cv_have_weak], 119 | [gl_cv_have_weak=no 120 | dnl First, test whether the compiler accepts it syntactically. 121 | AC_LINK_IFELSE( 122 | [AC_LANG_PROGRAM( 123 | [[extern void xyzzy (); 124 | #pragma weak xyzzy]], 125 | [[xyzzy();]])], 126 | [gl_cv_have_weak=maybe]) 127 | if test $gl_cv_have_weak = maybe; then 128 | dnl Second, test whether it actually works. On Cygwin 1.7.2, with 129 | dnl gcc 4.3, symbols declared weak always evaluate to the address 0. 130 | AC_RUN_IFELSE( 131 | [AC_LANG_SOURCE([[ 132 | #include 133 | #pragma weak fputs 134 | int main () 135 | { 136 | return (fputs == NULL); 137 | }]])], 138 | [gl_cv_have_weak=yes], 139 | [gl_cv_have_weak=no], 140 | [dnl When cross-compiling, assume that only ELF platforms support 141 | dnl weak symbols. 142 | AC_EGREP_CPP([Extensible Linking Format], 143 | [#ifdef __ELF__ 144 | Extensible Linking Format 145 | #endif 146 | ], 147 | [gl_cv_have_weak="guessing yes"], 148 | [gl_cv_have_weak="guessing no"]) 149 | ]) 150 | fi 151 | ]) 152 | if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then 153 | # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that 154 | # it groks . It's added above, in gl_THREADLIB_EARLY_BODY. 155 | AC_CHECK_HEADER([pthread.h], 156 | [gl_have_pthread_h=yes], [gl_have_pthread_h=no]) 157 | if test "$gl_have_pthread_h" = yes; then 158 | # Other possible tests: 159 | # -lpthreads (FSU threads, PCthreads) 160 | # -lgthreads 161 | gl_have_pthread= 162 | # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist 163 | # in libc. IRIX 6.5 has the first one in both libc and libpthread, but 164 | # the second one only in libpthread, and lock.c needs it. 165 | # 166 | # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04 167 | # needs -pthread for some reason. See: 168 | # http://lists.gnu.org/archive/html/bug-gnulib/2014-09/msg00023.html 169 | save_LIBS=$LIBS 170 | for gl_pthread in '' '-pthread'; do 171 | LIBS="$LIBS $gl_pthread" 172 | AC_LINK_IFELSE( 173 | [AC_LANG_PROGRAM( 174 | [[#include 175 | pthread_mutex_t m; 176 | pthread_mutexattr_t ma; 177 | ]], 178 | [[pthread_mutex_lock (&m); 179 | pthread_mutexattr_init (&ma);]])], 180 | [gl_have_pthread=yes 181 | LIBTHREAD=$gl_pthread LTLIBTHREAD=$gl_pthread 182 | LIBMULTITHREAD=$gl_pthread LTLIBMULTITHREAD=$gl_pthread]) 183 | LIBS=$save_LIBS 184 | test -n "$gl_have_pthread" && break 185 | done 186 | 187 | # Test for libpthread by looking for pthread_kill. (Not pthread_self, 188 | # since it is defined as a macro on OSF/1.) 189 | if test -n "$gl_have_pthread" && test -z "$LIBTHREAD"; then 190 | # The program links fine without libpthread. But it may actually 191 | # need to link with libpthread in order to create multiple threads. 192 | AC_CHECK_LIB([pthread], [pthread_kill], 193 | [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread 194 | # On Solaris and HP-UX, most pthread functions exist also in libc. 195 | # Therefore pthread_in_use() needs to actually try to create a 196 | # thread: pthread_create from libc will fail, whereas 197 | # pthread_create will actually create a thread. 198 | # On Solaris 10 or newer, this test is no longer needed, because 199 | # libc contains the fully functional pthread functions. 200 | case "$host_os" in 201 | solaris | solaris2.[1-9] | solaris2.[1-9].* | hpux*) 202 | AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1], 203 | [Define if the pthread_in_use() detection is hard.]) 204 | esac 205 | ]) 206 | elif test -z "$gl_have_pthread"; then 207 | # Some library is needed. Try libpthread and libc_r. 208 | AC_CHECK_LIB([pthread], [pthread_kill], 209 | [gl_have_pthread=yes 210 | LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread 211 | LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread]) 212 | if test -z "$gl_have_pthread"; then 213 | # For FreeBSD 4. 214 | AC_CHECK_LIB([c_r], [pthread_kill], 215 | [gl_have_pthread=yes 216 | LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r 217 | LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r]) 218 | fi 219 | fi 220 | if test -n "$gl_have_pthread"; then 221 | gl_threads_api=posix 222 | AC_DEFINE([USE_POSIX_THREADS], [1], 223 | [Define if the POSIX multithreading library can be used.]) 224 | if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then 225 | if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then 226 | AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], 227 | [Define if references to the POSIX multithreading library should be made weak.]) 228 | LIBTHREAD= 229 | LTLIBTHREAD= 230 | fi 231 | fi 232 | fi 233 | fi 234 | fi 235 | if test -z "$gl_have_pthread"; then 236 | if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then 237 | gl_have_solaristhread= 238 | gl_save_LIBS="$LIBS" 239 | LIBS="$LIBS -lthread" 240 | AC_LINK_IFELSE( 241 | [AC_LANG_PROGRAM( 242 | [[ 243 | #include 244 | #include 245 | ]], 246 | [[thr_self();]])], 247 | [gl_have_solaristhread=yes]) 248 | LIBS="$gl_save_LIBS" 249 | if test -n "$gl_have_solaristhread"; then 250 | gl_threads_api=solaris 251 | LIBTHREAD=-lthread 252 | LTLIBTHREAD=-lthread 253 | LIBMULTITHREAD="$LIBTHREAD" 254 | LTLIBMULTITHREAD="$LTLIBTHREAD" 255 | AC_DEFINE([USE_SOLARIS_THREADS], [1], 256 | [Define if the old Solaris multithreading library can be used.]) 257 | if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then 258 | AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1], 259 | [Define if references to the old Solaris multithreading library should be made weak.]) 260 | LIBTHREAD= 261 | LTLIBTHREAD= 262 | fi 263 | fi 264 | fi 265 | fi 266 | if test "$gl_use_threads" = pth; then 267 | gl_save_CPPFLAGS="$CPPFLAGS" 268 | AC_LIB_LINKFLAGS([pth]) 269 | gl_have_pth= 270 | gl_save_LIBS="$LIBS" 271 | LIBS="$LIBS $LIBPTH" 272 | AC_LINK_IFELSE( 273 | [AC_LANG_PROGRAM([[#include ]], [[pth_self();]])], 274 | [gl_have_pth=yes]) 275 | LIBS="$gl_save_LIBS" 276 | if test -n "$gl_have_pth"; then 277 | gl_threads_api=pth 278 | LIBTHREAD="$LIBPTH" 279 | LTLIBTHREAD="$LTLIBPTH" 280 | LIBMULTITHREAD="$LIBTHREAD" 281 | LTLIBMULTITHREAD="$LTLIBTHREAD" 282 | AC_DEFINE([USE_PTH_THREADS], [1], 283 | [Define if the GNU Pth multithreading library can be used.]) 284 | if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then 285 | if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then 286 | AC_DEFINE([USE_PTH_THREADS_WEAK], [1], 287 | [Define if references to the GNU Pth multithreading library should be made weak.]) 288 | LIBTHREAD= 289 | LTLIBTHREAD= 290 | fi 291 | fi 292 | else 293 | CPPFLAGS="$gl_save_CPPFLAGS" 294 | fi 295 | fi 296 | if test -z "$gl_have_pthread"; then 297 | case "$gl_use_threads" in 298 | yes | windows | win32) # The 'win32' is for backward compatibility. 299 | if { case "$host_os" in 300 | mingw*) true;; 301 | *) false;; 302 | esac 303 | }; then 304 | gl_threads_api=windows 305 | AC_DEFINE([USE_WINDOWS_THREADS], [1], 306 | [Define if the native Windows multithreading API can be used.]) 307 | fi 308 | ;; 309 | esac 310 | fi 311 | fi 312 | AC_MSG_CHECKING([for multithread API to use]) 313 | AC_MSG_RESULT([$gl_threads_api]) 314 | AC_SUBST([LIBTHREAD]) 315 | AC_SUBST([LTLIBTHREAD]) 316 | AC_SUBST([LIBMULTITHREAD]) 317 | AC_SUBST([LTLIBMULTITHREAD]) 318 | ]) 319 | 320 | AC_DEFUN([gl_THREADLIB], 321 | [ 322 | AC_REQUIRE([gl_THREADLIB_EARLY]) 323 | AC_REQUIRE([gl_THREADLIB_BODY]) 324 | ]) 325 | 326 | 327 | dnl gl_DISABLE_THREADS 328 | dnl ------------------ 329 | dnl Sets the gl_THREADLIB default so that threads are not used by default. 330 | dnl The user can still override it at installation time, by using the 331 | dnl configure option '--enable-threads'. 332 | 333 | AC_DEFUN([gl_DISABLE_THREADS], [ 334 | m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no]) 335 | ]) 336 | 337 | 338 | dnl Survey of platforms: 339 | dnl 340 | dnl Platform Available Compiler Supports test-lock 341 | dnl flavours option weak result 342 | dnl --------------- --------- --------- -------- --------- 343 | dnl Linux 2.4/glibc posix -lpthread Y OK 344 | dnl 345 | dnl GNU Hurd/glibc posix 346 | dnl 347 | dnl Ubuntu 14.04 posix -pthread Y OK 348 | dnl 349 | dnl FreeBSD 5.3 posix -lc_r Y 350 | dnl posix -lkse ? Y 351 | dnl posix -lpthread ? Y 352 | dnl posix -lthr Y 353 | dnl 354 | dnl FreeBSD 5.2 posix -lc_r Y 355 | dnl posix -lkse Y 356 | dnl posix -lthr Y 357 | dnl 358 | dnl FreeBSD 4.0,4.10 posix -lc_r Y OK 359 | dnl 360 | dnl NetBSD 1.6 -- 361 | dnl 362 | dnl OpenBSD 3.4 posix -lpthread Y OK 363 | dnl 364 | dnl Mac OS X 10.[123] posix -lpthread Y OK 365 | dnl 366 | dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK 367 | dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK 368 | dnl 369 | dnl HP-UX 11 posix -lpthread N (cc) OK 370 | dnl Y (gcc) 371 | dnl 372 | dnl IRIX 6.5 posix -lpthread Y 0.5 373 | dnl 374 | dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK 375 | dnl 376 | dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK 377 | dnl -lpthread (gcc) Y 378 | dnl 379 | dnl Cygwin posix -lpthread Y OK 380 | dnl 381 | dnl Any of the above pth -lpth 0.0 382 | dnl 383 | dnl Mingw windows N OK 384 | dnl 385 | dnl BeOS 5 -- 386 | dnl 387 | dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is 388 | dnl turned off: 389 | dnl OK if all three tests terminate OK, 390 | dnl 0.5 if the first test terminates OK but the second one loops endlessly, 391 | dnl 0.0 if the first test already loops endlessly. 392 | -------------------------------------------------------------------------------- /m4/gettext.m4: -------------------------------------------------------------------------------- 1 | # gettext.m4 serial 68 (gettext-0.19.8) 2 | dnl Copyright (C) 1995-2014, 2016 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | dnl 7 | dnl This file can be used in projects which are not available under 8 | dnl the GNU General Public License or the GNU Library General Public 9 | dnl License but which still want to provide support for the GNU gettext 10 | dnl functionality. 11 | dnl Please note that the actual code of the GNU gettext library is covered 12 | dnl by the GNU Library General Public License, and the rest of the GNU 13 | dnl gettext package is covered by the GNU General Public License. 14 | dnl They are *not* in the public domain. 15 | 16 | dnl Authors: 17 | dnl Ulrich Drepper , 1995-2000. 18 | dnl Bruno Haible , 2000-2006, 2008-2010. 19 | 20 | dnl Macro to add for using GNU gettext. 21 | 22 | dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). 23 | dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The 24 | dnl default (if it is not specified or empty) is 'no-libtool'. 25 | dnl INTLSYMBOL should be 'external' for packages with no intl directory, 26 | dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. 27 | dnl If INTLSYMBOL is 'use-libtool', then a libtool library 28 | dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, 29 | dnl depending on --{enable,disable}-{shared,static} and on the presence of 30 | dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library 31 | dnl $(top_builddir)/intl/libintl.a will be created. 32 | dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext 33 | dnl implementations (in libc or libintl) without the ngettext() function 34 | dnl will be ignored. If NEEDSYMBOL is specified and is 35 | dnl 'need-formatstring-macros', then GNU gettext implementations that don't 36 | dnl support the ISO C 99 formatstring macros will be ignored. 37 | dnl INTLDIR is used to find the intl libraries. If empty, 38 | dnl the value '$(top_builddir)/intl/' is used. 39 | dnl 40 | dnl The result of the configuration is one of three cases: 41 | dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled 42 | dnl and used. 43 | dnl Catalog format: GNU --> install in $(datadir) 44 | dnl Catalog extension: .mo after installation, .gmo in source tree 45 | dnl 2) GNU gettext has been found in the system's C library. 46 | dnl Catalog format: GNU --> install in $(datadir) 47 | dnl Catalog extension: .mo after installation, .gmo in source tree 48 | dnl 3) No internationalization, always use English msgid. 49 | dnl Catalog format: none 50 | dnl Catalog extension: none 51 | dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. 52 | dnl The use of .gmo is historical (it was needed to avoid overwriting the 53 | dnl GNU format catalogs when building on a platform with an X/Open gettext), 54 | dnl but we keep it in order not to force irrelevant filename changes on the 55 | dnl maintainers. 56 | dnl 57 | AC_DEFUN([AM_GNU_GETTEXT], 58 | [ 59 | dnl Argument checking. 60 | ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , 61 | [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT 62 | ])])])])]) 63 | ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], 64 | [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])]) 65 | ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , 66 | [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT 67 | ])])])]) 68 | define([gt_included_intl], 69 | ifelse([$1], [external], 70 | ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]), 71 | [yes])) 72 | define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], [])) 73 | gt_NEEDS_INIT 74 | AM_GNU_GETTEXT_NEED([$2]) 75 | 76 | AC_REQUIRE([AM_PO_SUBDIRS])dnl 77 | ifelse(gt_included_intl, yes, [ 78 | AC_REQUIRE([AM_INTL_SUBDIR])dnl 79 | ]) 80 | 81 | dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. 82 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 83 | AC_REQUIRE([AC_LIB_RPATH]) 84 | 85 | dnl Sometimes libintl requires libiconv, so first search for libiconv. 86 | dnl Ideally we would do this search only after the 87 | dnl if test "$USE_NLS" = "yes"; then 88 | dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then 89 | dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT 90 | dnl the configure script would need to contain the same shell code 91 | dnl again, outside any 'if'. There are two solutions: 92 | dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. 93 | dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. 94 | dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not 95 | dnl documented, we avoid it. 96 | ifelse(gt_included_intl, yes, , [ 97 | AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) 98 | ]) 99 | 100 | dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation. 101 | gt_INTL_MACOSX 102 | 103 | dnl Set USE_NLS. 104 | AC_REQUIRE([AM_NLS]) 105 | 106 | ifelse(gt_included_intl, yes, [ 107 | BUILD_INCLUDED_LIBINTL=no 108 | USE_INCLUDED_LIBINTL=no 109 | ]) 110 | LIBINTL= 111 | LTLIBINTL= 112 | POSUB= 113 | 114 | dnl Add a version number to the cache macros. 115 | case " $gt_needs " in 116 | *" need-formatstring-macros "*) gt_api_version=3 ;; 117 | *" need-ngettext "*) gt_api_version=2 ;; 118 | *) gt_api_version=1 ;; 119 | esac 120 | gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" 121 | gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" 122 | 123 | dnl If we use NLS figure out what method 124 | if test "$USE_NLS" = "yes"; then 125 | gt_use_preinstalled_gnugettext=no 126 | ifelse(gt_included_intl, yes, [ 127 | AC_MSG_CHECKING([whether included gettext is requested]) 128 | AC_ARG_WITH([included-gettext], 129 | [ --with-included-gettext use the GNU gettext library included here], 130 | nls_cv_force_use_gnu_gettext=$withval, 131 | nls_cv_force_use_gnu_gettext=no) 132 | AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) 133 | 134 | nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" 135 | if test "$nls_cv_force_use_gnu_gettext" != "yes"; then 136 | ]) 137 | dnl User does not insist on using GNU NLS library. Figure out what 138 | dnl to use. If GNU gettext is available we use this. Else we have 139 | dnl to fall back to GNU NLS library. 140 | 141 | if test $gt_api_version -ge 3; then 142 | gt_revision_test_code=' 143 | #ifndef __GNU_GETTEXT_SUPPORTED_REVISION 144 | #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) 145 | #endif 146 | changequote(,)dnl 147 | typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; 148 | changequote([,])dnl 149 | ' 150 | else 151 | gt_revision_test_code= 152 | fi 153 | if test $gt_api_version -ge 2; then 154 | gt_expression_test_code=' + * ngettext ("", "", 0)' 155 | else 156 | gt_expression_test_code= 157 | fi 158 | 159 | AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], 160 | [AC_LINK_IFELSE( 161 | [AC_LANG_PROGRAM( 162 | [[ 163 | #include 164 | #ifndef __GNU_GETTEXT_SUPPORTED_REVISION 165 | extern int _nl_msg_cat_cntr; 166 | extern int *_nl_domain_bindings; 167 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings) 168 | #else 169 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 170 | #endif 171 | $gt_revision_test_code 172 | ]], 173 | [[ 174 | bindtextdomain ("", ""); 175 | return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION 176 | ]])], 177 | [eval "$gt_func_gnugettext_libc=yes"], 178 | [eval "$gt_func_gnugettext_libc=no"])]) 179 | 180 | if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then 181 | dnl Sometimes libintl requires libiconv, so first search for libiconv. 182 | ifelse(gt_included_intl, yes, , [ 183 | AM_ICONV_LINK 184 | ]) 185 | dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL 186 | dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) 187 | dnl because that would add "-liconv" to LIBINTL and LTLIBINTL 188 | dnl even if libiconv doesn't exist. 189 | AC_LIB_LINKFLAGS_BODY([intl]) 190 | AC_CACHE_CHECK([for GNU gettext in libintl], 191 | [$gt_func_gnugettext_libintl], 192 | [gt_save_CPPFLAGS="$CPPFLAGS" 193 | CPPFLAGS="$CPPFLAGS $INCINTL" 194 | gt_save_LIBS="$LIBS" 195 | LIBS="$LIBS $LIBINTL" 196 | dnl Now see whether libintl exists and does not depend on libiconv. 197 | AC_LINK_IFELSE( 198 | [AC_LANG_PROGRAM( 199 | [[ 200 | #include 201 | #ifndef __GNU_GETTEXT_SUPPORTED_REVISION 202 | extern int _nl_msg_cat_cntr; 203 | extern 204 | #ifdef __cplusplus 205 | "C" 206 | #endif 207 | const char *_nl_expand_alias (const char *); 208 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) 209 | #else 210 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 211 | #endif 212 | $gt_revision_test_code 213 | ]], 214 | [[ 215 | bindtextdomain ("", ""); 216 | return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION 217 | ]])], 218 | [eval "$gt_func_gnugettext_libintl=yes"], 219 | [eval "$gt_func_gnugettext_libintl=no"]) 220 | dnl Now see whether libintl exists and depends on libiconv. 221 | if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then 222 | LIBS="$LIBS $LIBICONV" 223 | AC_LINK_IFELSE( 224 | [AC_LANG_PROGRAM( 225 | [[ 226 | #include 227 | #ifndef __GNU_GETTEXT_SUPPORTED_REVISION 228 | extern int _nl_msg_cat_cntr; 229 | extern 230 | #ifdef __cplusplus 231 | "C" 232 | #endif 233 | const char *_nl_expand_alias (const char *); 234 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) 235 | #else 236 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 237 | #endif 238 | $gt_revision_test_code 239 | ]], 240 | [[ 241 | bindtextdomain ("", ""); 242 | return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION 243 | ]])], 244 | [LIBINTL="$LIBINTL $LIBICONV" 245 | LTLIBINTL="$LTLIBINTL $LTLIBICONV" 246 | eval "$gt_func_gnugettext_libintl=yes" 247 | ]) 248 | fi 249 | CPPFLAGS="$gt_save_CPPFLAGS" 250 | LIBS="$gt_save_LIBS"]) 251 | fi 252 | 253 | dnl If an already present or preinstalled GNU gettext() is found, 254 | dnl use it. But if this macro is used in GNU gettext, and GNU 255 | dnl gettext is already preinstalled in libintl, we update this 256 | dnl libintl. (Cf. the install rule in intl/Makefile.in.) 257 | if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ 258 | || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ 259 | && test "$PACKAGE" != gettext-runtime \ 260 | && test "$PACKAGE" != gettext-tools; }; then 261 | gt_use_preinstalled_gnugettext=yes 262 | else 263 | dnl Reset the values set by searching for libintl. 264 | LIBINTL= 265 | LTLIBINTL= 266 | INCINTL= 267 | fi 268 | 269 | ifelse(gt_included_intl, yes, [ 270 | if test "$gt_use_preinstalled_gnugettext" != "yes"; then 271 | dnl GNU gettext is not found in the C library. 272 | dnl Fall back on included GNU gettext library. 273 | nls_cv_use_gnu_gettext=yes 274 | fi 275 | fi 276 | 277 | if test "$nls_cv_use_gnu_gettext" = "yes"; then 278 | dnl Mark actions used to generate GNU NLS library. 279 | BUILD_INCLUDED_LIBINTL=yes 280 | USE_INCLUDED_LIBINTL=yes 281 | LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD" 282 | LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD" 283 | LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` 284 | fi 285 | 286 | CATOBJEXT= 287 | if test "$gt_use_preinstalled_gnugettext" = "yes" \ 288 | || test "$nls_cv_use_gnu_gettext" = "yes"; then 289 | dnl Mark actions to use GNU gettext tools. 290 | CATOBJEXT=.gmo 291 | fi 292 | ]) 293 | 294 | if test -n "$INTL_MACOSX_LIBS"; then 295 | if test "$gt_use_preinstalled_gnugettext" = "yes" \ 296 | || test "$nls_cv_use_gnu_gettext" = "yes"; then 297 | dnl Some extra flags are needed during linking. 298 | LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" 299 | LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" 300 | fi 301 | fi 302 | 303 | if test "$gt_use_preinstalled_gnugettext" = "yes" \ 304 | || test "$nls_cv_use_gnu_gettext" = "yes"; then 305 | AC_DEFINE([ENABLE_NLS], [1], 306 | [Define to 1 if translation of program messages to the user's native language 307 | is requested.]) 308 | else 309 | USE_NLS=no 310 | fi 311 | fi 312 | 313 | AC_MSG_CHECKING([whether to use NLS]) 314 | AC_MSG_RESULT([$USE_NLS]) 315 | if test "$USE_NLS" = "yes"; then 316 | AC_MSG_CHECKING([where the gettext function comes from]) 317 | if test "$gt_use_preinstalled_gnugettext" = "yes"; then 318 | if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then 319 | gt_source="external libintl" 320 | else 321 | gt_source="libc" 322 | fi 323 | else 324 | gt_source="included intl directory" 325 | fi 326 | AC_MSG_RESULT([$gt_source]) 327 | fi 328 | 329 | if test "$USE_NLS" = "yes"; then 330 | 331 | if test "$gt_use_preinstalled_gnugettext" = "yes"; then 332 | if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then 333 | AC_MSG_CHECKING([how to link with libintl]) 334 | AC_MSG_RESULT([$LIBINTL]) 335 | AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) 336 | fi 337 | 338 | dnl For backward compatibility. Some packages may be using this. 339 | AC_DEFINE([HAVE_GETTEXT], [1], 340 | [Define if the GNU gettext() function is already present or preinstalled.]) 341 | AC_DEFINE([HAVE_DCGETTEXT], [1], 342 | [Define if the GNU dcgettext() function is already present or preinstalled.]) 343 | fi 344 | 345 | dnl We need to process the po/ directory. 346 | POSUB=po 347 | fi 348 | 349 | ifelse(gt_included_intl, yes, [ 350 | dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL 351 | dnl to 'yes' because some of the testsuite requires it. 352 | if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then 353 | BUILD_INCLUDED_LIBINTL=yes 354 | fi 355 | 356 | dnl Make all variables we use known to autoconf. 357 | AC_SUBST([BUILD_INCLUDED_LIBINTL]) 358 | AC_SUBST([USE_INCLUDED_LIBINTL]) 359 | AC_SUBST([CATOBJEXT]) 360 | 361 | dnl For backward compatibility. Some configure.ins may be using this. 362 | nls_cv_header_intl= 363 | nls_cv_header_libgt= 364 | 365 | dnl For backward compatibility. Some Makefiles may be using this. 366 | DATADIRNAME=share 367 | AC_SUBST([DATADIRNAME]) 368 | 369 | dnl For backward compatibility. Some Makefiles may be using this. 370 | INSTOBJEXT=.mo 371 | AC_SUBST([INSTOBJEXT]) 372 | 373 | dnl For backward compatibility. Some Makefiles may be using this. 374 | GENCAT=gencat 375 | AC_SUBST([GENCAT]) 376 | 377 | dnl For backward compatibility. Some Makefiles may be using this. 378 | INTLOBJS= 379 | if test "$USE_INCLUDED_LIBINTL" = yes; then 380 | INTLOBJS="\$(GETTOBJS)" 381 | fi 382 | AC_SUBST([INTLOBJS]) 383 | 384 | dnl Enable libtool support if the surrounding package wishes it. 385 | INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix 386 | AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX]) 387 | ]) 388 | 389 | dnl For backward compatibility. Some Makefiles may be using this. 390 | INTLLIBS="$LIBINTL" 391 | AC_SUBST([INTLLIBS]) 392 | 393 | dnl Make all documented variables known to autoconf. 394 | AC_SUBST([LIBINTL]) 395 | AC_SUBST([LTLIBINTL]) 396 | AC_SUBST([POSUB]) 397 | ]) 398 | 399 | 400 | dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. 401 | m4_define([gt_NEEDS_INIT], 402 | [ 403 | m4_divert_text([DEFAULTS], [gt_needs=]) 404 | m4_define([gt_NEEDS_INIT], []) 405 | ]) 406 | 407 | 408 | dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) 409 | AC_DEFUN([AM_GNU_GETTEXT_NEED], 410 | [ 411 | m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) 412 | ]) 413 | 414 | 415 | dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) 416 | AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) 417 | 418 | 419 | dnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version]) 420 | AC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], []) 421 | -------------------------------------------------------------------------------- /m4/po.m4: -------------------------------------------------------------------------------- 1 | # po.m4 serial 24 (gettext-0.19) 2 | dnl Copyright (C) 1995-2014, 2016 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | dnl 7 | dnl This file can be used in projects which are not available under 8 | dnl the GNU General Public License or the GNU Library General Public 9 | dnl License but which still want to provide support for the GNU gettext 10 | dnl functionality. 11 | dnl Please note that the actual code of the GNU gettext library is covered 12 | dnl by the GNU Library General Public License, and the rest of the GNU 13 | dnl gettext package is covered by the GNU General Public License. 14 | dnl They are *not* in the public domain. 15 | 16 | dnl Authors: 17 | dnl Ulrich Drepper , 1995-2000. 18 | dnl Bruno Haible , 2000-2003. 19 | 20 | AC_PREREQ([2.60]) 21 | 22 | dnl Checks for all prerequisites of the po subdirectory. 23 | AC_DEFUN([AM_PO_SUBDIRS], 24 | [ 25 | AC_REQUIRE([AC_PROG_MAKE_SET])dnl 26 | AC_REQUIRE([AC_PROG_INSTALL])dnl 27 | AC_REQUIRE([AC_PROG_MKDIR_P])dnl 28 | AC_REQUIRE([AC_PROG_SED])dnl 29 | AC_REQUIRE([AM_NLS])dnl 30 | 31 | dnl Release version of the gettext macros. This is used to ensure that 32 | dnl the gettext macros and po/Makefile.in.in are in sync. 33 | AC_SUBST([GETTEXT_MACRO_VERSION], [0.19]) 34 | 35 | dnl Perform the following tests also if --disable-nls has been given, 36 | dnl because they are needed for "make dist" to work. 37 | 38 | dnl Search for GNU msgfmt in the PATH. 39 | dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. 40 | dnl The second test excludes FreeBSD msgfmt. 41 | AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, 42 | [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && 43 | (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], 44 | :) 45 | AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT]) 46 | 47 | dnl Test whether it is GNU msgfmt >= 0.15. 48 | changequote(,)dnl 49 | case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in 50 | '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; 51 | *) MSGFMT_015=$MSGFMT ;; 52 | esac 53 | changequote([,])dnl 54 | AC_SUBST([MSGFMT_015]) 55 | changequote(,)dnl 56 | case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in 57 | '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; 58 | *) GMSGFMT_015=$GMSGFMT ;; 59 | esac 60 | changequote([,])dnl 61 | AC_SUBST([GMSGFMT_015]) 62 | 63 | dnl Search for GNU xgettext 0.12 or newer in the PATH. 64 | dnl The first test excludes Solaris xgettext and early GNU xgettext versions. 65 | dnl The second test excludes FreeBSD xgettext. 66 | AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, 67 | [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && 68 | (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], 69 | :) 70 | dnl Remove leftover from FreeBSD xgettext call. 71 | rm -f messages.po 72 | 73 | dnl Test whether it is GNU xgettext >= 0.15. 74 | changequote(,)dnl 75 | case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in 76 | '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; 77 | *) XGETTEXT_015=$XGETTEXT ;; 78 | esac 79 | changequote([,])dnl 80 | AC_SUBST([XGETTEXT_015]) 81 | 82 | dnl Search for GNU msgmerge 0.11 or newer in the PATH. 83 | AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, 84 | [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :) 85 | 86 | dnl Installation directories. 87 | dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we 88 | dnl have to define it here, so that it can be used in po/Makefile. 89 | test -n "$localedir" || localedir='${datadir}/locale' 90 | AC_SUBST([localedir]) 91 | 92 | dnl Support for AM_XGETTEXT_OPTION. 93 | test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= 94 | AC_SUBST([XGETTEXT_EXTRA_OPTIONS]) 95 | 96 | AC_CONFIG_COMMANDS([po-directories], [[ 97 | for ac_file in $CONFIG_FILES; do 98 | # Support "outfile[:infile[:infile...]]" 99 | case "$ac_file" in 100 | *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; 101 | esac 102 | # PO directories have a Makefile.in generated from Makefile.in.in. 103 | case "$ac_file" in */Makefile.in) 104 | # Adjust a relative srcdir. 105 | ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` 106 | ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` 107 | ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` 108 | # In autoconf-2.13 it is called $ac_given_srcdir. 109 | # In autoconf-2.50 it is called $srcdir. 110 | test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" 111 | case "$ac_given_srcdir" in 112 | .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; 113 | /*) top_srcdir="$ac_given_srcdir" ;; 114 | *) top_srcdir="$ac_dots$ac_given_srcdir" ;; 115 | esac 116 | # Treat a directory as a PO directory if and only if it has a 117 | # POTFILES.in file. This allows packages to have multiple PO 118 | # directories under different names or in different locations. 119 | if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then 120 | rm -f "$ac_dir/POTFILES" 121 | test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" 122 | gt_tab=`printf '\t'` 123 | cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" 124 | POMAKEFILEDEPS="POTFILES.in" 125 | # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend 126 | # on $ac_dir but don't depend on user-specified configuration 127 | # parameters. 128 | if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then 129 | # The LINGUAS file contains the set of available languages. 130 | if test -n "$OBSOLETE_ALL_LINGUAS"; then 131 | test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" 132 | fi 133 | ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` 134 | # Hide the ALL_LINGUAS assignment from automake < 1.5. 135 | eval 'ALL_LINGUAS''=$ALL_LINGUAS_' 136 | POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" 137 | else 138 | # The set of available languages was given in configure.in. 139 | # Hide the ALL_LINGUAS assignment from automake < 1.5. 140 | eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' 141 | fi 142 | # Compute POFILES 143 | # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) 144 | # Compute UPDATEPOFILES 145 | # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) 146 | # Compute DUMMYPOFILES 147 | # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) 148 | # Compute GMOFILES 149 | # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) 150 | case "$ac_given_srcdir" in 151 | .) srcdirpre= ;; 152 | *) srcdirpre='$(srcdir)/' ;; 153 | esac 154 | POFILES= 155 | UPDATEPOFILES= 156 | DUMMYPOFILES= 157 | GMOFILES= 158 | for lang in $ALL_LINGUAS; do 159 | POFILES="$POFILES $srcdirpre$lang.po" 160 | UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" 161 | DUMMYPOFILES="$DUMMYPOFILES $lang.nop" 162 | GMOFILES="$GMOFILES $srcdirpre$lang.gmo" 163 | done 164 | # CATALOGS depends on both $ac_dir and the user's LINGUAS 165 | # environment variable. 166 | INST_LINGUAS= 167 | if test -n "$ALL_LINGUAS"; then 168 | for presentlang in $ALL_LINGUAS; do 169 | useit=no 170 | if test "%UNSET%" != "$LINGUAS"; then 171 | desiredlanguages="$LINGUAS" 172 | else 173 | desiredlanguages="$ALL_LINGUAS" 174 | fi 175 | for desiredlang in $desiredlanguages; do 176 | # Use the presentlang catalog if desiredlang is 177 | # a. equal to presentlang, or 178 | # b. a variant of presentlang (because in this case, 179 | # presentlang can be used as a fallback for messages 180 | # which are not translated in the desiredlang catalog). 181 | case "$desiredlang" in 182 | "$presentlang"*) useit=yes;; 183 | esac 184 | done 185 | if test $useit = yes; then 186 | INST_LINGUAS="$INST_LINGUAS $presentlang" 187 | fi 188 | done 189 | fi 190 | CATALOGS= 191 | if test -n "$INST_LINGUAS"; then 192 | for lang in $INST_LINGUAS; do 193 | CATALOGS="$CATALOGS $lang.gmo" 194 | done 195 | fi 196 | test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" 197 | sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" 198 | for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do 199 | if test -f "$f"; then 200 | case "$f" in 201 | *.orig | *.bak | *~) ;; 202 | *) cat "$f" >> "$ac_dir/Makefile" ;; 203 | esac 204 | fi 205 | done 206 | fi 207 | ;; 208 | esac 209 | done]], 210 | [# Capture the value of obsolete ALL_LINGUAS because we need it to compute 211 | # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it 212 | # from automake < 1.5. 213 | eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' 214 | # Capture the value of LINGUAS because we need it to compute CATALOGS. 215 | LINGUAS="${LINGUAS-%UNSET%}" 216 | ]) 217 | ]) 218 | 219 | dnl Postprocesses a Makefile in a directory containing PO files. 220 | AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], 221 | [ 222 | # When this code is run, in config.status, two variables have already been 223 | # set: 224 | # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, 225 | # - LINGUAS is the value of the environment variable LINGUAS at configure 226 | # time. 227 | 228 | changequote(,)dnl 229 | # Adjust a relative srcdir. 230 | ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` 231 | ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` 232 | ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` 233 | # In autoconf-2.13 it is called $ac_given_srcdir. 234 | # In autoconf-2.50 it is called $srcdir. 235 | test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" 236 | case "$ac_given_srcdir" in 237 | .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; 238 | /*) top_srcdir="$ac_given_srcdir" ;; 239 | *) top_srcdir="$ac_dots$ac_given_srcdir" ;; 240 | esac 241 | 242 | # Find a way to echo strings without interpreting backslash. 243 | if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then 244 | gt_echo='echo' 245 | else 246 | if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then 247 | gt_echo='printf %s\n' 248 | else 249 | echo_func () { 250 | cat < "$ac_file.tmp" 411 | tab=`printf '\t'` 412 | if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then 413 | # Add dependencies that cannot be formulated as a simple suffix rule. 414 | for lang in $ALL_LINGUAS; do 415 | frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` 416 | cat >> "$ac_file.tmp" < /dev/null; then 424 | # Add dependencies that cannot be formulated as a simple suffix rule. 425 | for lang in $ALL_LINGUAS; do 426 | frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` 427 | cat >> "$ac_file.tmp" <> "$ac_file.tmp" <