--- a/main.c
+++ b/main.c
@@ -13,6 +13,9 @@
 #include "config.h"
 #include <signal.h>
 #include <setjmp.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
 #include "vi.h"
 
 extern		trapint(); /* defined below */
@@ -25,7 +28,7 @@ static init_digraphs();
 
 /*---------------------------------------------------------------------*/
 
-void main(argc, argv)
+int main(argc, argv)
 	int	argc;
 	char	*argv[];
 {
@@ -349,7 +352,7 @@ void main(argc, argv)
 	refresh();
 	endwin();
 
-	exit(0);
+	return(0);
 	/*NOTREACHED*/
 }
 
--- a/tio.c
+++ b/tio.c
@@ -15,6 +15,9 @@
 # include <setjmp.h>
 #endif
 #include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include "vi.h"
 
 
@@ -354,7 +357,7 @@ static int dummy()
 	return 0;
 }
 # else 
-static int dummy()
+static void dummy()
 {
 }
 # endif
--- a/tmp.c
+++ b/tmp.c
@@ -13,6 +13,9 @@
 
 #include "config.h"
 #include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 #include "vi.h"
 #if TOS
 # include <stat.h>
@@ -24,7 +27,7 @@
 # endif
 #endif
 #include <malloc.h>
-
+#include <string.h>
 
 #ifndef NO_MODELINE
 static void do_modeline(l, stop)
--- a/cmd1.c
+++ b/cmd1.c
@@ -14,6 +14,8 @@
 
 #include "config.h"
 #include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
 #include "vi.h"
 #include "regexp.h"
 
@@ -278,7 +280,7 @@ void cmd_shell(frommark, tomark, cmd, ba
 	suspend_curses();
 	if (frommark == 0L)
 	{
-		system(extra);
+		elvis_system(extra);
 	}
 	else /* pipe lines from the file through the command */
 	{
--- a/cmd2.c
+++ b/cmd2.c
@@ -11,6 +11,9 @@
 /* This file contains some of the commands - mostly ones that change text */
 
 #include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include "config.h"
 #include "vi.h"
 #include "regexp.h"
@@ -23,7 +26,7 @@
 #  include <sys/stat.h>
 # endif
 #endif
-
+#include <string.h>
 
 /*ARGSUSED*/
 void cmd_substitute(frommark, tomark, cmd, bang, extra)
--- a/config.h
+++ b/config.h
@@ -148,7 +148,6 @@
 #if BSD || UNIX7 || OSK
 # define strchr	index
 #endif
-extern char *strchr();
 
 /* BSD uses bcopy() instead of memcpy() */
 #if BSD
@@ -219,6 +218,10 @@ extern char *malloc();
 # endif
 #endif
 
+#ifndef ANY_UNIX
+#  define elvis_system system
+#endif
+
 #if MSDOS || TOS
 /* do not change TMPNAME, CUTNAME and SCRATCH*: they MUST begin with '%s\\'! */
 # ifndef TMPDIR
--- a/curses.c
+++ b/curses.c
@@ -35,6 +35,8 @@
 #endif
 
 #include <signal.h>
+#include <stdlib.h>
+#include <string.h>
 
 extern char	*getenv();
 static void	 starttcap();
--- a/cut.c
+++ b/cut.c
@@ -20,6 +20,10 @@
 #define	rename(a,b)	Frename(0,a,b)
 #endif
 
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
 # define NANNONS	9	/* number of annonymous buffers */
 
 static struct cutbuf
--- a/ex.c
+++ b/ex.c
@@ -12,6 +12,7 @@
 
 #include "config.h"
 #include <ctype.h>
+#include <string.h>
 #include "vi.h"
 
 #ifndef isascii
--- a/input.c
+++ b/input.c
@@ -15,7 +15,7 @@
 #include <ctype.h>
 #include "config.h"
 #include "vi.h"
-
+#include <string.h>
 
 #ifndef NO_DIGRAPH
 static struct _DIG
--- a/misc.c
+++ b/misc.c
@@ -12,6 +12,7 @@
 
 #include "config.h"
 #include "vi.h"
+#include <string.h>
 
 
 /* find a particular line & return a pointer to a copy of its text */
--- a/modify.c
+++ b/modify.c
@@ -8,6 +8,7 @@
 
 #include "config.h"
 #include "vi.h"
+#include <string.h>
 
 #ifdef DEBUG
 # include <stdio.h>
--- a/move2.c
+++ b/move2.c
@@ -13,6 +13,7 @@
 #include "config.h"
 #include "vi.h"
 #include "regexp.h"
+#include <stdlib.h>
 
 extern long	atol();
 
--- a/opts.c
+++ b/opts.c
@@ -14,6 +14,8 @@
 
 #include "config.h"
 #include "vi.h"
+#include <stdio.h>
+#include <string.h>
 #ifndef NULL
 #define NULL (char *)0
 #endif
--- a/regexp.c
+++ b/regexp.c
@@ -31,6 +31,8 @@
 
 #include <setjmp.h>
 #include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
 #include "config.h"
 #include "vi.h"
 #include "regexp.h"
--- a/regsub.c
+++ b/regsub.c
@@ -5,6 +5,8 @@
  */
 
 #include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
 #include "config.h"
 #include "vi.h"
 #include "regexp.h"
--- a/system.c
+++ b/system.c
@@ -25,6 +25,9 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 extern char	**environ;
 
 #if ANY_UNIX
@@ -32,8 +35,8 @@ extern char	**environ;
 /* This is a new version of the system() function.  The only difference
  * between this one and the library one is: this one uses the o_shell option.
  */
-int system(cmd)
-	char	*cmd;	/* a command to run */
+int elvis_system(char *cmd)
+/*	char	*cmd;	 a command to run */
 {
 	int	status;	/* exit status of the command */
 
--- a/vcmd.c
+++ b/vcmd.c
@@ -13,6 +13,8 @@
 
 #include "config.h"
 #include "vi.h"
+#include <string.h>
+#include <stdio.h>
 #if MSDOS
 #include <process.h>
 #include <string.h>
@@ -627,7 +629,7 @@ MARK v_keyword(keyword, m, cnt)
 	waswarn = *o_warn;
 	*o_warn = FALSE;
 	suspend_curses();
-	if (system(cmdline))
+	if (elvis_system(cmdline))
 	{
 		addstr("<<< failed >>>\n");
 	}
--- a/vi.c
+++ b/vi.c
@@ -10,6 +10,7 @@
 
 #include "config.h"
 #include <ctype.h>
+#include <string.h>
 #include "vi.h"
 
 
--- a/vi.h
+++ b/vi.h
@@ -409,6 +409,9 @@ typedef int CMD;
 extern void	ex();
 extern void	vi();
 extern void	doexcmd();
+#ifndef elvis_system
+extern int	elvis_system(char *cmd);
+#endif
 
 #ifndef NO_ABBR
 extern void	cmd_abbr();
