$NetBSD: patch-au,v 1.7 2015/11/07 22:07:15 dholland Exp $

- use standard headers
- avoid implicit int
- build if NAME_MAX is missing (old Solaris?)
- build if access() and F_OK/R_OK/etc. are missing (OpenBSD)

--- icb/tcl.c.orig	1995-02-24 21:20:30.000000000 +0000
+++ icb/tcl.c
@@ -3,13 +3,14 @@
 
 /* TCL interface */
 
-#ifdef linux
+#include <limits.h>
+#if defined(linux) || defined(__sun)
 #include <unistd.h>
 #endif
 
 #include "icb.h"
 #include "externs.h"
-#include <sys/dir.h>
+#include <dirent.h>
 #include <sys/file.h>
 
 Tcl_Interp *interp;
@@ -92,10 +93,14 @@ tclinit()
 
 }
 
-tclreadicbrc()
+void tclreadicbrc(void)
 {
 	char *p, *path;
+#ifdef NAME_MAX
+	char cmd[NAME_MAX + 10];
+#else
 	char cmd[MAXNAMLEN+10];
+#endif
 	
 	if (!(path = getrcname())) return;
 
@@ -117,7 +122,11 @@ getrcname()
 {
 	static char *names[] = { ".icbrc", ".fnrc", ".tclrc" , (char *)NULL };
 	char *rcfile, *homedir, *getenv(), **p;
+#ifdef NAME_MAX
+	static char rcpath[NAME_MAX + 1];
+#else
 	static char rcpath[MAXNAMLEN+1];	/* path of startup file */
+#endif
 
 	/* get name of file to use */
 	if (((rcfile = getenv("ICBRC")) != NULL)
@@ -135,10 +144,12 @@ getrcname()
 		}
 
 		/* make sure the file is there */
+#if defined(F_OK) && defined(R_OK)
 		if (access(rcfile, (F_OK | R_OK)) < 0) {
 			printf("icb: can't read rc file \"%s\".\r\n", rcfile);
 			return(NULL);
 		}
+#endif
 
 		return rcfile;
 	} 
