Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/mdocml Re-enable wchar_t support. mandoc(1) ca...



details:   https://anonhg.NetBSD.org/src/rev/b9fa1e6b5cf2
branches:  trunk
changeset: 322018:b9fa1e6b5cf2
user:      nakayama <nakayama%NetBSD.org@localhost>
date:      Fri Apr 13 21:52:48 2018 +0000

description:
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@.

diffstat:

 external/bsd/mdocml/dist/term_ascii.c |  14 +++++++++++++-
 external/bsd/mdocml/include/config.h  |   2 +-
 2 files changed, 14 insertions(+), 2 deletions(-)

diffs (48 lines):

diff -r 22da412cd010 -r b9fa1e6b5cf2 external/bsd/mdocml/dist/term_ascii.c
--- a/external/bsd/mdocml/dist/term_ascii.c     Fri Apr 13 20:30:09 2018 +0000
+++ b/external/bsd/mdocml/dist/term_ascii.c     Fri Apr 13 21:52:48 2018 +0000
@@ -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 @@
                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;
diff -r 22da412cd010 -r b9fa1e6b5cf2 external/bsd/mdocml/include/config.h
--- a/external/bsd/mdocml/include/config.h      Fri Apr 13 20:30:09 2018 +0000
+++ b/external/bsd/mdocml/include/config.h      Fri Apr 13 21:52:48 2018 +0000
@@ -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"



Home | Main Index | Thread Index | Old Index