Module Name: src
Committed By: nakayama
Date: Fri Apr 13 21:52:49 UTC 2018
Modified Files:
src/external/bsd/mdocml/dist: term_ascii.c
src/external/bsd/mdocml/include: config.h
Log Message:
Re-enable wchar_t support. mandoc(1) can now fall back to ascii
output if the locale is non-UTF-8 locale with the following change.
https://marc.info/?l=openbsd-cvs&m=152364416720474
| Modified files:
| usr.bin/mandoc : term_ascii.c
|
| Log message:
| Make sure that mandoc only goes into UTF-8 mode if the user really
| selected UTF-8, not some other multibyte locale. This obviously
| makes no difference on OpenBSD but improves portability.
| Issue reported by <Nakayama at NetBSD> via wiz@.
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.11 -r1.2 src/external/bsd/mdocml/dist/term_ascii.c
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/mdocml/include/config.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/mdocml/dist/term_ascii.c
diff -u src/external/bsd/mdocml/dist/term_ascii.c:1.1.1.11 src/external/bsd/mdocml/dist/term_ascii.c:1.2
--- src/external/bsd/mdocml/dist/term_ascii.c:1.1.1.11 Sat Mar 18 15:06:54 2017
+++ src/external/bsd/mdocml/dist/term_ascii.c Fri Apr 13 21:52:49 2018
@@ -21,11 +21,13 @@
#include <assert.h>
#if HAVE_WCHAR
+#include <langinfo.h>
#include <locale.h>
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#if HAVE_WCHAR
#include <wchar.h>
@@ -99,7 +101,17 @@ ascii_init(enum termenc enc, const struc
v = TERMENC_LOCALE == enc ?
setlocale(LC_CTYPE, "") :
setlocale(LC_CTYPE, UTF8_LOCALE);
- if (NULL != v && MB_CUR_MAX > 1) {
+
+ /*
+ * We only support UTF-8,
+ * so revert to ASCII for anything else.
+ */
+
+ if (v != NULL &&
+ strcmp(nl_langinfo(CODESET), "UTF-8") != 0)
+ v = setlocale(LC_CTYPE, "C");
+
+ if (v != NULL && MB_CUR_MAX > 1) {
p->enc = enc;
p->advance = locale_advance;
p->endline = locale_endline;
Index: src/external/bsd/mdocml/include/config.h
diff -u src/external/bsd/mdocml/include/config.h:1.4 src/external/bsd/mdocml/include/config.h:1.5
--- src/external/bsd/mdocml/include/config.h:1.4 Sat Mar 17 11:06:48 2018
+++ src/external/bsd/mdocml/include/config.h Fri Apr 13 21:52:48 2018
@@ -41,7 +41,7 @@
#define HAVE_STRTONUM 0
#define HAVE_SYS_ENDIAN 1
#define HAVE_VASPRINTF 1
-#define HAVE_WCHAR 0
+#define HAVE_WCHAR 1
#define HAVE_OHASH 0
#define BINM_APROPOS "apropos"