oksh-noxz

[fork] Portable OpenBSD ksh, based on the Public Domain Korn Shell (pdksh).
git clone https://noxz.tech/git/oksh-noxz.git
oksh-noxz

commit: 9afc5a757e832dea472fd12ddc31ecccf1522e17
parent: caf98eb42ccf9a600c15ff4043b69f640fce6854
author: Brian Callahan <bcallah@openbsd.org>
date:   Fri, 1 May 2020 15:47:37 +0000
Add Haiku support.
Fixes #42
Medit.c6+++++
Mportable.h27++++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/edit.c b/edit.c
@@ -173,13 +173,19 @@ x_mode(bool onoff)
 		edchars.intr = cb.c_cc[VINTR];
 		edchars.quit = cb.c_cc[VQUIT];
 		edchars.eof = cb.c_cc[VEOF];
+#ifdef VWERASE
 		edchars.werase = cb.c_cc[VWERASE];
+#endif
 		cb.c_iflag &= ~(INLCR|ICRNL);
 		cb.c_lflag &= ~(ISIG|ICANON|ECHO);
+#ifdef VLNEXT
 		/* osf/1 processes lnext when ~icanon */
 		cb.c_cc[VLNEXT] = _POSIX_VDISABLE;
+#endif
+#ifdef VDISCARD
 		/* sunos 4.1.x & osf/1 processes discard(flush) when ~icanon */
 		cb.c_cc[VDISCARD] = _POSIX_VDISABLE;
+#endif
 		cb.c_cc[VTIME] = 0;
 		cb.c_cc[VMIN] = 1;
 
diff --git a/portable.h b/portable.h
@@ -30,6 +30,10 @@
 #include <sys/file.h>
 #endif /* _AIX || __sun */
 
+#if defined(__HAIKU__)
+#include <stdint.h>
+#endif
+
 #include <time.h>
 
 #include "pconfig.h"
@@ -46,8 +50,12 @@
 #define O_EXLOCK	0
 #endif /* !O_EXLOCK */
 
+#ifndef _PATH_BSHELL
+#define _PATH_BSHELL	"/bin/sh"
+#endif /* !_PATH_BSHELL */
+
 #ifndef _PW_NAME_LEN
-#if defined(__linux__) || defined(__CYGWIN__) || defined(_AIX) || defined(__midipix__)
+#if defined(__linux__) || defined(__CYGWIN__) || defined(_AIX) || defined(__midipix__) || defined(__HAIKU__)
 #define _PW_NAME_LEN	LOGIN_NAME_MAX
 #elif defined(__NetBSD__)
 #define _PW_NAME_LEN	MAXLOGNAME
@@ -55,9 +63,17 @@
 #define _PW_NAME_LEN	LOGNAME_MAX
 #else
 #define _PW_NAME_LEN	MAXLOGNAME - 1
-#endif /* __linux__ || __CYGWIN__ || _AIX || __NetBSD__ || __sun || __midipix__ */
+#endif /* __linux__ || __CYGWIN__ || _AIX || __NetBSD__ || __sun || __midipix__ || __HAIKU__ */
 #endif /* !_PW_NAME_LEN */
 
+#ifndef LOCK_EX
+#define LOCK_EX	0x02
+#endif /* !LOCK_EX */
+
+#ifndef LOCK_UN
+#define LOCK_UN	0x08
+#endif /* !LOCK_UN */
+
 #ifndef RLIMIT_RSS
 #define	RLIMIT_RSS	5		/* resident set size */
 #endif /* !RLIMIT_RSS */
@@ -91,6 +107,13 @@
 #undef BAD
 #endif /* _AIX */
 
+#ifdef __HAIKU__
+#define _PATH_DEFPATH ".:/boot/home/config/non-packaged/bin:/boot/home/config/bin:/boot/system/non-packaged/bin:/bin:/boot/system/apps:/boot/system/preferences"
+#define WCOREFLAG 0200
+#define WCOREDUMP(x) ((x) & WCOREFLAG)
+#define nice(x) (int)0
+#endif /* __HAIKU__ */
+
 #ifndef HAVE_SETRESGID
 #define setresgid(x, y, z)	setgid(x); setegid(y); setgid(z)
 #endif /* !HAVE_SETRESGID */