[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, feature/gnulib-regex, updated. gawk-4.1.
From: |
Eli Zaretskii |
Subject: |
[gawk-diffs] [SCM] gawk branch, feature/gnulib-regex, updated. gawk-4.1.0-3010-ga9e991e |
Date: |
Sat, 4 Aug 2018 13:15:21 -0400 (EDT) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, feature/gnulib-regex has been updated
via a9e991ea8292ab72e452688577e179e62c0e0b1b (commit)
from a09917ecd6bc47fc6c9b17beda87d9205a985a0e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=a9e991ea8292ab72e452688577e179e62c0e0b1b
commit a9e991ea8292ab72e452688577e179e62c0e0b1b
Author: Eli Zaretskii <address@hidden>
Date: Sat Aug 4 20:14:51 2018 +0300
Emulate nl_langinfo(CODESET) for MinGW.
diff --git a/pc/ChangeLog b/pc/ChangeLog
index e62150a..834aede 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,13 @@
+2018-08-04 Eli Zaretskii <address@hidden>
+
+ * gawkmisc.pc (nl_langinfo) [__MINGW32__]: New function
+ [DYNAMIC]: Include winerror.h, for MinGW runtime 5.1.0.
+
+ * langinfo.h: New file.
+
+ * config.sed:
+ * config.h (HAVE_LANGINFO_CODESET): Define for MinGW.
+
2018-05-12 Eli Zaretskii <address@hidden>
* Makefile.tst (readfile): Fix a typo.
diff --git a/pc/config.h b/pc/config.h
index 62c13f2..64ad9f9 100644
--- a/pc/config.h
+++ b/pc/config.h
@@ -115,7 +115,9 @@
#endif
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
-#undef HAVE_LANGINFO_CODESET
+#ifdef __MINGW32__
+#define HAVE_LANGINFO_CODESET 1
+#endif
/* Define if your <locale.h> file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
diff --git a/pc/config.sed b/pc/config.sed
index 315c9ca..75ad089 100644
--- a/pc/config.sed
+++ b/pc/config.sed
@@ -82,6 +82,10 @@ s/^#undef HAVE_FMOD *$/#define HAVE_FMOD 1/
#ifdef __MINGW32__\
#define HAVE_ISWUPPER 1\
#endif
+/^#undef HAVE_LANGINFO_CODESET *$/c\
+#ifdef __MINGW32__\
+#define HAVE_LANGINFO_CODESET 1\
+#endif
s/^#undef HAVE_LIBM *$/#define HAVE_LIBM 1/
/^#undef HAVE_LIBREADLINE *$/c\
/* #undef HAVE_LIBREADLINE */
diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc
index f3d6d7f..7c4436e 100644
--- a/pc/gawkmisc.pc
+++ b/pc/gawkmisc.pc
@@ -724,6 +724,70 @@ w32_setlocale (int category, const char *value)
return setlocale (category, new_locale);
}
+/* Replacement for the missing nl_langinfo. Only CODESET is currently
+ supported. */
+#include <langinfo.h>
+
+char *
+nl_langinfo (int item)
+{
+ switch (item)
+ {
+ case CODESET:
+ {
+ /* Shamelessly stolen from Gnulib's nl_langinfo.c. */
+ static char buf[2 + 10 + 1];
+ char const *locale = setlocale (LC_CTYPE, NULL);
+ char *codeset = buf;
+ size_t codesetlen;
+ codeset[0] = '\0';
+
+ if (locale && locale[0])
+ {
+ /* If the locale name contains an encoding after the
+ dot, return it. */
+ char *dot = strchr (locale, '.');
+
+ if (dot)
+ {
+ /* Look for the possible @... trailer and remove it,
+ if any. */
+ char *codeset_start = dot + 1;
+ char const *modifier = strchr (codeset_start, '@');
+
+ if (! modifier)
+ codeset = codeset_start;
+ else
+ {
+ codesetlen = modifier - codeset_start;
+ if (codesetlen < sizeof buf)
+ {
+ codeset = memcpy (buf, codeset_start, codesetlen);
+ codeset[codesetlen] = '\0';
+ }
+ }
+ }
+ }
+ /* If setlocale is successful, it returns the number of the
+ codepage, as a string. Otherwise, fall back on Windows
+ API GetACP, which returns the locale's codepage as a
+ number (although this doesn't change according to what
+ the 'setlocale' call specified). Either way, prepend
+ "CP" to make it a valid codeset name. */
+ codesetlen = strlen (codeset);
+ if (0 < codesetlen && codesetlen < sizeof buf - 2)
+ memmove (buf + 2, codeset, codesetlen + 1);
+ else
+ sprintf (buf + 2, "%u", GetACP ());
+ codeset = memcpy (buf, "CP", 2);
+
+ return codeset;
+ }
+ default:
+ return (char *) "";
+ }
+}
+
/*
* On MS-Windows with MinGW, execvp causes the shell and the re-exec'ed
* dgawk to compete for the keyboard input.
@@ -740,6 +804,7 @@ int execvp(const char *file, const char *const *argv)
#ifdef DYNAMIC
+#include <winerror.h>
#include <dlfcn.h>
static DWORD last_err;
diff --git a/pc/langinfo.h b/pc/langinfo.h
new file mode 100644
index 0000000..2d22096
--- /dev/null
+++ b/pc/langinfo.h
@@ -0,0 +1,9 @@
+/* langinfo.h replacement for MS-Windows build. */
+#ifndef LANGINFO_H
+#define LANGINFO_H
+
+#define CODESET 1
+
+extern char *nl_langinfo (int);
+
+#endif
-----------------------------------------------------------------------
Summary of changes:
pc/ChangeLog | 10 +++++++++
pc/config.h | 4 +++-
pc/config.sed | 4 ++++
pc/gawkmisc.pc | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pc/langinfo.h | 9 ++++++++
5 files changed, 91 insertions(+), 1 deletion(-)
create mode 100644 pc/langinfo.h
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, feature/gnulib-regex, updated. gawk-4.1.0-3010-ga9e991e,
Eli Zaretskii <=