From ba1ab86db5f90d1390f15fddd6a863fc68bd965c Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Sun, 20 Mar 2005 02:50:31 +0000
Subject: [PATCH] check for a UTF-8-supporting version of slang

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2398 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog    |  6 ++---
 configure.ac | 75 ++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 70 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c8323090..c0bedf06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -328,9 +328,9 @@ CVS code -
 	  as Pico does. (DLR)
 - configure.ac:
 	- Remove specific references to control key shortcuts. (DLR)
-	- Check for the wide version of ncurses, without which multibyte
-	  strings don't seem to be displayed properly, and associated
-	  wide character functions. (DLR)
+	- Check for the wide versions of ncurses or slang, without which
+	  multibyte strings don't seem to be displayed properly, and
+	  associated multibyte/wide character functions. (DLR)
 	- Check for wchar.h, for those systems that need it for the
 	  wcwidth() prototype. (DLR)
 	- Remove checks for all include files that we include
diff --git a/configure.ac b/configure.ac
index 8aa6ad4b..eab13e99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,9 +59,7 @@ int main(void)
 	AC_MSG_RESULT(no),
 	AC_MSG_RESULT(yes)
 	AC_DEFINE(BROKEN_REGEXEC, 1, [Define this if your regexec() function segfaults when passed an empty string under certain conditions.]),
-	AC_MSG_RESULT([cross-compiling; assuming no])
-	)
-    )
+	AC_MSG_RESULT([cross-compiling; assuming no])))
 
 dnl options
 AC_ARG_ENABLE(debug, 
@@ -207,12 +205,31 @@ AC_ARG_WITH(slang,
 	fi
 
 	AC_CHECK_HEADER(slcurses.h,
-	    AC_MSG_CHECKING([for SLtt_initialize in -lslang])
+	    AC_MSG_CHECKING([for SLutf8_enable in -lslang])
 	    _libs=$LIBS
 	    LIBS="$LIBS -lslang"
 	    AC_TRY_RUN([
 #include <slcurses.h>
 int main(void)
+{
+    SLutf8_enable(TRUE);
+    return 0;
+}],
+		[AC_MSG_RESULT(yes)
+		AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
+		slang_support=yes
+		CURSES_LIB_WIDE=yes
+		if test "$with_slang" != "yes"; then
+		    CURSES_LIB="-L${with_slang}/lib -lslang"
+		else
+		    CURSES_LIB="-lslang"
+		fi
+		CURSES_LIB_NAME=slang],
+		[AC_MSG_RESULT(no)
+		AC_MSG_CHECKING([for SLtt_initialize in -lslang])
+		AC_TRY_RUN([
+#include <slcurses.h>
+int main(void)
 {
     SLtt_initialize(NULL);
     return 0;
@@ -227,17 +244,37 @@ int main(void)
 		fi
 		CURSES_LIB_NAME=slang],
 		[AC_MSG_RESULT(no)
+
 		# We might need the term library
 		for termlib in ncurses curses termcap terminfo termlib; do
 		    AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
 		    test -n "$tcap" && break
 		done
 
-		AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
+		AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap])
 		LIBS="$LIBS $tcap"
 		AC_TRY_RUN([
 #include <slcurses.h>
 int main(void)
+{
+    SLutf8_enable(TRUE);
+    return 0;
+}],
+		    [AC_MSG_RESULT(yes)
+		    AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
+		    slang_support=yes
+		    CURSES_LIB_WIDE=yes
+		    if test "$with_slang" != "yes"; then
+			CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
+		    else
+			CURSES_LIB="-lslang $tcap"
+		    fi
+		    CURSES_LIB_NAME=slang],
+		    [AC_MSG_RESULT(no)
+		    AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
+		    AC_TRY_RUN([
+#include <slcurses.h>
+int main(void)
 {
     SLtt_initialize(NULL);
     return 0;
@@ -250,14 +287,33 @@ int main(void)
 		    else
 			CURSES_LIB="-lslang $tcap"
 		    fi
-		    CURSES_LIB_NAME=slang], [
-		    AC_MSG_RESULT(no)
+		    CURSES_LIB_NAME=slang],
+		    [AC_MSG_RESULT(no)
+
 		    # We might need the math library
-		    AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
+		    AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap -lm])
 		    LIBS="$LIBS -lm"
 		    AC_TRY_RUN([
 #include <slcurses.h>
 int main(void)
+{
+    SLutf8_enable(TRUE);
+    return 0;
+}],
+			[AC_MSG_RESULT(yes)
+			AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
+			slang_support=yes
+			CURSES_LIB_WIDE=yes
+			if test "$with_slang" != "yes"; then
+			    CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
+			else
+			    CURSES_LIB="-lslang $tcap -lm"
+			fi
+			CURSES_LIB_NAME=slang],
+			AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
+			AC_TRY_RUN([
+#include <slcurses.h>
+int main(void)
 {
     SLtt_initialize(NULL);
     return 0;
@@ -274,6 +330,9 @@ int main(void)
 			[AC_MSG_RESULT(no)],
 AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
 AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
+AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
+AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
+AC_MSG_WARN([*** Can not use slang when cross-compiling])),
 AC_MSG_WARN([*** Can not use slang when cross-compiling])),
 	    AC_MSG_ERROR([
 *** The header file slcurses.h was not found. If you wish to use
-- 
GitLab