From 6f70b64dd68c4ebeae674b8c1b190e1ea3fd951c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Fri, 24 Mar 2017 18:46:52 +0100
Subject: [PATCH] Updated Haiku patchset

---
 configure           | 14 +++++++-------
 modules/Makefile.in |  2 +-
 slsh/Makefile.in    |  2 +-
 slsh/slsh.c         | 20 ++++++++++++++++++--
 src/Makefile.in     |  2 +-
 src/slstd.c         |  3 +++
 6 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/configure b/configure
index a37a389..a9bf4f0 100755
--- a/configure
+++ b/configure
@@ -6927,8 +6927,8 @@ _ACEOF



-# Extract the first word of "ncurses5-config", so it can be a program name with args.
-set dummy ncurses5-config; ac_word=$2
+# Extract the first word of "ncurses6-config", so it can be a program name with args.
+set dummy ncurses6-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if ${ac_cv_path_nc5config+:} false; then :
@@ -7014,9 +7014,9 @@ fi
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for terminfo" >&5
 $as_echo_n "checking for terminfo... " >&6; }
-if test "$nc5config" != "no"
+if test "$nc6config" != "no"
 then
-   MISC_TERMINFO_DIRS=`$nc5config --terminfo`
+   MISC_TERMINFO_DIRS=`$nc6config --terminfo`
 else
    MISC_TERMINFO_DIRS=""
 fi
@@ -7025,20 +7025,20 @@ JD_Terminfo_Dirs="$MISC_TERMINFO_DIRS \
                   /usr/share/terminfo \
                   /usr/share/lib/terminfo \
 		  /usr/local/lib/terminfo"
-TERMCAP=-ltermcap
+TERMCAP=-lncurses

 for terminfo_dir in $JD_Terminfo_Dirs
 do
    if test -d $terminfo_dir
    then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&6
 $as_echo "yes" >&6; }
       TERMCAP=""
       break
    fi
 done
 if test "$TERMCAP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&6
 $as_echo "no" >&6; }

 $as_echo "#define USE_TERMCAP 1" >>confdefs.h
diff --git a/modules/Makefile.in b/modules/Makefile.in
index e30d1d0..59ef54a 100644
--- a/modules/Makefile.in
+++ b/modules/Makefile.in
@@ -73,7 +73,7 @@ INSTALL		= @INSTALL@
 INSTALL_DATA	= @INSTALL_DATA@
 INSTALL_MODULE	= @INSTALL_MODULE@
 MKINSDIR	= $(CONFIG_DIR)/autoconf/mkinsdir.sh
-SLSH_DIR	= $(prefix)/share/slsh
+SLSH_DIR	= @datarootdir@/slsh
 CMAPS_DIR	= $(SLSH_DIR)/cmaps
 HELP_DIR	= $(SLSH_DIR)/help
 # ---------------------------------------------------------------------------
diff --git a/slsh/Makefile.in b/slsh/Makefile.in
index cba9d81..82982df 100644
--- a/slsh/Makefile.in
+++ b/slsh/Makefile.in
@@ -34,7 +34,7 @@ MKINSDIR	= $(CONFIG_DIR)/autoconf/mkinsdir.sh
 SLSH_CONF_DIR	= @sysconfdir@
 SLSH_LIB_DIR	= $(datarootdir)/slsh
 SLSH_HELP_DIR	= $(SLSH_LIB_DIR)/help
-SLSH_DOC_DIR	= $(datarootdir)/doc/slsh
+SLSH_DOC_DIR	= @docdir@/slsh
 SLSH_LOCALLIB_DIR = $(SLSH_LIB_DIR)/local-packages
 SLSH_SCRIPT_DIR	= $(SLSH_LIB_DIR)/scripts
 SCRIPTS		= jpegsize lsrpm sldb svnsh slprof slstkchk
diff --git a/slsh/slsh.c b/slsh/slsh.c
index b51d85b..ebdf647 100644
--- a/slsh/slsh.c
+++ b/slsh/slsh.c
@@ -26,6 +26,10 @@ USA.
 # include <windows.h>
 # include <io.h>
 #endif
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#include <fs_info.h>
+#endif

 #include <sys/stat.h>

@@ -56,7 +60,11 @@ static SLFUTURE_CONST char *Slsh_Version = "0.9.4-0";
 # define SLSH_LIB_DIR_ENV "SLSH_LIB_DIR"
 #endif

-#if defined(REAL_UNIX_SYSTEM) || defined(__APPLE__)
+#if defined(__HAIKU__)
+/* # define DEFAULT_LIBRARY_PATH "/usr/local/share/slsh:/usr/local/lib/slsh:/usr/share/slsh:/usr/lib/slsh"; */
+# define DEFAULT_CONF_PATH "/boot/system/settings:/boot/home/config/settings";
+# define USER_SLSHRC "slsh.rc"
+#elif defined(REAL_UNIX_SYSTEM) || defined(__APPLE__)
 /* # define DEFAULT_LIBRARY_PATH "/usr/local/share/slsh:/usr/local/lib/slsh:/usr/share/slsh:/usr/lib/slsh"; */
 /* # define DEFAULT_CONF_PATH "/usr/local/etc:/usr/local/etc/slsh:/etc:/etc/slsh"; */
 # define DEFAULT_CONF_PATH NULL
@@ -536,6 +544,9 @@ int main (int argc, char **argv)
    int test_mode = 0;
    char *exec_string = NULL;
    int quiet = 0;
+#if defined(__HAIKU__)
+   char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+#endif

 #ifdef SLSYSWRAP
    (void) SLsyswrap_set_syscall_failure (0);
@@ -565,8 +576,13 @@ int main (int argc, char **argv)
 #endif

    /* FIXME for other systems */
-#ifdef __WIN32__
+#if defined(__WIN32__)
    init_file_dir = getenv ("USERPROFILE");
+#elif defined(__HAIKU__)
+   if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, buffer, sizeof(buffer)) != B_OK)
+     sprintf(buffer, "/boot/home/config/settings");
+
+   init_file_dir = &buffer;
 #else
    init_file_dir = getenv ("HOME");
 #endif
diff --git a/src/Makefile.in b/src/Makefile.in
index 7fe4dc2..6c0e2d6 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -47,7 +47,7 @@ exec_prefix = @exec_prefix@
 install_lib_dir = @libdir@
 install_bin_dir = @bindir@
 install_include_dir = @includedir@
-install_doc_dir = $(prefix)/share/doc/slang/v@slang_major_version@
+install_doc_dir = @docdir@/slang/v@slang_major_version@
 DOC_FILES = ../changes.txt ../COPY* ../doc/slangdoc.html ../doc/text/*.txt
 MODULE_INSTALL_DIR = @libdir@/slang/v@slang_major_version@/modules
 #---------------------------------------------------------------------------
diff --git a/src/slstd.c b/src/slstd.c
index e4dda06..c5a8cf1 100644
--- a/src/slstd.c
+++ b/src/slstd.c
@@ -1340,6 +1340,9 @@ int SLang_init_slang (void) /*{{{*/
 #ifdef REAL_UNIX_SYSTEM
 	"UNIX",
 #endif
+#if defined(__HAIKU__)
+	"HAIKU",
+#endif
 #if SLANG_HAS_FLOAT
 	"SLANG_DOUBLE_TYPE",
 #endif
--
2.11.0
