summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorSchala2015-06-08 17:49:06 -0700
committerSchala2015-06-08 17:49:06 -0700
commitfc1b45fae31f4f92d3f34a3d541f526f2fd4ddef (patch)
tree8255ae2d294151e5075457e091f750a9f20b6963
downloadaur-fc1b45fae31f4f92d3f34a3d541f526f2fd4ddef.tar.gz
added patches from https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-gettext
-rw-r--r--.SRCINFO31
-rw-r--r--.gitignore5
-rw-r--r--00-relocatex-libintl-0.18.3.1.patch814
-rw-r--r--05-always-use-libintl-vsnprintf.mingw.patch11
-rw-r--r--06-dont-include-ctype-after-gnulibs-wctype.mingw.patch44
-rw-r--r--07-fix-asprintf-conflict.mingw.patch63
-rw-r--r--PKGBUILD63
7 files changed, 1031 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..0d8750128345
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,31 @@
+pkgbase = mingw-w64-gettext
+ pkgdesc = GNU internationalization library (mingw-w64)
+ pkgver = 0.19.4
+ pkgrel = 4
+ url = http://www.gnu.org/software/gettext
+ arch = any
+ license = GPL
+ makedepends = mingw-w64-gcc
+ makedepends = mingw-w64-configure
+ depends = mingw-w64-crt
+ depends = mingw-w64-libiconv
+ depends = mingw-w64-termcap
+ depends = mingw-w64-libunistring
+ options = !strip
+ options = !buildflags
+ options = staticlibs
+ source = http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.4.tar.gz
+ source = http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.4.tar.gz.sig
+ source = 00-relocatex-libintl-0.18.3.1.patch
+ source = 05-always-use-libintl-vsnprintf.mingw.patch
+ source = 06-dont-include-ctype-after-gnulibs-wctype.mingw.patch
+ source = 07-fix-asprintf-conflict.mingw.patch
+ md5sums = d3511af1e604a3478900d2c2b4a4a48e
+ md5sums = SKIP
+ md5sums = 397d7d6d4abd15a70edb3c9f2bab4cd2
+ md5sums = 27852a388b8cf38188dc392c244230ff
+ md5sums = f69747f43f279b8a81286cfe5916b82f
+ md5sums = 3ebccf730ec3377b068027eb2283afb2
+
+pkgname = mingw-w64-gettext
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..5d1148bf487d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+pkg/
+src/
+*.gz
+*.sig
+*.xz
diff --git a/00-relocatex-libintl-0.18.3.1.patch b/00-relocatex-libintl-0.18.3.1.patch
new file mode 100644
index 000000000000..ef372f9068de
--- /dev/null
+++ b/00-relocatex-libintl-0.18.3.1.patch
@@ -0,0 +1,814 @@
+diff -crBN gettext-0.18.3.1.orig/gettext-runtime/intl/bindtextdom.c gettext-0.18.3.1/gettext-runtime/intl/bindtextdom.c
+*** gettext-0.18.3.1.orig/gettext-runtime/intl/bindtextdom.c 2012-12-10 02:59:06.000000000 +0100
+--- gettext-0.18.3.1/gettext-runtime/intl/bindtextdom.c 2014-01-08 21:50:51.057941500 +0100
+***************
+*** 22,27 ****
+--- 22,28 ----
+ #include <stddef.h>
+ #include <stdlib.h>
+ #include <string.h>
++ #include <unistd.h>
+
+ #include "gettextP.h"
+ #ifdef _LIBC
+***************
+*** 66,71 ****
+--- 67,78 ----
+ # define BIND_TEXTDOMAIN_CODESET libintl_bind_textdomain_codeset
+ #endif
+
++ #if ENABLE_RELOCATABLE
++ # include "relocatex.h"
++ #else
++ # define relocate(pathname) (pathname)
++ #endif
++
+ /* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP
+ to be used for the DOMAINNAME message catalog.
+ If *DIRNAMEP or *CODESETP is NULL, the corresponding attribute is not
+***************
+*** 318,325 ****
+--- 325,347 ----
+ char *
+ BINDTEXTDOMAIN (const char *domainname, const char *dirname)
+ {
++ /*
+ set_binding_values (domainname, &dirname, NULL);
+ return (char *) dirname;
++ */
++ if (!access (dirname, R_OK)) {
++ set_binding_values (domainname, &dirname, NULL);
++ return (char *) dirname;
++ } else {
++ char *locale_dirname, *installdir = strdup (dirname), *s;
++ if ((s = strrchr (installdir, '/'))) *s = '\0';
++ if ((s = strrchr (installdir, '/'))) *s = '\0';
++ locale_dirname = relocatex (installdir, dirname);
++ set_binding_values (domainname, (const char **) &locale_dirname, NULL);
++ if (installdir)
++ free (installdir);
++ return (char *) locale_dirname;
++ }
+ }
+
+ /* Specify the character encoding in which the messages from the
+diff -crBN gettext-0.18.3.1.orig/gettext-runtime/intl/canonicalize.c gettext-0.18.3.1/gettext-runtime/intl/canonicalize.c
+*** gettext-0.18.3.1.orig/gettext-runtime/intl/canonicalize.c 1970-01-01 01:00:00.000000000 +0100
+--- gettext-0.18.3.1/gettext-runtime/intl/canonicalize.c 2014-01-08 21:50:51.089192200 +0100
+***************
+*** 0 ****
+--- 1,329 ----
++ /* Return the canonical absolute name of a given file.
++ Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++ #include <stdlib.h>
++ #include <string.h>
++ #include <unistd.h>
++ #include <limits.h>
++ #include <sys/param.h>
++ #include <sys/stat.h>
++ #include <errno.h>
++ #include <stddef.h>
++ #include <malloc.h>
++ #ifdef __WIN32__
++ # include <stdio.h>
++ # include <windows.h>
++ //# include <gw32.h>
++ #endif /* __WIN32__ */
++
++ #ifndef MAXSYMLINKS
++ # define MAXSYMLINKS 20
++ #endif
++
++ #ifndef __set_errno
++ # define __set_errno(Val) errno = (Val)
++ #endif
++
++ # ifdef VMS
++ /* We want the directory in Unix syntax, not in VMS syntax. */
++ # define __getcwd(buf, max) getcwd (buf, max, 0)
++ # else
++ # define __getcwd getcwd
++ # endif
++
++ #define weak_alias(local, symbol)
++
++ #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
++ /* Win32, Cygwin, OS/2, DOS */
++ # define ISDIRSEP(C) ((C) == '/' || (C) == '\\')
++ #else
++ /* Unix */
++ # define ISDIRSEP(C) ((C) == '/')
++ #endif
++
++ /* Return the canonical absolute name of file NAME. A canonical name
++ does not contain any `.', `..' components nor any repeated path
++ separators ('/') or symlinks. All path components must exist. If
++ RESOLVED is null, the result is malloc'd; otherwise, if the
++ canonical name is PATH_MAX chars or more, returns null with `errno'
++ set to ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
++ returns the name in RESOLVED. If the name cannot be resolved and
++ RESOLVED is non-NULL, it contains the path of the first component
++ that cannot be resolved. If the path can be resolved, RESOLVED
++ holds the same value as the value returned.
++ RESOLVED must be at least PATH_MAX long */
++
++ static char *
++ canonicalize (const char *name, char *resolved)
++ {
++ char *rpath, *dest, *extra_buf = NULL;
++ const char *start, *end, *rpath_limit;
++ long int path_max;
++ int num_links = 0, old_errno;
++
++ if (name == NULL)
++ {
++ /* As per Single Unix Specification V2 we must return an error if
++ either parameter is a null pointer. We extend this to allow
++ the RESOLVED parameter to be NULL in case the we are expected to
++ allocate the room for the return value. */
++ __set_errno (EINVAL);
++ return NULL;
++ }
++
++ if (name[0] == '\0')
++ {
++ /* As per Single Unix Specification V2 we must return an error if
++ the name argument points to an empty string. */
++ __set_errno (ENOENT);
++ return NULL;
++ }
++ #ifdef __WIN32__
++ {
++ char *lpFilePart;
++ int len;
++ // fprintf(stderr, "name: %s\n", name);
++ rpath = resolved ? __builtin_alloca (MAX_PATH) : malloc (MAX_PATH);
++ // unix2winpath (name);
++ // fprintf(stderr, "name: %s\n", name);
++ len = GetFullPathName(name, MAX_PATH, rpath, &lpFilePart);
++ /* GetFullPathName returns bogus paths for *nix-style paths, like
++ * /foo/bar - it just prepends current drive to them. Keep them
++ * intact (they need to be for relocation to work!).
++ */
++ if (name[0] == '/') {
++ strncpy (rpath, name, MAX_PATH - 1);
++ rpath[MAX_PATH - 1] = '\0';
++ len = strlen (rpath);
++ }
++ // fprintf(stderr, "rpath: %s\n", rpath);
++ if (len == 0) {
++ //set_werrno;
++ return NULL;
++ }
++ if (len > MAX_PATH) {
++ if (resolved)
++ __set_errno(ENAMETOOLONG);
++ else {
++ rpath = realloc(rpath, len + 2);
++ GetFullPathName(name, len, rpath, &lpFilePart);
++ // fprintf(stderr, "rpath: %s\n", rpath);
++ }
++ }
++ // if ( ISDIRSEP(name[strlen(name)]) && !ISDIRSEP(rpath[len]) ) {
++ // rpath[len] = '\\';
++ // rpath[len + 1] = 0;
++ // }
++ old_errno = errno;
++ //if (!access (rpath, D_OK) && !ISDIRSEP(rpath[len - 1]) ){
++ if (!access (rpath, R_OK) && !ISDIRSEP(rpath[len - 1]) ){
++ rpath[len] = '\\';
++ rpath[len + 1] = 0;
++ }
++ errno = old_errno;
++ win2unixpath (rpath);
++ // fprintf(stderr, "rpath: %s\n", rpath);
++ return resolved ? strcpy(resolved, rpath) : rpath ;
++ }
++ #else /* __WIN32__ */
++
++ #ifdef PATH_MAX
++ path_max = PATH_MAX;
++ #else
++ path_max = pathconf (name, _PC_PATH_MAX);
++ if (path_max <= 0)
++ path_max = 1024;
++ #endif
++
++ rpath = resolved ? __builtin_alloca (path_max) : malloc (path_max);
++ rpath_limit = rpath + path_max;
++
++ if (name[0] != '/')
++ {
++ if (!__getcwd (rpath, path_max))
++ {
++ rpath[0] = '\0';
++ goto error;
++ }
++ dest = strchr (rpath, '\0');
++ }
++ else
++ {
++ rpath[0] = '/';
++ dest = rpath + 1;
++ }
++
++ for (start = end = name; *start; start = end)
++ {
++ #ifdef _LIBC
++ struct stat64 st;
++ #else
++ struct stat st;
++ #endif
++ int n;
++
++ /* Skip sequence of multiple path-separators. */
++ while (*start == '/')
++ ++start;
++
++ /* Find end of path component. */
++ for (end = start; *end && *end != '/'; ++end)
++ /* Nothing. */;
++
++ if (end - start == 0)
++ break;
++ else if (end - start == 1 && start[0] == '.')
++ /* nothing */;
++ else if (end - start == 2 && start[0] == '.' && start[1] == '.')
++ {
++ /* Back up to previous component, ignore if at root already. */
++ if (dest > rpath + 1)
++ while ((--dest)[-1] != '/');
++ }
++ else
++ {
++ size_t new_size;
++
++ if (dest[-1] != '/')
++ *dest++ = '/';
++
++ if (dest + (end - start) >= rpath_limit)
++ {
++ ptrdiff_t dest_offset = dest - rpath;
++
++ if (resolved)
++ {
++ __set_errno (ENAMETOOLONG);
++ if (dest > rpath + 1)
++ dest--;
++ *dest = '\0';
++ goto error;
++ }
++ new_size = rpath_limit - rpath;
++ if (end - start + 1 > path_max)
++ new_size += end - start + 1;
++ else
++ new_size += path_max;
++ rpath = realloc (rpath, new_size);
++ rpath_limit = rpath + new_size;
++ if (rpath == NULL)
++ return NULL;
++
++ dest = rpath + dest_offset;
++ }
++
++ #ifdef _LIBC
++ dest = __mempcpy (dest, start, end - start);
++ #else
++ memcpy (dest, start, end - start);
++ dest += end - start;
++ #endif
++ *dest = '\0';
++
++ #ifdef _LIBC
++ if (__lxstat64 (_STAT_VER, rpath, &st) < 0)
++ #else
++ if (lstat (rpath, &st) < 0)
++ #endif
++ goto error;
++
++ #if HAVE_READLINK
++ if (S_ISLNK (st.st_mode))
++ {
++ char *buf = __builtin_alloca (path_max);
++ size_t len;
++
++ if (++num_links > MAXSYMLINKS)
++ {
++ __set_errno (ELOOP);
++ goto error;
++ }
++
++ n = __readlink (rpath, buf, path_max);
++ if (n < 0)
++ goto error;
++ buf[n] = '\0';
++
++ if (!extra_buf)
++ extra_buf = __builtin_alloca (path_max);
++
++ len = strlen (end);
++ if ((long int) (n + len) >= path_max)
++ {
++ __set_errno (ENAMETOOLONG);
++ goto error;
++ }
++
++ /* Careful here, end may be a pointer into extra_buf... */
++ memmove (&extra_buf[n], end, len + 1);
++ name = end = memcpy (extra_buf, buf, n);
++
++ if (buf[0] == '/')
++ dest = rpath + 1; /* It's an absolute symlink */
++ else
++ /* Back up to previous component, ignore if at root already: */
++ if (dest > rpath + 1)
++ while ((--dest)[-1] != '/');
++ }
++ #endif
++ }
++ }
++ if (dest > rpath + 1 && dest[-1] == '/')
++ --dest;
++ *dest = '\0';
++
++ return resolved ? memcpy (resolved, rpath, dest - rpath + 1) : rpath;
++
++ error:
++ if (resolved)
++ strcpy (resolved, rpath);
++ else
++ free (rpath);
++ return NULL;
++
++ #endif /* __WIN32__ */
++ }
++
++
++ char *
++ __realpath (const char *name, char *resolved)
++ {
++ if (resolved == NULL)
++ {
++ __set_errno (EINVAL);
++ return NULL;
++ }
++
++ return canonicalize (name, resolved);
++ }
++ weak_alias (__realpath, realpath)
++
++
++ char *
++ __canonicalize_file_name (const char *name)
++ {
++ return canonicalize (name, NULL);
++ }
++ weak_alias (__canonicalize_file_name, canonicalize_file_name)
++
++ char *
++ canonicalize_file_name (const char *name)
++ {
++ return canonicalize (name, NULL);
++ }
+diff -crBN gettext-0.18.3.1.orig/gettext-runtime/intl/Makefile.in gettext-0.18.3.1/gettext-runtime/intl/Makefile.in
+*** gettext-0.18.3.1.orig/gettext-runtime/intl/Makefile.in 2013-07-29 13:35:59.000000000 +0200
+--- gettext-0.18.3.1/gettext-runtime/intl/Makefile.in 2014-01-08 21:52:05.080559000 +0100
+***************
+*** 122,127 ****
+--- 122,128 ----
+ localcharset.h \
+ lock.h \
+ relocatable.h \
++ relocatex.h \
+ tsearch.h tsearch.c \
+ verify.h \
+ xsize.h \
+***************
+*** 152,157 ****
+--- 153,160 ----
+ threadlib.c \
+ lock.c \
+ relocatable.c \
++ relocatex.c \
++ canonicalize.c \
+ langprefs.c \
+ localename.c \
+ log.c \
+***************
+*** 185,190 ****
+--- 188,195 ----
+ threadlib.$lo \
+ lock.$lo \
+ relocatable.$lo \
++ relocatex.$lo \
++ canonicalize.$lo \
+ langprefs.$lo \
+ localename.$lo \
+ log.$lo \
+***************
+*** 287,292 ****
+--- 292,301 ----
+ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/threadlib.c
+ lock.lo: $(srcdir)/lock.c
+ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/lock.c
++ relocatex.lo: $(srcdir)/relocatex.c
++ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/relocatex.c
++ canonicalize.lo: $(srcdir)/canonicalize.c
++ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/canonicalize.c
+ relocatable.lo: $(srcdir)/relocatable.c
+ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(COMPILE) $(srcdir)/relocatable.c
+ langprefs.lo: $(srcdir)/langprefs.c
+diff -crBN gettext-0.18.3.1.orig/gettext-runtime/intl/relocatex.c gettext-0.18.3.1/gettext-runtime/intl/relocatex.c
+*** gettext-0.18.3.1.orig/gettext-runtime/intl/relocatex.c 1970-01-01 01:00:00.000000000 +0100
+--- gettext-0.18.3.1/gettext-runtime/intl/relocatex.c 2014-01-08 21:50:51.136095000 +0100
+***************
+*** 0 ****
+--- 1,295 ----
++ /* Provide relocatable packages.
++ Copyright (C) 2003 Free Software Foundation, Inc.
++ Written by Bruno Haible <bruno@clisp.org>, 2003.
++
++ This program is free software; you can redistribute it and/or modify it
++ under the terms of the GNU Library General Public License as published
++ by the Free Software Foundation; either version 2, or (at your option)
++ any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Library General Public License for more details.
++
++ You should have received a copy of the GNU Library General Public
++ License along with this program; if not, write to the Free Software
++ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
++ USA. */
++
++
++ /* Specification. */
++ #include <errno.h>
++ #define _GNU_SOURCE
++ #include <stdlib.h>
++ #include <string.h>
++ #include <stdio.h>
++ #include <unistd.h>
++ /* #include <path.h> */
++ #include "relocatex.h"
++ //#include "canonicalize.h"
++ /* #include <gw32.h> */
++
++
++ #if defined _WIN32 || defined __WIN32__
++ # define WIN32_LEAN_AND_MEAN
++ # include <windows.h>
++ //# define __GW32__
++ //# include <winx/errnox.h>
++ #endif
++ #define set_werrno
++
++ #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
++ /* Win32, Cygwin, OS/2, DOS */
++ # define ISDIRSEP(C) ((C) == '/' || (C) == '\\')
++ #else
++ /* Unix */
++ # define ISDIRSEP(C) ((C) == '/')
++ #endif
++
++ /* Original installation prefix. */
++ static char *orig_prefix = NULL;
++ static size_t orig_prefix_len = 0;
++ /* Current installation prefix. */
++ static char *curr_prefix = NULL;
++ static size_t curr_prefix_len = 0;
++ /* These prefixes do not end in a slash. Anything that will be concatenated
++ to them must start with a slash. */
++
++
++ char *win2unixpath (char *FileName)
++ {
++ char *s = FileName;
++ while (*s) {
++ if (*s == '\\')
++ *s = '/';
++ *s++;
++ }
++ return FileName;
++ }
++
++ int win2posixpath (const char *winpath, char *posixpath)
++ {
++ strcpy (posixpath, winpath);
++ win2unixpath (posixpath);
++ return 0;
++ }
++
++
++ /* Sets the original and the current installation prefix of this module.
++ Relocation simply replaces a pathname starting with the original prefix
++ by the corresponding pathname with the current prefix instead. Both
++ prefixes should be directory names without trailing slash (i.e. use ""
++ instead of "/"). */
++ static char *
++ set_orig_prefix (const char *orig_prefix_arg)
++ {
++ char *memory;
++ // printf ("orig_prefix_arg: %s\n", orig_prefix_arg);
++ if (!orig_prefix_arg) {
++ orig_prefix = NULL;
++ orig_prefix_len = 0;
++ return NULL;
++ }
++ if (orig_prefix)
++ free (orig_prefix);
++
++ memory = canonicalize_file_name (orig_prefix_arg);
++ // printf ("memory: %s\n", memory);
++ // memory = (char *) malloc (orig_prefix_len + 1);
++ if (!memory) {
++ set_werrno;
++ orig_prefix = NULL;
++ orig_prefix_len = 0;
++ return NULL;
++ }
++ win2unixpath (memory);
++ // win2posixpath (orig_prefix_arg, memory);
++ orig_prefix = memory;
++ orig_prefix_len = strlen (orig_prefix);
++ // printf ("orig_prefix: %s\n", orig_prefix);
++ if (ISDIRSEP (orig_prefix[orig_prefix_len-1])) {
++ orig_prefix[orig_prefix_len-1] = '\0';
++ orig_prefix_len--;
++ }
++ // printf ("orig_prefix: %s\n", orig_prefix);
++ // printf ("orig_prefix_len: %d\n", orig_prefix_len);
++ return orig_prefix;
++ }
++
++ #if defined __WIN32__
++ static char *
++ set_current_prefix (const char *ModuleName)
++ {
++ LPTSTR curr_prefix_arg, q, lpFilePart;
++ DWORD len;
++ int nDIRSEP = 0;
++
++ if (curr_prefix)
++ free (curr_prefix);
++ curr_prefix_arg = malloc (MAX_PATH * sizeof (TCHAR));
++ if (!curr_prefix_arg) {
++ set_werrno;
++ curr_prefix = NULL;
++ curr_prefix_len = 0;
++ return NULL;
++ }
++ if (ModuleName) {
++ // printf ("ModuleName: %s\n", ModuleName);
++ len = SearchPath (NULL, ModuleName, ".DLL", MAX_PATH, curr_prefix_arg, &lpFilePart);
++ if (len) {
++ // printf ("ModulePath: %s\n", curr_prefix_arg);
++ // printf ("FilePart: %s\n", lpFilePart);
++ }
++ }
++ if (!ModuleName || !len) {
++ len = GetModuleFileName (NULL, curr_prefix_arg, MAX_PATH);
++ if (!len) {
++ set_werrno;
++ curr_prefix = NULL;
++ curr_prefix_len = 0;
++ return NULL;
++ }
++ }
++ // strncpy (curr_prefix_arg, ModuleName, MAX_PATH);
++ // printf ("curr_prefix_arg: %s\n", curr_prefix_arg);
++ win2posixpath (curr_prefix_arg, curr_prefix_arg);
++ curr_prefix = curr_prefix_arg;
++ q = curr_prefix_arg + len - 1;
++ /* strip name of executable and its directory */
++ while (!ISDIRSEP (*q) && (q > curr_prefix_arg) && nDIRSEP < 2) {
++ q--;
++ if (ISDIRSEP (*q)) {
++ *q = '\0';
++ nDIRSEP++;
++ }
++ }
++ curr_prefix_len = q - curr_prefix_arg;
++ // printf ("curr_prefix: %s\n", curr_prefix);
++ // printf ("curr_prefix_len: %d\n", curr_prefix_len);
++ return curr_prefix;
++ }
++
++ char *getshortpath (const char *longpath)
++ {
++ char *shortpath = NULL;
++ DWORD len, res;
++
++ // printf ("longpath: %s\n", longpath);
++ len = GetShortPathName(longpath, shortpath, 0);
++ // printf ("len: %ld\n", len);
++ if (!len) {
++ // WinErr ("getshortpath: len = 0");
++ set_werrno;
++ return (char *) longpath;
++ }
++ shortpath = (char *) malloc (len + 1);
++ if (!shortpath) {
++ // WinErr ("getshortpath: malloc");
++ set_werrno;
++ return (char *) longpath;
++ }
++ res = GetShortPathName(longpath, shortpath, len);
++ // printf ("res: %ld\n", res);
++ if (!res) {
++ // WinErr ("getshortpath: res = 0");
++ free (shortpath);
++ set_werrno;
++ return (char *) longpath;
++ }
++ // printf ("shortpath: %s\n", shortpath);
++ return shortpath;
++ }
++
++ char *relocaten (const char *ModuleName, const char *path)
++ {
++ char *relative_path, *relocated_path, *relocated_short_path;
++ int relative_path_len;
++
++ if (!curr_prefix)
++ set_current_prefix (ModuleName);
++ // printf ("path: %s\n", path);
++ // printf ("orig_prefix: %s\n", orig_prefix);
++ // printf ("curr_prefix: %s\n", curr_prefix);
++ // if (strncmp (orig_prefix, path, orig_prefix_len))
++ // if (strcmp (orig_prefix, path))
++ // return (char *) path;
++ relative_path = (char *) path + orig_prefix_len;
++ // printf ("relative_path: %s\n", relative_path);
++ relative_path_len = strlen (relative_path);
++ relocated_path = malloc (curr_prefix_len + relative_path_len + 1);
++ strcpy (relocated_path, curr_prefix);
++ strcat (relocated_path, relative_path);
++ // printf ("relocated_path: %s\n", relocated_path);
++ relocated_short_path = getshortpath (relocated_path);
++ // printf ("relocated_short_path: %s\n", relocated_short_path);
++ if (relocated_short_path) {
++ if (relocated_short_path != relocated_path)
++ free (relocated_path);
++ return relocated_short_path;
++ } else
++ return relocated_path;
++ }
++
++ #else // __WIN32__
++ char *relocaten (const char *ModuleName, const char *path)
++ {
++ // dummy function for Unix/Linux
++ return (char *)path;
++ }
++ #endif
++
++ char *relocaten2 (const char *ModuleName, const char *installdir, const char *path)
++ {
++ set_orig_prefix (installdir);
++ return relocaten (ModuleName, path);
++ }
++
++ char *relocatenx (const char *ModuleName, const char *installdir, const char *path)
++ {
++ char *p;
++
++ set_orig_prefix (installdir);
++ if (access (path, R_OK))
++ p = relocaten (ModuleName, path);
++ else
++ p = (char *) path;
++ // printf ("relocatenx: %s\n", p);
++ return p;
++ }
++
++ char *relocate2 (const char *installdir, const char *path)
++ {
++ return relocaten2 (NULL, installdir, path);
++ }
++
++ char *relocatex (const char *installdir, const char *path)
++ {
++ return relocatenx (NULL, installdir, path);
++ }
++
++ char *relocatepx (const char *cprefix, const char *installdir, const char *path)
++ {
++ if (curr_prefix)
++ free (curr_prefix);
++ curr_prefix = strdup (cprefix);
++ return relocatex (installdir, path);
++ }
++
++ static char *get_orig_prefix (void)
++ {
++ return orig_prefix;
++ }
++
++ static char *get_curr_prefix (void)
++ {
++ return curr_prefix;
++ }
++
++ static char *set_curr_prefix (const char *ModuleName)
++ {
++ if (curr_prefix)
++ free (curr_prefix);
++ set_current_prefix (ModuleName);
++ return curr_prefix;
++ }
+diff -crBN gettext-0.18.3.1.orig/gettext-runtime/intl/relocatex.h gettext-0.18.3.1/gettext-runtime/intl/relocatex.h
+*** gettext-0.18.3.1.orig/gettext-runtime/intl/relocatex.h 1970-01-01 01:00:00.000000000 +0100
+--- gettext-0.18.3.1/gettext-runtime/intl/relocatex.h 2014-01-08 21:50:51.136095000 +0100
+***************
+*** 0 ****
+--- 1,41 ----
++ /*
++ Copyright (C) 2006 Free Software Foundation, Inc.
++ This file is part of the GnuWin C Library.
++
++ The GnuWin C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GnuWin C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GnuWin32 C Library; if not, write to the Free
++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
++ 02111-1307 USA. */
++
++ #ifndef __RELOCATE_H__
++ #define __RELOCATE_H__ 1
++
++ /* #include <libc-dll.h> */
++
++ #ifdef __cplusplus
++ extern "C" {
++ #endif
++
++ char *relocaten (const char *ModuleName, const char *path);
++ char *relocaten2 (const char *ModuleName, const char *installdir, const char *path);
++ char *relocatenx (const char *ModuleName, const char *installdir, const char *path);
++ char *relocate2 (const char *installdir, const char *path);
++ char *relocatex (const char *installdir, const char *path);
++
++ #ifdef __cplusplus
++ }
++ #endif
++
++ //#endif /* __GW32__ */
++
++ #endif /* __RELOCATE_H__ */
+diff -crBN gettext-0.18.3.1.orig/MINGW-PATCHES/README-relocatex-libintl.txt gettext-0.18.3.1/MINGW-PATCHES/README-relocatex-libintl.txt
+*** gettext-0.18.3.1.orig/MINGW-PATCHES/README-relocatex-libintl.txt 1970-01-01 01:00:00.000000000 +0100
+--- gettext-0.18.3.1/MINGW-PATCHES/README-relocatex-libintl.txt 2014-01-08 21:50:51.151701000 +0100
+***************
+*** 0 ****
+--- 1,23 ----
++ The relocatex-libintl patch adds builtin relocation for executables to the
++ libintl dll. With this patch the programs are automatically relocatable. There
++ is no need anymore to add relocation code to your program when you use this
++ libintl DLL.
++
++ The patch was ported from the GnuWin32 port of libintl, which has also builtin
++ relacation support.
++
++ At the moment the relocation support is only active if you compile with MinGW
++ for Windows. If you compile for Unix/Linux/Cygwin the functionality is
++ unchanged.
++
++ See also:
++ http://waterlan.home.xs4all.nl/libintl.html
++ http://sourceforge.net/tracker/?func=detail&atid=302435&aid=3003879&group_id=2435
++ GnuWin32: http://gnuwin32.sourceforge.net/
++
++ Great thanks to GnuWin32 maintainer Kees Zeelenberg.
++
++ Erwin Waterlander
++ waterlan@xs4all.nl
++ http://waterlan.home.xs4all.nl/
++
diff --git a/05-always-use-libintl-vsnprintf.mingw.patch b/05-always-use-libintl-vsnprintf.mingw.patch
new file mode 100644
index 000000000000..28d543730300
--- /dev/null
+++ b/05-always-use-libintl-vsnprintf.mingw.patch
@@ -0,0 +1,11 @@
+--- gettext-runtime/intl/printf.c.orig 2012-09-22 16:23:24 +0400
++++ gettext-runtime/intl/printf.c 2012-09-22 23:45:29 +0400
+@@ -209,7 +209,7 @@
+ int
+ libintl_vsnprintf (char *resultbuf, size_t length, const char *format, va_list args)
+ {
+- if (strchr (format, '$') == NULL)
++ if (0 && (strchr (format, '$') == NULL))
+ return system_vsnprintf (resultbuf, length, format, args);
+ else
+ {
diff --git a/06-dont-include-ctype-after-gnulibs-wctype.mingw.patch b/06-dont-include-ctype-after-gnulibs-wctype.mingw.patch
new file mode 100644
index 000000000000..a52883bd258a
--- /dev/null
+++ b/06-dont-include-ctype-after-gnulibs-wctype.mingw.patch
@@ -0,0 +1,44 @@
+--- gettext-tools/gnulib-lib/libxml/parser.c.orig 2013-01-18 10:24:37 +0400
++++ gettext-tools/gnulib-lib/libxml/parser.c 2013-01-18 10:36:35 +0400
+@@ -42,6 +42,9 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdarg.h>
++#ifdef HAVE_CTYPE_H
++#include <ctype.h>
++#endif
+ #include <libxml/xmlmemory.h>
+ #include <libxml/threads.h>
+ #include <libxml/globals.h>
+@@ -61,9 +64,6 @@
+ #include <libxml/xmlschemastypes.h>
+ #include <libxml/relaxng.h>
+ #endif
+-#ifdef HAVE_CTYPE_H
+-#include <ctype.h>
+-#endif
+ #ifdef HAVE_STDLIB_H
+ #include <stdlib.h>
+ #endif
+--- gettext-tools/gnulib-lib/libxml/threads.c.orig 2013-01-18 10:38:24 +0400
++++ gettext-tools/gnulib-lib/libxml/threads.c 2013-01-18 10:41:11 +0400
+@@ -12,15 +12,16 @@
+
+ #include <string.h>
+
++#ifdef HAVE_UNISTD_H
++#include <unistd.h>
++#endif
++
+ #include <libxml/threads.h>
+ #include <libxml/globals.h>
+
+ #ifdef HAVE_SYS_TYPES_H
+ #include <sys/types.h>
+ #endif
+-#ifdef HAVE_UNISTD_H
+-#include <unistd.h>
+-#endif
+ #ifdef HAVE_STDLIB_H
+ #include <stdlib.h>
+ #endif
diff --git a/07-fix-asprintf-conflict.mingw.patch b/07-fix-asprintf-conflict.mingw.patch
new file mode 100644
index 000000000000..725d2c797ad1
--- /dev/null
+++ b/07-fix-asprintf-conflict.mingw.patch
@@ -0,0 +1,63 @@
+--- gettext-runtime/libasprintf/vasnprintf.h.orig 2013-01-17 09:09:12 +0400
++++ gettext-runtime/libasprintf/vasnprintf.h 2013-05-01 17:33:31 +0400
+@@ -40,6 +40,8 @@
+ extern "C" {
+ #endif
+
++#if !defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW64_VERSION_MAJOR)
++
+ /* Write formatted output to a string dynamically allocated with malloc().
+ You can pass a preallocated buffer for the result in RESULTBUF and its
+ size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
+@@ -64,11 +66,14 @@
+ free (output);
+ }
+ */
++
+ extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
+ __attribute__ ((__format__ (__printf__, 3, 4)));
+ extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
+ __attribute__ ((__format__ (__printf__, 3, 0)));
+
++#endif /* !defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW64_VERSION_MAJOR) */
++
+ #ifdef __cplusplus
+ }
+ #endif
+--- gettext-runtime/libasprintf/vasprintf.h.orig 2013-04-30 09:03:19 +0400
++++ gettext-runtime/libasprintf/vasprintf.h 2013-05-01 17:32:04 +0400
+@@ -37,6 +37,8 @@
+ extern "C" {
+ #endif
+
++#if !defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW64_VERSION_MAJOR)
++
+ /* Write formatted output to a string dynamically allocated with malloc().
+ If the memory allocation succeeds, store the address of the string in
+ *RESULT and return the number of resulting bytes, excluding the trailing
+@@ -46,6 +48,8 @@
+ extern int vasprintf (char **result, const char *format, va_list args)
+ __attribute__ ((__format__ (__printf__, 2, 0)));
+
++#endif /* !defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW64_VERSION_MAJOR) */
++
+ #ifdef __cplusplus
+ }
+ #endif
+--- gettext-runtime/libasprintf/vasnprintf.c.orig 2013-05-01 18:07:02 +0400
++++ gettext-runtime/libasprintf/vasnprintf.c 2013-05-01 18:42:46 +0400
+@@ -67,7 +67,14 @@
+ #endif
+
+ #include <locale.h> /* localeconv() */
++#if defined(__MINGW64_VERSION_MAJOR) && defined(__USE_MINGW_ANSI_STDIO)
++# define REMOVED__USE_MINGW_ANSI_STDIO
++# undef __USE_MINGW_ANSI_STDIO
++#endif
+ #include <stdio.h> /* snprintf(), sprintf() */
++#if defined(__MINGW64_VERSION_MAJOR) && defined(REMOVED__USE_MINGW_ANSI_STDIO)
++# define __USE_MINGW_ANSI_STDIO
++#endif
+ #include <stdlib.h> /* abort(), malloc(), realloc(), free() */
+ #include <string.h> /* memcpy(), strlen() */
+ #include <errno.h> /* errno */
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..5ddc26b4bd8c
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,63 @@
+# Contributor: Filip Brcic <brcha@gna.org>
+pkgname=mingw-w64-gettext
+pkgver=0.19.4
+pkgrel=4
+arch=(any)
+pkgdesc="GNU internationalization library (mingw-w64)"
+depends=(mingw-w64-crt mingw-w64-libiconv mingw-w64-termcap mingw-w64-libunistring)
+makedepends=(mingw-w64-gcc mingw-w64-configure)
+options=(!strip !buildflags staticlibs)
+license=("GPL")
+url="http://www.gnu.org/software/gettext"
+source=("http://ftp.gnu.org/pub/gnu/gettext/gettext-${pkgver}.tar.gz"{,.sig}
+"00-relocatex-libintl-0.18.3.1.patch"
+"05-always-use-libintl-vsnprintf.mingw.patch"
+"06-dont-include-ctype-after-gnulibs-wctype.mingw.patch"
+"07-fix-asprintf-conflict.mingw.patch")
+md5sums=('d3511af1e604a3478900d2c2b4a4a48e'
+ 'SKIP'
+ '397d7d6d4abd15a70edb3c9f2bab4cd2'
+ '27852a388b8cf38188dc392c244230ff'
+ 'f69747f43f279b8a81286cfe5916b82f'
+ '3ebccf730ec3377b068027eb2283afb2')
+validpgpkeys=('462225C3B46F34879FC8496CD605848ED7E69871') # Daiki Ueno
+
+_architectures="i686-w64-mingw32 x86_64-w64-mingw32"
+
+prepare() {
+ cd gettext-$pkgver
+ patch -p1 -i ${srcdir}/00-relocatex-libintl-0.18.3.1.patch
+ patch -p0 -i ${srcdir}/05-always-use-libintl-vsnprintf.mingw.patch
+ patch -p0 -i ${srcdir}/06-dont-include-ctype-after-gnulibs-wctype.mingw.patch
+ patch -p0 -i ${srcdir}/07-fix-asprintf-conflict.mingw.patch
+}
+
+build() {
+ cd gettext-${pkgver}
+ unset LDFLAGS
+ for _arch in ${_architectures}; do
+ mkdir -p build-${_arch} && pushd build-${_arch}
+ ${_arch}-configure \
+ --target=${_arch} \
+ --disable-java \
+ --disable-native-java \
+ --disable-csharp \
+ --enable-threads=win32 \
+ --without-emacs
+ make
+ popd
+ done
+}
+
+package() {
+ for _arch in ${_architectures}; do
+ cd "${srcdir}/${pkgname#mingw-w64-}-$pkgver/build-${_arch}"
+ make DESTDIR="$pkgdir" install
+ find "$pkgdir/usr/${_arch}" -name '*.exe' -exec rm {} \;
+ find "$pkgdir/usr/${_arch}" -name '*.dll' -exec ${_arch}-strip --strip-unneeded {} \;
+ find "$pkgdir/usr/${_arch}" -name '*.a' -o -name '*.dll' | xargs ${_arch}-strip -g
+ rm "$pkgdir/usr/${_arch}/bin/"{autopoint,gettext.sh,gettextize}
+ rm -r "$pkgdir/usr/${_arch}/lib/gettext"
+ rm -r "$pkgdir/usr/${_arch}/share"
+ done
+}