Module Name:    src
Committed By:   martin
Date:           Sat Apr 14 10:50:49 UTC 2018

Modified Files:
        src/external/bsd/mdocml/dist [netbsd-8]: term_ascii.c
        src/external/bsd/mdocml/include [netbsd-8]: config.h

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #755):

        external/bsd/mdocml/include/config.h: revision 1.5
        external/bsd/mdocml/dist/term_ascii.c: revision 1.2

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.1.1.11.4.1 \
    src/external/bsd/mdocml/dist/term_ascii.c
cvs rdiff -u -r1.3.4.1 -r1.3.4.2 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.1.1.11.4.1
--- 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	Sat Apr 14 10:50: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.3.4.1 src/external/bsd/mdocml/include/config.h:1.3.4.2
--- src/external/bsd/mdocml/include/config.h:1.3.4.1	Sun Mar 18 11:01:00 2018
+++ src/external/bsd/mdocml/include/config.h	Sat Apr 14 10:50:49 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"

Reply via email to