aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-07-31 09:47:01 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-07-31 09:47:01 +0000
commit3214279b89580e66e19f6f2b2f0eef85e22c1165 (patch)
tree1dc4b914a58cf8a880794496be61d8000ccf9a7c
parentc70a30223b2d39c4638430476119eb1e1a38a407 (diff)
downloadmandoc-3214279b89580e66e19f6f2b2f0eef85e22c1165.tar.gz
mandoc-3214279b89580e66e19f6f2b2f0eef85e22c1165.tar.zst
mandoc-3214279b89580e66e19f6f2b2f0eef85e22c1165.zip
1.13 backport: autodetect UTF8_LOCALE
-rwxr-xr-xconfigure31
-rw-r--r--configure.local.example9
2 files changed, 37 insertions, 3 deletions
diff --git a/configure b/configure
index 6716352d..f77bcc8d 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Id: configure,v 1.43.2.1 2016/07/20 14:14:07 schwarze Exp $
+# $Id: configure,v 1.43.2.2 2016/07/31 09:47:01 schwarze Exp $
#
# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -35,6 +35,7 @@ echo "config.log: writing..."
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"
@@ -182,6 +183,23 @@ runtest() {
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 err ERR || true
@@ -205,7 +223,15 @@ runtest strptime STRPTIME || 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
# --- sqlite3 ---
if [ ${BUILD_DB} -eq 0 ]; then
@@ -323,6 +349,7 @@ echo
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}\""
cat << __HEREDOC__
diff --git a/configure.local.example b/configure.local.example
index 1ecffff0..9ae2e3cf 100644
--- a/configure.local.example
+++ b/configure.local.example
@@ -1,4 +1,4 @@
-# $Id: configure.local.example,v 1.14.2.1 2016/07/20 14:14:07 schwarze Exp $
+# $Id: configure.local.example,v 1.14.2.2 2016/07/31 09:47:01 schwarze Exp $
#
# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -48,6 +48,13 @@ HAVE_WCHAR=1
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, man.conf(5) is not available
# and manpath(1) not used, manuals are searched for in the following