From b34c683f3f1df020ead90edaa6fdc3a42eaaa470 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Tue, 2 Mar 2004 21:31:31 +0000
Subject: [PATCH] Tom Bates' nsr-tandem-nsk port, plus a few tweaks of mine

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1677 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog    | 2 ++
 src/nano.c   | 9 +++++++--
 src/nano.h   | 7 +++++++
 src/rcfile.c | 2 +-
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index de12d39b..5f156ff8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,8 @@ CVS code -
 	  Add function init_backup_dir() to handle relative paths
 	  correctly, use get_full_path() to get the canonical pathname,
 	  and use tail() to get the filename if get_full_path() fails.
+	- Port to the Tandem NonStop Kernel (nsr-tandem-nsk). (Tom
+	  Bates; minor tweaks by DLR)
 - files.c:
   add_open_files()
 	- Make the saving of marked status in open_files->file_flags
diff --git a/src/nano.c b/src/nano.c
index 15c1fe5e..cf3858cc 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -19,6 +19,11 @@
  *                                                                        *
  **************************************************************************/
 
+#ifdef __TANDEM
+/* Tandem NonStop Kernel */
+#include <floss.h>
+#endif
+
 #include "config.h"
 
 #include <stdio.h>
@@ -3173,7 +3178,7 @@ int main(int argc, char *argv[])
 #if !defined(ENABLE_NANORC) && defined(DISABLE_ROOTWRAP) && !defined(DISABLE_WRAPPING)
     /* if we don't have rcfile support, we're root, and
        --disable-wrapping-as-root is used, turn wrapping off */
-    if (geteuid() == 0)
+    if (geteuid() == NANO_ROOT_UID)
 	SET(NO_WRAP);
 #endif
 
@@ -3415,7 +3420,7 @@ int main(int argc, char *argv[])
 	flags |= flags_cpy;
     }
 #if defined(DISABLE_ROOTWRAP) && !defined(DISABLE_WRAPPING)
-    else if (geteuid() == 0)
+    else if (geteuid() == NANO_ROOT_UID)
 	SET(NO_WRAP);
 #endif
 #endif /* ENABLE_NANORC */
diff --git a/src/nano.h b/src/nano.h
index 7dd25bef..9e3a1ba0 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -22,6 +22,13 @@
 #ifndef NANO_H
 #define NANO_H 1
 
+#ifdef __TANDEM
+/* Tandem NonStop Kernel */
+#define NANO_ROOT_UID 65535
+#else
+#define NANO_ROOT_UID 0
+#endif
+
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
diff --git a/src/rcfile.c b/src/rcfile.c
index dcfdb8c7..5749c288 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -678,7 +678,7 @@ void do_rcfile(void)
 #if defined(DISABLE_ROOTWRAP) && !defined(DISABLE_WRAPPING)
     /* If we've already read SYSCONFDIR/nanorc (if it's there), we're
        root, and --disable-wrapping-as-root is used, turn wrapping off */
-	if (euid == 0)
+	if (euid == NANO_ROOT_UID)
 	    SET(NO_WRAP);
 #endif
 	if ((rcstream = fopen(nanorc, "r")) == NULL) {
-- 
GitLab