From 705c5d4aa39bf8f71eb155730858c480bef9c268 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sat, 27 Oct 2018 12:51:57 +0200
Subject: Haiku supporting patches


diff --git a/src/Makefile.am b/src/Makefile.am
index 7640d21..328353c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,6 +35,6 @@ hstr_SOURCES = 						\
 
 # create hstr > hh hard link on installation
 install-exec-hook:
-	ln $(DESTDIR)$(bindir)/hstr$(EXEEXT) $(DESTDIR)$(bindir)/hh$(EXEEXT)
+	ln -s $(DESTDIR)$(bindir)/hstr$(EXEEXT) $(DESTDIR)$(bindir)/hh$(EXEEXT)
 
 hstr_LDADD = $(NCURSES_LIBS)
diff --git a/src/hstr_history.c b/src/hstr_history.c
index c4353ca..e2f8891 100644
--- a/src/hstr_history.c
+++ b/src/hstr_history.c
@@ -51,7 +51,11 @@ char* get_history_file_name(void)
     if(!historyFile || strlen(historyFile)==0) {
         char* home = getenv(ENV_VAR_HOME);
         historyFile = malloc(strlen(home) + 1 + strlen(FILE_DEFAULT_HISTORY) + 1);
-        strcat(strcat(strcpy(historyFile, home), "/"), FILE_DEFAULT_HISTORY);
+        #ifndef __HAIKU__
+            strcat(strcat(strcpy(historyFile, home), "/"), FILE_DEFAULT_HISTORY);
+        #else
+            strcat(strcat(strcpy(historyFile, home), "/config/settings/"), FILE_DEFAULT_HISTORY);
+        #endif
     } else {
         // allocate so that this function always returns string to be freed
         // (getenv() returns pointer (no need to free), home is allocated (must be freed)
diff --git a/src/hstr_utils.c b/src/hstr_utils.c
index 2c0742c..ab48a05 100644
--- a/src/hstr_utils.c
+++ b/src/hstr_utils.c
@@ -106,7 +106,7 @@ void hstr_chop(char *s)
     }
 }
 
-#if !defined(__MS_WSL__) && !defined(__CYGWIN__) && !defined(DEBUG_NO_TIOCSTI)
+#if !defined(__MS_WSL__) && !defined(__CYGWIN__) && !defined(DEBUG_NO_TIOCSTI) && !defined(__HAIKU__)
 void tiocsti()
 {
     char buf[] = DEFAULT_COMMAND;
@@ -120,7 +120,7 @@ void tiocsti()
 void fill_terminal_input(char* cmd, bool padding)
 {
     if(cmd && strlen(cmd)>0) {
-#if defined(__MS_WSL__) || defined(__CYGWIN__) || defined(DEBUG_NO_TIOCSTI)
+#if defined(__MS_WSL__) || defined(__CYGWIN__) || defined(DEBUG_NO_TIOCSTI) || defined(__HAIKU__)
         fprintf(stderr, "%s", cmd);
         if(padding) fprintf(stderr, "%s", "\n");
 #else
diff --git a/src/include/hstr.h b/src/include/hstr.h
index 6376b47..3ea4443 100644
--- a/src/include/hstr.h
+++ b/src/include/hstr.h
@@ -25,6 +25,8 @@
   #include <curses.h>
 #elif defined(__FreeBSD__)
   #include <ncurses.h>
+#elif defined(__HAIKU__)
+  #include <ncurses.h>
 #else
   #include <ncursesw/curses.h>
 #endif
diff --git a/src/include/hstr_curses.h b/src/include/hstr_curses.h
index 045673e..ef3ef46 100644
--- a/src/include/hstr_curses.h
+++ b/src/include/hstr_curses.h
@@ -21,6 +21,8 @@
 
 #ifdef __APPLE__
 #include <curses.h>
+#elif defined(__HAIKU__)
+#include <ncurses.h>
 #elif defined(__FreeBSD__)
 #include <ncurses.h>
 #else
-- 
2.19.1


From 1393e5f2234634e8430072684cce36be83fd4fca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sat, 27 Oct 2018 12:54:48 +0200
Subject: No dotfiles on Haiku


diff --git a/src/include/hstr_history.h b/src/include/hstr_history.h
index 80ca7d1..bf65cdc 100644
--- a/src/include/hstr_history.h
+++ b/src/include/hstr_history.h
@@ -31,8 +31,13 @@
 
 #define ENV_VAR_HISTFILE "HISTFILE"
 
-#define FILE_DEFAULT_HISTORY ".bash_history"
-#define FILE_ZSH_HISTORY ".zsh_history"
+#ifndef __HAIKU__
+    #define FILE_DEFAULT_HISTORY ".bash_history"
+    #define FILE_ZSH_HISTORY ".zsh_history"
+#else
+    #define FILE_DEFAULT_HISTORY "bash_history"
+    #define FILE_ZSH_HISTORY "zsh_history"
+#endif
 
 #define ZSH_HISTORY_ITEM_OFFSET 15
 #define BASH_HISTORY_ITEM_OFFSET 0
-- 
2.19.1

