From ad5bbeb3c2556445105887861b0878dbcd62cc36 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sun, 25 Mar 2018 10:19:57 +0200 Subject: [PATCH] Make wcwidth configurable (#4816) * Make wcwidth configurable This adds the cmake option "INTERNAL_WCWIDTH" (to be set to "ON" or "OFF") and the configure option --[en,dis]able-internal-wcwidth. Both default to enabling our fallback, but can be set to use the system's wcwidth again. Sequel to #4554. See #4571, #4539, #4609. On my system, this would fix #4306. --- CMakeLists.txt | 7 +++++++ configure.ac | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73d162ffe..a01397a17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,13 @@ SET_SOURCE_FILES_PROPERTIES(src/fish_version.cpp PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FBVF}) +OPTION(INTERNAL_WCWIDTH "use fallback wcwidth" ON) +IF(INTERNAL_WCWIDTH) + add_definitions(-DHAVE_BROKEN_WCWIDTH=1) +ELSE() + add_definitions(-DHAVE_BROKEN_WCWIDTH=0) +ENDIF() + # Set up PCRE2 INCLUDE(cmake/PCRE2.cmake) diff --git a/configure.ac b/configure.ac index c41ee59f8..39e6de148 100644 --- a/configure.ac +++ b/configure.ac @@ -25,6 +25,7 @@ AC_SUBST(HAVE_DOXYGEN) AC_SUBST(LDFLAGS_FISH) AC_SUBST(WCHAR_T_BITS) AC_SUBST(EXTRA_PCRE2) +AC_SUBST(HAVE_BROKEN_WCWIDTH) # # If needed, run autoconf to regenerate the configure file @@ -599,6 +600,20 @@ AC_ARG_WITH( [included_pcre2=auto] ) +HAVE_BROKEN_WCWIDTH= +AC_ARG_ENABLE( + [wcwidth], + AS_HELP_STRING( + [--disable-internal-wcwidth], + [use system wcwidth instead of the bundled version] + )) + +if test "x$enable_wcwidth" != "xno"; then + AC_DEFINE([HAVE_BROKEN_WCWIDTH], [1], [banana]) +else + AC_DEFINE([HAVE_BROKEN_WCWIDTH], [0], [banana]) +fi + if test "x$included_pcre2" != "xyes"; then # test for pcre2-config