From 44b03451934776b1030c9d5109114e98520bb4c2 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 13 Apr 2018 18:31:00 +0000 Subject: 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 via wiz@. --- term_ascii.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'term_ascii.c') diff --git a/term_ascii.c b/term_ascii.c index 265baf5d..43905634 100644 --- a/term_ascii.c +++ b/term_ascii.c @@ -1,7 +1,7 @@ -/* $Id: term_ascii.c,v 1.59 2017/08/23 10:50:15 schwarze Exp $ */ +/* $Id: term_ascii.c,v 1.60 2018/04/13 18:31:00 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2014, 2015, 2017 Ingo Schwarze + * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -21,11 +21,13 @@ #include #if HAVE_WCHAR +#include #include #endif #include #include #include +#include #include #if HAVE_WCHAR #include @@ -100,7 +102,17 @@ ascii_init(enum termenc enc, const struct manoutput *outopts) 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; -- cgit v1.2.3-56-ge451