Skip to content

Instantly share code, notes, and snippets.

@1480c1
Last active August 27, 2020 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1480c1/b1dfe3a208ce69048e1fca72f6135225 to your computer and use it in GitHub Desktop.
Save 1480c1/b1dfe3a208ce69048e1fca72f6135225 to your computer and use it in GitHub Desktop.
vabs: gettext
From 9198f94896fc13407d4ca8f2acd8f01f8f80e494 Mon Sep 17 00:00:00 2001
From: Tim S <stahta01@users.sourceforge.net>
Date: Sun, 16 Sep 2018 10:35:04 -0400
Subject: [PATCH 1/2] Use LF as newline in envsubst
Now using underline prefix in functions as stated at:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmode
And, change mode back to prior mode
---
gettext-runtime/src/envsubst.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/gettext-runtime/src/envsubst.c b/gettext-runtime/src/envsubst.c
index ffe4ce79d..29b1f0daf 100644
--- a/gettext-runtime/src/envsubst.c
+++ b/gettext-runtime/src/envsubst.c
@@ -28,6 +28,11 @@
#include <unistd.h>
#include <locale.h>
+#ifdef _WIN32
+#include <fcntl.h>
+#include <io.h> /* for _setmode() */
+#endif
+
#include "noreturn.h"
#include "closeout.h"
#include "error.h"
@@ -290,7 +295,17 @@ static void
print_variable (const char *var_ptr, size_t var_len)
{
fwrite (var_ptr, var_len, 1, stdout);
+#if defined(_WIN32)
+ /* Change to binary mode */
+ int oldmode = _setmode(_fileno(stdout), _O_BINARY);
+#endif
putchar ('\n');
+#if defined(_WIN32)
+ fflush(stdout); /* Must flush before changing mode back */
+ if ( oldmode != -1 )
+ /* Return to prior mode */
+ _setmode( _fileno( stdout ), oldmode );
+#endif
}
/* Print the variables contained in STRING to stdout, each one followed by a
--
2.25.1
From 1a66f5468517dd501ca76fde4d4b1d9b44e3700c Mon Sep 17 00:00:00 2001
From: Christopher Degawa <ccom@randomderp.com>
Date: Mon, 24 Aug 2020 17:56:55 +0000
Subject: [PATCH 2/2] vabs
---
configure.ac | 2 +-
gettext-runtime/configure.ac | 2 +-
gettext-runtime/intl/libgnuintl.in.h | 2 +-
gettext-runtime/intl/printf.c | 45 +++++++++---------------
gettext-runtime/libasprintf/configure.ac | 2 +-
gettext-runtime/libasprintf/vasnprintf.c | 7 ++++
gettext-runtime/libasprintf/vasnprintf.h | 5 +++
gettext-runtime/libasprintf/vasprintf.h | 4 +++
gettext-tools/configure.ac | 4 +--
gettext-tools/gnulib-lib/Makefile.am | 2 ++
gettext-tools/misc/autopoint.in | 28 +++++++--------
gettext-tools/misc/gettextize.in | 14 ++++----
libtextstyle/configure.ac | 2 +-
13 files changed, 62 insertions(+), 57 deletions(-)
diff --git a/configure.ac b/configure.ac
index 49689fb01..540480e34 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,7 @@ dnl along with this program. If not, see <https://www.gnu.org/licenses/>.
dnl Process this file with autoconf to produce a configure script.
-AC_PREREQ([2.63])
+AC_PREREQ([2.64])
AC_INIT([gettext],
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
[bug-gettext@gnu.org])
diff --git a/gettext-runtime/configure.ac b/gettext-runtime/configure.ac
index b2bfda5e1..93f24054e 100644
--- a/gettext-runtime/configure.ac
+++ b/gettext-runtime/configure.ac
@@ -16,7 +16,7 @@ dnl along with this program. If not, see <https://www.gnu.org/licenses/>.
dnl Process this file with autoconf to produce a configure script.
-AC_PREREQ([2.63])
+AC_PREREQ([2.64])
AC_INIT([gettext-runtime],
m4_esyscmd([../build-aux/git-version-gen ../.tarball-version]),
[bug-gettext@gnu.org])
diff --git a/gettext-runtime/intl/libgnuintl.in.h b/gettext-runtime/intl/libgnuintl.in.h
index 6fb192061..c2f64071f 100644
--- a/gettext-runtime/intl/libgnuintl.in.h
+++ b/gettext-runtime/intl/libgnuintl.in.h
@@ -368,7 +368,7 @@ extern int vfprintf (FILE *, const char *, va_list);
#if !(defined printf && defined _GL_STDIO_H) /* don't override gnulib */
#undef printf
-#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__
+#if defined __NetBSD__ || defined __BEOS__ || defined __CYGWIN__ || defined __MINGW32__ || defined _MSC_VER
/* Don't break __attribute__((format(printf,M,N))).
This redefinition is only possible because the libc in NetBSD, Cygwin,
mingw does not have a function __printf__.
diff --git a/gettext-runtime/intl/printf.c b/gettext-runtime/intl/printf.c
index 7c07ed759..bfb916e03 100644
--- a/gettext-runtime/intl/printf.c
+++ b/gettext-runtime/intl/printf.c
@@ -219,38 +219,25 @@ libintl_sprintf (char *resultbuf, const char *format, ...)
# endif
DLL_EXPORTED
-int
-libintl_vsnprintf (char *resultbuf, size_t length, const char *format, va_list args)
-{
-# if !USE_REPLACEMENT_CODE_ALWAYS
- if (strchr (format, '$') == NULL)
- return system_vsnprintf (resultbuf, length, format, args);
- else
-# endif
- {
- size_t maxlength = length;
- char *result = libintl_vasnprintf (resultbuf, &length, format, args);
- if (result == NULL)
- return -1;
- if (result != resultbuf)
- {
- if (maxlength > 0)
- {
- size_t pruned_length =
+int libintl_vsnprintf(char *resultbuf, size_t length, const char *format,
+ va_list args) {
+ size_t maxlength = length;
+ char *result = libintl_vasnprintf(resultbuf, &length, format, args);
+ if (result == NULL) return -1;
+ if (result != resultbuf) {
+ if (maxlength > 0) {
+ size_t pruned_length =
(length < maxlength ? length : maxlength - 1);
- memcpy (resultbuf, result, pruned_length);
- resultbuf[pruned_length] = '\0';
- }
- free (result);
+ memcpy(resultbuf, result, pruned_length);
+ resultbuf[pruned_length] = '\0';
}
- if (length > INT_MAX)
- {
- errno = EOVERFLOW;
- return -1;
- }
- else
- return length;
+ free(result);
+ }
+ if (length > INT_MAX) {
+ errno = EOVERFLOW;
+ return -1;
}
+ return length;
}
DLL_EXPORTED
diff --git a/gettext-runtime/libasprintf/configure.ac b/gettext-runtime/libasprintf/configure.ac
index 776a1f4d7..ad5345c60 100644
--- a/gettext-runtime/libasprintf/configure.ac
+++ b/gettext-runtime/libasprintf/configure.ac
@@ -16,7 +16,7 @@ dnl along with this program. If not, see <https://www.gnu.org/licenses/>.
dnl Process this file with autoconf to produce a configure script.
-AC_PREREQ([2.63])
+AC_PREREQ([2.64])
AC_INIT([libasprintf], [1.0])
AC_CONFIG_SRCDIR([vasprintf.c])
AC_CONFIG_AUX_DIR([../../build-aux])
diff --git a/gettext-runtime/libasprintf/vasnprintf.c b/gettext-runtime/libasprintf/vasnprintf.c
index 079d6f174..c34ceca07 100644
--- a/gettext-runtime/libasprintf/vasnprintf.c
+++ b/gettext-runtime/libasprintf/vasnprintf.c
@@ -74,7 +74,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/gettext-runtime/libasprintf/vasnprintf.h b/gettext-runtime/libasprintf/vasnprintf.h
index e58bd40cf..0e4333bdb 100644
--- a/gettext-runtime/libasprintf/vasnprintf.h
+++ b/gettext-runtime/libasprintf/vasnprintf.h
@@ -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 @@ extern "C" {
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
diff --git a/gettext-runtime/libasprintf/vasprintf.h b/gettext-runtime/libasprintf/vasprintf.h
index 2b65c7217..2c59fe834 100644
--- a/gettext-runtime/libasprintf/vasprintf.h
+++ b/gettext-runtime/libasprintf/vasprintf.h
@@ -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 asprintf (char **result, const char *format, ...)
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
diff --git a/gettext-tools/configure.ac b/gettext-tools/configure.ac
index 04db78149..637f233f9 100644
--- a/gettext-tools/configure.ac
+++ b/gettext-tools/configure.ac
@@ -16,7 +16,7 @@ dnl along with this program. If not, see <https://www.gnu.org/licenses/>.
dnl Process this file with autoconf to produce a configure script.
-AC_PREREQ([2.63])
+AC_PREREQ([2.64])
AC_INIT([gettext-tools],
m4_esyscmd([../build-aux/git-version-gen ../.tarball-version]),
[bug-gettext@gnu.org])
@@ -179,7 +179,7 @@ AC_TRY_LINK([
[x = ceil(x); x = sqrt(x);],
[MSGMERGE_LIBM=])
if test "$MSGMERGE_LIBM" = "?"; then
- save_LIBS="$LIBS"
+ save_LIBS="$LIBS"
LIBS="$LIBS -lm"
AC_TRY_LINK([
#ifndef __NO_MATH_INLINES
diff --git a/gettext-tools/gnulib-lib/Makefile.am b/gettext-tools/gnulib-lib/Makefile.am
index e2a935df9..722fd1829 100644
--- a/gettext-tools/gnulib-lib/Makefile.am
+++ b/gettext-tools/gnulib-lib/Makefile.am
@@ -45,6 +45,8 @@ AM_CPPFLAGS += -I$(top_builddir) -I$(top_srcdir)
# Parametrization of the 'relocatable' module.
AM_CPPFLAGS += -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1
+AM_CPPFLAGS += -DINSTALLDIR=\"$(bindir)\"
+
# Parametrization of the 'libxml' module:
# When building a shared library, don't export the variables
# xmlMalloc, xmlMallocAtomic, xmlRealloc, xmlFree, xmlMemStrdup.
diff --git a/gettext-tools/misc/autopoint.in b/gettext-tools/misc/autopoint.in
index 3a24eee5d..8bf9d1824 100644
--- a/gettext-tools/misc/autopoint.in
+++ b/gettext-tools/misc/autopoint.in
@@ -91,7 +91,7 @@ func_find_curr_installdir ()
*) curr_executable=`pwd`/"$curr_executable" ;;
esac
# Resolve symlinks.
- sed_dirname='s,/[^/]*$,,'
+ sed_dirname='s,[\\/][^\\/]*$,,'
sed_linkdest='s,^.* -> \(.*\),\1,p'
while : ; do
lsline=`LC_ALL=C ls -l "$curr_executable"`
@@ -105,7 +105,7 @@ func_find_curr_installdir ()
*) break ;;
esac
done
- curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'`
+ curr_installdir=`echo "$curr_executable" | sed -e 's,[\\/][^\\/]*$,,'`
# Canonicalize.
curr_installdir=`cd "$curr_installdir" && pwd`
}
@@ -116,16 +116,16 @@ func_find_prefixes ()
orig_installprefix="$orig_installdir"
curr_installprefix="$curr_installdir"
while true; do
- orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
- curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
+ orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*[\\/]\([^\\/]*\)$,\1,p'`
+ curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*[\\/]\([^\\/]*\)$,\1,p'`
if test -z "$orig_last" || test -z "$curr_last"; then
break
fi
if test "$orig_last" != "$curr_last"; then
break
fi
- orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'`
- curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'`
+ orig_installprefix=`echo "$orig_installprefix" | sed -e 's,[\\/][^\\/]*$,,'`
+ curr_installprefix=`echo "$curr_installprefix" | sed -e 's,[\\/][^\\/]*$,,'`
done
}
if test "@RELOCATABLE@" = yes; then
@@ -135,7 +135,7 @@ if test "@RELOCATABLE@" = yes; then
func_find_curr_installdir # determine curr_installdir
func_find_prefixes
# Relocate the directory variables that we use.
- gettext_datadir=`echo "$gettext_datadir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'`
+ gettext_datadir=`echo "$gettext_datadir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,[\\/]$,,'`
fi
# func_trace_autoconf macro configure.ac
@@ -652,7 +652,7 @@ func_destfile ()
# po/* ->
sharedowner=
allpodirs=
- case `echo "$1" | sed -e 's,[^/]*$,,'` in
+ case `echo "$1" | sed -e 's,[^\\/]*$,,'` in
"" )
case "$1" in
config.rpath ) destfile="$auxdir$1" ;;
@@ -660,7 +660,7 @@ func_destfile ()
* ) destfile="$1" ;;
esac
;;
- m4/ ) destfile=`echo "$1" | sed -e "s,^m4/,$m4dir/,"` ;;
+ m4/ ) destfile=`echo "$1" | sed -e "s,^m4\([\\/]\),$m4dir\1,"` ;;
intl/ ) if test -n "$omitintl"; then destfile=""; else destfile="$1"; fi ;;
po/ ) destfile=`echo "$1" | sed -e "s,^po/,,"` allpodirs=yes ;;
* ) destfile="$1" ;;
@@ -709,7 +709,7 @@ if test -z "$force"; then
mismatch=
func_tmpdir
mismatchfile="$tmp"/autopoint.diff
- for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do
+ for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir[\\/]archive[\\/],," | LC_ALL=C sort`; do
func_destfile "$file"
if test -n "$destfile"; then
func_compare_to_destfile ()
@@ -722,7 +722,7 @@ if test -z "$force"; then
else
echo "autopoint: File $finaldestfile has been locally modified." 1>&2
mismatch=yes
- diff -c "$work_dir/archive/$file" "$finaldestfile" | sed -e "1s,$work_dir/archive/,," >> "$mismatchfile"
+ diff -c "$work_dir/archive/$file" "$finaldestfile" | sed -e "1s,$work_dir[\\/]archive[\\/],," >> "$mismatchfile"
fi
fi
fi
@@ -748,11 +748,11 @@ fi
# 'to' is a relative pathname, relative to the current directory.
func_mkdir_for ()
{
- base=`echo "$1" | sed -e 's,/[^/]*$,,'`
+ base=`echo "$1" | sed -e 's,[\\/][^\\/]*$,,'`
if test "X$base" != "X$1" && test -n "$base"; then
func_mkdir_for "$base"
# Recompute base. It was clobbered by the recursive call.
- base=`echo "$1" | sed -e 's,/[^/]*$,,'`
+ base=`echo "$1" | sed -e 's,[\\/][^\\/]*$,,'`
test -d "$base" || { echo "Creating directory $base"; mkdir "$base"; }
fi
}
@@ -787,7 +787,7 @@ func_backup ()
}
# Now copy the files.
-for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do
+for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir[\\/]archive[\\/],," | LC_ALL=C sort`; do
func_destfile "$file"
if test -n "$destfile"; then
func_copy_to_destfile ()
diff --git a/gettext-tools/misc/gettextize.in b/gettext-tools/misc/gettextize.in
index c78c308bf..7d71aec41 100644
--- a/gettext-tools/misc/gettextize.in
+++ b/gettext-tools/misc/gettextize.in
@@ -91,7 +91,7 @@ func_find_curr_installdir ()
*) curr_executable=`pwd`/"$curr_executable" ;;
esac
# Resolve symlinks.
- sed_dirname='s,/[^/]*$,,'
+ sed_dirname='s,[\\/][^\\/]*$,,'
sed_linkdest='s,^.* -> \(.*\),\1,p'
while : ; do
lsline=`LC_ALL=C ls -l "$curr_executable"`
@@ -105,7 +105,7 @@ func_find_curr_installdir ()
*) break ;;
esac
done
- curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'`
+ curr_installdir=`echo "$curr_executable" | sed -e 's,[\\/][^\\/]*$,,'`
# Canonicalize.
curr_installdir=`cd "$curr_installdir" && pwd`
}
@@ -116,16 +116,16 @@ func_find_prefixes ()
orig_installprefix="$orig_installdir"
curr_installprefix="$curr_installdir"
while true; do
- orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
- curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
+ orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*[\\/]\([^\\/]*\)$,\1,p'`
+ curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*]\\/]\([^\\/]*\)$,\1,p'`
if test -z "$orig_last" || test -z "$curr_last"; then
break
fi
if test "$orig_last" != "$curr_last"; then
break
fi
- orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'`
- curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'`
+ orig_installprefix=`echo "$orig_installprefix" | sed -e 's,[\\/][^\\/]*$,,'`
+ curr_installprefix=`echo "$curr_installprefix" | sed -e 's,[\\/][^\\/]*$,,'`
done
}
if test "@RELOCATABLE@" = yes; then
@@ -135,7 +135,7 @@ if test "@RELOCATABLE@" = yes; then
func_find_curr_installdir # determine curr_installdir
func_find_prefixes
# Relocate the directory variables that we use.
- gettext_datadir=`echo "$gettext_datadir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'`
+ gettext_datadir=`echo "$gettext_datadir/" | sed -e "s%^${orig_installprefix}\([\\/]\)%${curr_installprefix}\1%" | sed -e 's,[\\/]$,,'`
fi
# func_trace_autoconf macro configure.ac
diff --git a/libtextstyle/configure.ac b/libtextstyle/configure.ac
index 63b4c2a1e..02c7ec947 100644
--- a/libtextstyle/configure.ac
+++ b/libtextstyle/configure.ac
@@ -16,7 +16,7 @@ dnl along with this program. If not, see <https://www.gnu.org/licenses/>.
dnl Process this file with autoconf to produce a configure script.
-AC_PREREQ([2.63])
+AC_PREREQ([2.64])
AC_INIT
AC_CONFIG_SRCDIR([version.sh])
AC_CONFIG_AUX_DIR([build-aux])
--
2.25.1
--- a/gettext-tools/gnulib-lib/libxml/parser.c 2020-08-24 17:51:07.453829053 +0000
+++ b/gettext-tools/gnulib-lib/libxml/parser.c 2020-08-25 16:40:23.462233330 +0000
@@ -78,6 +78,9 @@
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
#include <libxml/xmlmemory.h>
#include <libxml/threads.h>
#include <libxml/globals.h>
@@ -97,9 +100,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
--- a/gettext-tools/gnulib-lib/libxml/threads.c 2020-08-24 17:51:07.461829107 +0000
+++ b/gettext-tools/gnulib-lib/libxml/threads.c 2020-08-25 16:41:06.630569928 +0000
@@ -41,15 +41,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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment