and allow overriding it manually.
Based on a patch from Svyatoslav Mishyn <juef at openmailbox dot org>
tweaked by me.
The idea originally came up in a conversation with Markus Waldeck.
************************************************************************
* Official mandoc TODO.
-* $Id: TODO,v 1.219 2016/07/19 21:31:55 schwarze Exp $
+* $Id: TODO,v 1.220 2016/07/31 09:29:13 schwarze Exp $
************************************************************************
Many issues are annotated for difficulty as follows:
in dig(1).
loc ** exist ** algo ** size * imp **
-************************************************************************
-* portability
-************************************************************************
-
-- systems having UTF-8 but not en_US.UTF-8
- call locale(1) from ./configure, select a UTF-8-locale,
- and use that for test-wchar.c and term_ascii.c
- to Markus Waldeck Sat, 18 Jul 2015 01:55:37 +0200
- loc * exist * algo * size * imp *
-
************************************************************************
* warning issues
************************************************************************
#!/bin/sh
#
-# $Id: configure,v 1.47 2016/07/20 14:03:06 schwarze Exp $
+# $Id: configure,v 1.48 2016/07/31 09:29:13 schwarze Exp $
#
# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
MANPATH_DEFAULT="/usr/share/man:/usr/X11R6/man:/usr/local/man"
OSNAME=
+UTF8_LOCALE=
CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | env -i make -f -`
CFLAGS="-g -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings"
return 1
}
+# Select a UTF-8 locale.
+get_locale() {
+ [ -n "${HAVE_WCHAR}" ] && [ "${HAVE_WCHAR}" -eq 0 ] && return 0
+ ismanual UTF8_LOCALE "$UTF8_LOCALE" && return 0
+ echo "UTF8_LOCALE: testing..." 1>&3
+ UTF8_LOCALE=`locale -a | grep -i '^en_US\.UTF-*8$' | head -n 1`
+ if [ -z "${UTF8_LOCALE}" ]; then
+ UTF8_LOCALE=`locale -a | grep -i '\.UTF-*8' | head -n 1`
+ [ -n "${UTF8_LOCALE}" ] || return 1
+ fi
+ echo "UTF8_LOCALE=${UTF8_LOCALE}" 1>&2
+ echo "UTF8_LOCALE=${UTF8_LOCALE}" 1>&3
+ echo 1>&3
+ return 0;
+}
+
+
# --- library functions ---
runtest dirent-namlen DIRENT_NAMLEN || true
runtest EFTYPE EFTYPE || true
runtest strsep STRSEP || true
runtest strtonum STRTONUM || true
runtest vasprintf VASPRINTF || true
-runtest wchar WCHAR || true
+
+# --- wide character and locale support ---
+if get_locale; then
+ runtest wchar WCHAR -DUTF8_LOCALE=\"${UTF8_LOCALE}\" || true
+else
+ HAVE_WCHAR=0
+ echo "wchar: no (no UTF8_LOCALE)" 1>&2
+ echo "wchar: no (no UTF8_LOCALE)" 1>&3
+fi
# --- nanosleep ---
if [ -n "${LD_NANOSLEEP}" ]; then
echo "#define MAN_CONF_FILE \"/etc/${MANM_MANCONF}\""
echo "#define MANPATH_DEFAULT \"${MANPATH_DEFAULT}\""
[ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\""
+[ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\""
[ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
[ ${HAVE_EFTYPE} -eq 0 ] && echo "#define EFTYPE EINVAL"
-# $Id: configure.local.example,v 1.17 2016/07/20 14:03:06 schwarze Exp $
+# $Id: configure.local.example,v 1.18 2016/07/31 09:29:13 schwarze Exp $
#
# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
HAVE_WCHAR=0
+# For -Tutf8 mode, mandoc needs to set an arbitrary locale having
+# a UTF-8 character set. If autodetection of a suitable locale
+# fails or selects an undesirable locale, you can manually choose
+# the locale for -Tutf8 mode:
+
+UTF8_LOCALE=en_US.UTF-8
+
# When man(1) or apropos(1) is called without -m and -M options,
# MANPATH is not set in the environment, and man.conf(5) is not
# available, manuals are searched for in the following directory
-/* $Id: term_ascii.c,v 1.53 2016/07/08 22:29:05 schwarze Exp $ */
+/* $Id: term_ascii.c,v 1.54 2016/07/31 09:29:13 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
v = TERMENC_LOCALE == enc ?
setlocale(LC_CTYPE, "") :
- setlocale(LC_CTYPE, "en_US.UTF-8");
+ setlocale(LC_CTYPE, UTF8_LOCALE);
if (NULL != v && MB_CUR_MAX > 1) {
p->enc = enc;
p->advance = locale_advance;
-/* $Id: test-wchar.c,v 1.3 2015/10/06 18:32:20 schwarze Exp $ */
+/* $Id: test-wchar.c,v 1.4 2016/07/31 09:29:13 schwarze Exp $ */
/*
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
*
return 1;
}
- if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) {
- fputs("setlocale(LC_CTYPE, \"en_US.UTF-8\") failed\n",
- stderr);
+ if (setlocale(LC_CTYPE, UTF8_LOCALE) == NULL) {
+ fprintf(stderr, "setlocale(LC_CTYPE, \"%s\") failed\n",
+ UTF8_LOCALE);
return 1;
}