summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authordholland <dholland>2012-12-28 03:03:08 +0000
committerdholland <dholland>2012-12-28 03:03:08 +0000
commit07b24342c151565b853024240776c2856aee34ef (patch)
tree8c0484149657a50a301fa0bcb9d58f2f596c8985 /editors
parentad2c90a7d99400d4797dcba661d63a6ce9a6a683 (diff)
downloadpkgsrc-07b24342c151565b853024240776c2856aee34ef.tar.gz
Fix legacy C. Pass -Wall -W -Wmissing-declarations -Wwrite-strings on
gcc45. - avoid implicit int, declare void functions void - return values from non-void functions - put most external declarations properly in header files - use some static and const - fix up a big mess with function pointer casting - use standard includes, don't provide own decls of standard functions - use types matching libc when providing own malloc, printf, and putchar - use <ctype.h> functions correctly - silence assorted compiler warnings - fix some bugs exposed by compiler warnings - don't intentionally exercise signed overflow - remove some unused items - add patch comments to other patch (patch-aa) As this includes several fixes and removes some undefined behavior on a commonly reachable code path, bump PKGREVISION.
Diffstat (limited to 'editors')
-rw-r--r--editors/ex/Makefile10
-rw-r--r--editors/ex/distinfo48
-rw-r--r--editors/ex/patches/patch-aa7
-rw-r--r--editors/ex/patches/patch-ab25
-rw-r--r--editors/ex/patches/patch-ac164
-rw-r--r--editors/ex/patches/patch-ad95
-rw-r--r--editors/ex/patches/patch-ex__addr_c71
-rw-r--r--editors/ex/patches/patch-ex__argv_h12
-rw-r--r--editors/ex/patches/patch-ex__cmds2_c239
-rw-r--r--editors/ex/patches/patch-ex__cmds_c42
-rw-r--r--editors/ex/patches/patch-ex__cmdsub_c296
-rw-r--r--editors/ex/patches/patch-ex__get_c121
-rw-r--r--editors/ex/patches/patch-ex__io_c238
-rw-r--r--editors/ex/patches/patch-ex__proto_h595
-rw-r--r--editors/ex/patches/patch-ex__put_c530
-rw-r--r--editors/ex/patches/patch-ex__re_c348
-rw-r--r--editors/ex/patches/patch-ex__set_c128
-rw-r--r--editors/ex/patches/patch-ex__subr_c686
-rw-r--r--editors/ex/patches/patch-ex__tagio_c63
-rw-r--r--editors/ex/patches/patch-ex__temp_c255
-rw-r--r--editors/ex/patches/patch-ex__tty_c147
-rw-r--r--editors/ex/patches/patch-ex__tty_h39
-rw-r--r--editors/ex/patches/patch-ex__unix_c65
-rw-r--r--editors/ex/patches/patch-ex__v_c155
-rw-r--r--editors/ex/patches/patch-ex__vadj_c259
-rw-r--r--editors/ex/patches/patch-ex__version_c21
-rw-r--r--editors/ex/patches/patch-ex__vget_c258
-rw-r--r--editors/ex/patches/patch-ex__vis_h36
-rw-r--r--editors/ex/patches/patch-ex__vmain_c209
-rw-r--r--editors/ex/patches/patch-ex__voper_c351
-rw-r--r--editors/ex/patches/patch-ex__vops2_c211
-rw-r--r--editors/ex/patches/patch-ex__vops3_c323
-rw-r--r--editors/ex/patches/patch-ex__vops_c240
-rw-r--r--editors/ex/patches/patch-ex__vput_c471
-rw-r--r--editors/ex/patches/patch-ex__vwind_c173
-rw-r--r--editors/ex/patches/patch-ex_c122
-rw-r--r--editors/ex/patches/patch-expreserve_c90
-rw-r--r--editors/ex/patches/patch-exrecover_c332
-rw-r--r--editors/ex/patches/patch-libterm_libterm_h23
-rw-r--r--editors/ex/patches/patch-libterm_termcap_c77
-rw-r--r--editors/ex/patches/patch-libterm_tgoto_c25
-rw-r--r--editors/ex/patches/patch-libterm_tputs_c32
-rw-r--r--editors/ex/patches/patch-printf_c205
43 files changed, 7800 insertions, 37 deletions
diff --git a/editors/ex/Makefile b/editors/ex/Makefile
index be13dd77c5b..51daa8b67f8 100644
--- a/editors/ex/Makefile
+++ b/editors/ex/Makefile
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.10 2012/10/03 11:43:33 asau Exp $
+# $NetBSD: Makefile,v 1.11 2012/12/28 03:03:08 dholland Exp $
#
DISTNAME= ex-040103
PKGNAME= ex-20040103
-PKGREVISION= 2
+PKGREVISION= 3
CATEGORIES= editors
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=ex-vi/files/ex-vi/040103/}
@@ -12,6 +12,12 @@ HOMEPAGE= http://ex-vi.sourceforge.net/
COMMENT= Berkeley vi 3.7
LICENSE= original-bsd
+SUBST_CLASSES+= getline
+SUBST_STAGE.getline= post-extract
+SUBST_MESSAGE.getline= Changing 'getline' to 'get_line'
+SUBST_FILES.getline= ex*.c ex_proto.h
+SUBST_SED.getline= -e "s,getline,get_line,g"
+
MAKE_DIRS_PERMS+= ${VARBASE}/tmp/vi.recover ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 1777
.include "../../mk/curses.buildlink3.mk"
diff --git a/editors/ex/distinfo b/editors/ex/distinfo
index 666602b364f..de3a716062b 100644
--- a/editors/ex/distinfo
+++ b/editors/ex/distinfo
@@ -1,10 +1,46 @@
-$NetBSD: distinfo,v 1.14 2011/08/01 05:47:40 dholland Exp $
+$NetBSD: distinfo,v 1.15 2012/12/28 03:03:08 dholland Exp $
SHA1 (ex-040103.tar.gz) = 51fa1d613b37a4f3aed1ef2968be691465cdff09
RMD160 (ex-040103.tar.gz) = 5fc3f222dde5a8d00e1b233281ccf210affdbdf1
Size (ex-040103.tar.gz) = 284130 bytes
-SHA1 (patch-aa) = 8902846a518fbf214725a801293610ebe12c143b
-SHA1 (patch-ab) = 5bac9911e71b7fe787023568a7a46d1e87fb4d0e
-SHA1 (patch-ac) = 0401448724a4aba59b4aeb07a4cb00982bb52d98
-SHA1 (patch-ad) = 31bafb04f553ca286baf90505da450964fea9954
-SHA1 (patch-exrecover_c) = f5fd1bff1f1e8229170415081815531d86e482da
+SHA1 (patch-aa) = a8b9fd02ec7e576ea1bbf239cbd34bf7bae7c4a8
+SHA1 (patch-ab) = 1b75764cb5ef0873a307874bb94dd9d4e7e74290
+SHA1 (patch-ac) = a849730017d13a60686cdca81c9c74a55cd29b53
+SHA1 (patch-ad) = 497407efc9b2afc397a735abc6234bed8ece97ae
+SHA1 (patch-ex__addr_c) = 61d9851b746fe90b2f413dd42b09659fda13ffdb
+SHA1 (patch-ex__argv_h) = e121a95b2dd50ed5778af43df716913758d643d5
+SHA1 (patch-ex__cmds2_c) = 9856d947c0be80a3f597c7b16ec28ac729880668
+SHA1 (patch-ex__cmds_c) = 730252b283392a944f3b95c43182ed178a459ddd
+SHA1 (patch-ex__cmdsub_c) = d76d0e0d2748c30f1541a95fe194b3cf70a670fa
+SHA1 (patch-ex__get_c) = 19f439eaa2ab68755fb2f1b9e38bd6b2bfff6466
+SHA1 (patch-ex__io_c) = cc490141c0eaf6c172d36eccb403e21f762052f7
+SHA1 (patch-ex__proto_h) = ecd701f056e9ab78fd47d07b997e80e32e1e47fe
+SHA1 (patch-ex__put_c) = c3f8dddff3919b745f460aead3bc2dfda8b30083
+SHA1 (patch-ex__re_c) = fde8ef4a089ffc64980fde00a320ff906f7f4ee2
+SHA1 (patch-ex__set_c) = fa59569a6fa00649a01c2f399ec17f1e3d9e2de9
+SHA1 (patch-ex__subr_c) = 2c7291aa9988644c8eb7fa62778497743dd96d14
+SHA1 (patch-ex__tagio_c) = 83227d9ff2e88e55e06d3c8db94e106a25d2e00a
+SHA1 (patch-ex__temp_c) = 1b45c4f02d6ad0ff90f814e8e9c18e2ec739ec15
+SHA1 (patch-ex__tty_c) = 65d2ea5b01f6049419a00ece6664a86d9044fafc
+SHA1 (patch-ex__tty_h) = 64d7a196f499d3eedb7330a904e192e67d83cf3a
+SHA1 (patch-ex__unix_c) = f52c637a52987191404befd262e3717472995d91
+SHA1 (patch-ex__v_c) = 1af23e5f70f92e0269a740fcef665b45e1a0b461
+SHA1 (patch-ex__vadj_c) = 4de4dae1865d61a56da756493e8c098eff05039c
+SHA1 (patch-ex__version_c) = ddc81149794020a151435c1571817ad2315c305f
+SHA1 (patch-ex__vget_c) = 6b28e0fd02b6c6304a7996da9825e397a4f7635a
+SHA1 (patch-ex__vis_h) = be29bf377a0badf691ad3b65f8fedef73d67de4d
+SHA1 (patch-ex__vmain_c) = 52822b649d88acf16899ba1beb4559a3534b489d
+SHA1 (patch-ex__voper_c) = 2f0a55d21466f581ce4089986632339a67795633
+SHA1 (patch-ex__vops2_c) = cea13dde0335b81507f87838137e3360fe545d60
+SHA1 (patch-ex__vops3_c) = d2bab4f54f3bf8d7fa9b5cc44a8a5210dfdba87a
+SHA1 (patch-ex__vops_c) = f7c15746a93544ed058ab4af6a389049b74a99a8
+SHA1 (patch-ex__vput_c) = fa0216eb004ae58a297c3f00a610d689c978f273
+SHA1 (patch-ex__vwind_c) = 9ed05094167870f5eb9af28deb39318aa69cf832
+SHA1 (patch-ex_c) = c0c5d5d5fd45da46e2594101a7a3d4350c49ae05
+SHA1 (patch-expreserve_c) = 2c94b4eefa3e72c6abc4aaa2f54750557705c794
+SHA1 (patch-exrecover_c) = 8742a5ba155996632971891cdd4a24b4d97d4376
+SHA1 (patch-libterm_libterm_h) = 2f552d89726baf1d8b2c3be15ef386db7dffe04d
+SHA1 (patch-libterm_termcap_c) = cbc3ece52b9bbfd286be7953d9cb3bcf6e460b0e
+SHA1 (patch-libterm_tgoto_c) = d4299bdd468f0fff4d0fbbb67f37b8080a334787
+SHA1 (patch-libterm_tputs_c) = a305e0ccc35aafe30b3b061bb47964b0ae845e9a
+SHA1 (patch-printf_c) = 4a64b79fd7d3f1c6271d238cc3b71f02f43537d0
diff --git a/editors/ex/patches/patch-aa b/editors/ex/patches/patch-aa
index e8423752b27..bc3158a28b8 100644
--- a/editors/ex/patches/patch-aa
+++ b/editors/ex/patches/patch-aa
@@ -1,4 +1,9 @@
-$NetBSD: patch-aa,v 1.7 2010/01/31 21:24:04 joerg Exp $
+$NetBSD: patch-aa,v 1.8 2012/12/28 03:03:08 dholland Exp $
+
+- configure paths and programs for pkgsrc
+- don't install the executable sticky as that's often no longer allowed
+- don't create the PRESERVEDIR at install time
+ (the pkgsrc makefile takes care of it)
--- Makefile.orig 2004-01-03 14:22:47.000000000 +0000
+++ Makefile
diff --git a/editors/ex/patches/patch-ab b/editors/ex/patches/patch-ab
index 4cb692d3ef6..e110c484bfe 100644
--- a/editors/ex/patches/patch-ab
+++ b/editors/ex/patches/patch-ab
@@ -1,6 +1,11 @@
-$NetBSD: patch-ab,v 1.1 2005/10/31 20:04:46 tv Exp $
+$NetBSD: patch-ab,v 1.2 2012/12/28 03:03:08 dholland Exp $
---- malloc.c.orig 2002-03-02 07:15:03.000000000 -0500
+- use standard headers
+ (these functions are supposed to substitute for the libc ones, so they
+ need to match stdlib.h exactly)
+- declare void functions void
+
+--- malloc.c.orig 2002-03-02 12:15:03.000000000 +0000
+++ malloc.c
@@ -45,6 +45,7 @@
#include <sys/types.h>
@@ -10,3 +15,19 @@ $NetBSD: patch-ab,v 1.1 2005/10/31 20:04:46 tv Exp $
#else /* !POSIX_1 */
#include <sys/types.h>
extern int errno;
+@@ -235,6 +236,7 @@ found:
+
+ /* freeing strategy tuned for LIFO allocation
+ */
++void
+ free(ap)
+ register char *ap;
+ {
+@@ -331,6 +333,7 @@ size_t num, size;
+ }
+
+ /*ARGSUSED*/
++void
+ cfree(p, num, size)
+ char *p;
+ size_t num, size;
diff --git a/editors/ex/patches/patch-ac b/editors/ex/patches/patch-ac
index 1434c62a7d0..64139b817a8 100644
--- a/editors/ex/patches/patch-ac
+++ b/editors/ex/patches/patch-ac
@@ -1,26 +1,166 @@
-$NetBSD: patch-ac,v 1.4 2006/07/22 04:23:29 minskim Exp $
+$NetBSD: patch-ac,v 1.5 2012/12/28 03:03:08 dholland Exp $
---- mapmalloc.c.orig 2003-01-28 12:04:25.000000000 -0800
+- use standard headers
+ (these functions are supposed to substitute for the libc ones, so they
+ need to match stdlib.h exactly)
+- use own headers
+- declare void functions void
+- fix return and argument types
+
+--- mapmalloc.c.orig 2003-01-28 20:04:25.000000000 +0000
+++ mapmalloc.c
-@@ -54,6 +54,9 @@
+@@ -54,18 +54,12 @@
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
-+#if defined(__INTERIX)
+-#ifdef __GLIBC__
+-/*
+- * Broken GNU libc will include stdlib.h with conflicting
+- * malloc() types otherwise.
+- */
+-#ifndef __NO_STRING_INLINES
+-#define __NO_STRING_INLINES
+-#endif /* !__NO_STRING_INLINES */
+-#endif /* __GLIBC__ */
+#include <stdlib.h>
-+#endif
- #ifdef __GLIBC__
+ #include <string.h>
+
+ #include "config.h"
++#include "ex.h"
++#include "ex_proto.h"
+
+ #ifdef LANGMSG
+ #include <nl_types.h>
+@@ -176,8 +170,6 @@ static MM *mm_global = NULL;
+ static int zerofd = -1;
+ #endif
+
+-extern int error __P((char *, ...));
+-
/*
- * Broken GNU libc will include stdlib.h with conflicting
-@@ -551,7 +554,11 @@ size_t alignment, size;
+ * Determine memory page size of OS
+ */
+@@ -308,7 +300,7 @@ mm_create(MM *mmPrev, size_t usize)
+ * and/or next chunk when possible to form larger chunks out of
+ * smaller ones.
+ */
+-static
++static void
+ mm_insert_chunk(MM *mm, mem_chunk *mcInsert)
+ {
+ mem_chunk *mc;
+@@ -429,7 +421,7 @@ mm_retrieve_chunk(MM *mm, size_t size)
+ /*
+ * Allocate a chunk of memory
+ */
+-char *
++void *
+ malloc(size_t usize)
+ {
+ MM *mm;
+@@ -469,10 +461,12 @@ nextpool:
+ /*
+ * Free a chunk of memory
+ */
+-free(char *ptr)
++void
++free(void *ptrV)
+ {
+ MM *mm;
+ mem_chunk *mc;
++ char *ptr = ptrV;
+
+ if (mm_global == NULL || ptr == NULL)
+ return;
+@@ -494,12 +488,13 @@ free(char *ptr)
+ /*
+ * Reallocate a chunk of memory
+ */
+-char *
+-realloc(char *ptr, size_t usize)
++void *
++realloc(void *ptrV, size_t usize)
+ {
+ size_t size;
+ mem_chunk *mc;
+ char *vp;
++ char *ptr = ptrV;
+
+ if (ptr == NULL)
+ return malloc(usize); /* POSIX.1 semantics */
+@@ -523,7 +518,7 @@ realloc(char *ptr, size_t usize)
+ /*
+ * Allocate and initialize a chunk of memory
+ */
+-char *
++void *
+ calloc(size_t number, size_t usize)
+ {
+ char *vp;
+@@ -534,38 +529,55 @@ calloc(size_t number, size_t usize)
+ return vp;
}
++#ifndef __NetBSD__ /* signature does not agree with netbsd's libcompat */
/*ARGSUSED*/
-+#if defined(__DragonFly__) || defined(__APPLE__)
-+void *
-+#else
- char *
+-cfree(p, num, size)
++void cfree(p, num, size)
+ char *p;
+ size_t num, size;
+ {
+ free(p);
+ }
+#endif
++
++
++/*
++ * Not all systems have the following in libc, so avoid compiler warnings
++ * by inserting extra global declarations.
++ */
++char *memalign(size_t alignment, size_t size);
++void *valloc(size_t size);
++char *mallinfo(void);
++int mallopt(void);
++char *poolsbrk(intptr_t val);
++
+
+ /*ARGSUSED*/
+ char *
+ memalign(alignment, size)
+ size_t alignment, size;
+ {
++ (void)alignment;
++ (void)size;
+ return NULL;
+ }
+
+ /*ARGSUSED*/
+-char *
++void *
valloc(size)
size_t size;
{
++ (void)size;
+ return NULL;
+ }
+
+ char *
+-mallinfo()
++mallinfo(void)
+ {
+ return NULL;
+ }
+
+ int
+-mallopt()
++mallopt(void)
+ {
+ return -1;
+ }
+@@ -574,5 +586,6 @@ mallopt()
+ char *
+ poolsbrk(intptr_t val)
+ {
++ (void)val;
+ return NULL;
+ }
diff --git a/editors/ex/patches/patch-ad b/editors/ex/patches/patch-ad
index fbecc97e450..b476d4b8b91 100644
--- a/editors/ex/patches/patch-ad
+++ b/editors/ex/patches/patch-ad
@@ -1,8 +1,76 @@
-$NetBSD: patch-ad,v 1.1 2006/06/08 16:15:47 minskim Exp $
+$NetBSD: patch-ad,v 1.2 2012/12/28 03:03:08 dholland Exp $
---- ex.h.orig 2003-03-18 20:29:07.000000000 +0000
+- teach it about dead functions
+- use const for string constants
+- use speed_t for tty speed
+- don't declare versionstring, which is static in ex_version.c
+- fix up function pointer casting mess
+
+--- ex.h.orig 2012-12-27 21:58:42.000000000 +0000
+++ ex.h
-@@ -549,7 +549,6 @@ extern int tfile; /* Temporary file uni
+@@ -238,6 +238,15 @@ typedef int woid;
+ #endif /* !__STDC__ */
+
+ /*
++ * nonreturning functions
++ */
++#if defined(__GNUC__) || defined(__CLANG__)
++#define dead __attribute__((__noreturn__))
++#else
++#define dead
++#endif
++
++/*
+ * Use reliable POSIX.1 signals if available.
+ */
+ #ifdef POSIX_1
+@@ -401,8 +410,8 @@ typedef jmp_buf JMP_BUF;
+ * ex_data.c... see the shell script "makeoptions".
+ */
+ struct option {
+- char *oname;
+- char *oabbrev;
++ const char *oname;
++ const char *oabbrev;
+ short otype; /* Types -- see below */
+ short odefault; /* Default value */
+ short ovalue; /* Current value */
+@@ -483,7 +492,7 @@ var bool aiflag; /* Append/change/inser
+ var bool anymarks; /* We have used '[a-z] */
+ var int bsize; /* Block size for disk i/o */
+ var int chng; /* Warn "No write" */
+-var char *Command;
++var const char *Command;
+ var short defwind; /* -w# change default window size */
+ var int dirtcnt; /* When >= MAXDIRT, should sync temporary */
+ #ifdef TIOCLGET
+@@ -504,11 +513,11 @@ var char file[FNSIZE]; /* Working file n
+ var bool fixedzero; /* zero file size was fixed (for visual) */
+ var char genbuf[MAXBSIZE]; /* Working buffer when manipulating linebuf */
+ var bool hush; /* Command line option - was given, hush up! */
+-var char *globp; /* (Untyped) input string to command mode */
++var const char *globp; /* (Untyped) input string to command mode */
+ var bool holdcm; /* Don't cursor address */
+ var bool inappend; /* in ex command append mode */
+ var bool inglobal; /* Inside g//... or v//... */
+-var char *initev; /* Initial : escape for visual */
++var const char *initev; /* Initial : escape for visual */
+ var bool inopen; /* Inside open or visual */
+ var char *input; /* Current position in cmd line input buffer */
+ var bool intty; /* Input is a tty */
+@@ -530,7 +539,11 @@ var shand oldquit; /* Previous SIGQUIT h
+ var shand oldxfsz; /* Previous SIGXFSZ handler */
+ #endif
+ var short oprompt; /* Saved during source */
++#ifdef POSIX_1
++extern speed_t ospeed; /* Output speed (from gtty) */
++#else
+ extern short ospeed; /* Output speed (from gtty) */
++#endif
+ var int otchng; /* Backup tchng to find changes in macros */
+ var short peekc; /* Peek ahead character (cmd mode input) */
+ var char *pkill[2]; /* Trim for put with ragged (LISP) delete */
+@@ -549,7 +562,6 @@ extern int tfile; /* Temporary file uni
var bool tflag; /* -t option given on command line */
var bool vcatch; /* Want to catch an error (open/visual) */
var bool verbose; /* -V option; print command input to stderr */
@@ -10,3 +78,24 @@ $NetBSD: patch-ad,v 1.1 2006/06/08 16:15:47 minskim Exp $
var JMP_BUF vreslab; /* For error throws to a visual catch */
var bool writing; /* 1 if in middle of a file write */
var int xchng; /* Suppresses multiple "No writes" in !cmd */
+@@ -639,9 +651,9 @@ var line *undadot; /* If we saved all li
+ #define UNDNONE 3
+ #define UNDPUT 4
+
+-extern int (*Outchar)();
+-extern int (*Pline)();
+-extern int (*Putchar)();
++extern int (*Outchar)(int);
++extern int (*Pline)(int);
++extern int (*Putchar)(int);
+
+ #define NOSTR (char *) 0
+ #define NOLINE (line *) 0
+@@ -663,6 +675,6 @@ var nl_catd catd;
+ #else /* !LANGMSG */
+ #define catgets(a, b, c, d) (d)
+ #endif /* !LANGMSG */
+-var char *cntrlhm;
++var const char *cntrlhm;
+
+ #include "ex_proto.h"
diff --git a/editors/ex/patches/patch-ex__addr_c b/editors/ex/patches/patch-ex__addr_c
new file mode 100644
index 00000000000..c482d705b3e
--- /dev/null
+++ b/editors/ex/patches/patch-ex__addr_c
@@ -0,0 +1,71 @@
+$NetBSD: patch-ex__addr_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- declare void functions void
+- avoid implicit int
+
+--- ex_addr.c~ 2002-02-02 02:08:35.000000000 +0000
++++ ex_addr.c
+@@ -102,6 +102,7 @@ static bool bigmove;
+ /*
+ * Set up addr1 and addr2 for commands whose default address is dot.
+ */
++void
+ setdot()
+ {
+
+@@ -114,6 +115,7 @@ setdot()
+ * Call setdot1 to set up default addresses without ever
+ * setting the previous context mark.
+ */
++void
+ setdot1()
+ {
+
+@@ -132,6 +134,7 @@ setdot1()
+ * to delete 5 lines, etc.
+ * Such nonsense is implemented by setcount.
+ */
++void
+ setcount()
+ {
+ register int cnt;
+@@ -155,6 +158,7 @@ setcount()
+ /*
+ * Parse a number out of the command input stream.
+ */
++int
+ getnum()
+ {
+ register int cnt;
+@@ -168,6 +172,7 @@ getnum()
+ * Set the default addresses for commands which use the whole
+ * buffer as default, notably write.
+ */
++void
+ setall()
+ {
+
+@@ -188,6 +193,7 @@ setall()
+ /*
+ * No address allowed on, e.g. the file command.
+ */
++void
+ setnoaddr()
+ {
+
+@@ -377,6 +383,7 @@ error(catgets(catd, 1, 11, "No match to
+ * Left over from squashing ex version 1.1 into
+ * 11/34's and 11/40's.
+ */
++void
+ setCNL()
+ {
+
+@@ -384,6 +391,7 @@ setCNL()
+ newline();
+ }
+
++void
+ setNAEOL()
+ {
+
diff --git a/editors/ex/patches/patch-ex__argv_h b/editors/ex/patches/patch-ex__argv_h
new file mode 100644
index 00000000000..5594d9013be
--- /dev/null
+++ b/editors/ex/patches/patch-ex__argv_h
@@ -0,0 +1,12 @@
+$NetBSD: patch-ex__argv_h,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- declare void functions void
+
+--- ex_argv.h~ 2002-02-02 00:05:46.000000000 +0000
++++ ex_argv.h
+@@ -102,4 +102,4 @@ struct glob {
+ };
+ var struct glob frob;
+
+-int gglob __P((struct glob *));
++void gglob __P((struct glob *));
diff --git a/editors/ex/patches/patch-ex__cmds2_c b/editors/ex/patches/patch-ex__cmds2_c
new file mode 100644
index 00000000000..d7e1ea433b3
--- /dev/null
+++ b/editors/ex/patches/patch-ex__cmds2_c
@@ -0,0 +1,239 @@
+$NetBSD: patch-ex__cmds2_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- avoid implicit int
+- declare void functions void
+- use const for string constants
+
+--- ex_cmds2.c~ 2002-02-02 02:08:35.000000000 +0000
++++ ex_cmds2.c
+@@ -95,6 +95,7 @@ extern int poffset; /* mjm: extern; als
+ /*
+ * Is there a single letter indicating a named buffer next?
+ */
++int
+ cmdreg()
+ {
+ register int c = 0;
+@@ -108,6 +109,7 @@ cmdreg()
+ /*
+ * Tell whether the character ends a command
+ */
++int
+ endcmd(ch)
+ int ch;
+ {
+@@ -129,6 +131,7 @@ endcmd(ch)
+ /*
+ * Insist on the end of the command.
+ */
++void
+ eol()
+ {
+
+@@ -144,7 +147,8 @@ eol()
+ * just fixing up the echo area for the print.
+ * Otherwise we reset a number of externals, and discard unused input.
+ */
+-error0()
++static void
++error0(void)
+ {
+
+ if (vcatch) {
+@@ -191,8 +195,8 @@ error0()
+ * Otherwise, in the normal command mode error case,
+ * finish state reset, and throw to top.
+ */
+-error1(str)
+- char *str;
++static void
++error1(const char *str)
+ {
+ bool die;
+
+@@ -230,17 +234,18 @@ error1(str)
+ * with i an integer argument to printf.
+ */
+ /*VARARGS2*/
++void
+ #ifndef __STDC__
+ error(str, i)
+ #ifdef lint
+- register char *str;
++ register const char *str;
+ #else
+ register int str;
+ #endif
+ int i;
+ {
+ #else
+-error(char *str, ...)
++error(const char *str, ...)
+ {
+ va_list ap;
+ #endif
+@@ -265,6 +270,7 @@ error(char *str, ...)
+ /*
+ * Rewind the argument list.
+ */
++void
+ erewind()
+ {
+
+@@ -280,6 +286,7 @@ erewind()
+ }
+ }
+
++void
+ fixol()
+ {
+ if (Outchar != vputchar) {
+@@ -298,6 +305,7 @@ fixol()
+ /*
+ * Does an ! character follow in the command stream?
+ */
++int
+ exclam()
+ {
+
+@@ -311,6 +319,7 @@ exclam()
+ /*
+ * Make an argument list for e.g. next.
+ */
++void
+ makargs()
+ {
+
+@@ -324,6 +333,7 @@ makargs()
+ /*
+ * Advance to next file in argument list.
+ */
++void
+ next()
+ {
+ extern short isalt; /* defined in ex_io.c */
+@@ -343,6 +353,7 @@ next()
+ * Eat trailing flags and offsets after a command,
+ * saving for possible later post-command prints.
+ */
++void
+ newline()
+ {
+ register int c;
+@@ -399,6 +410,7 @@ serror(catgets(catd, 1, 32,
+ * Before quit or respec of arg list, check that there are
+ * no more files in the arg list.
+ */
++void
+ nomore()
+ {
+
+@@ -413,6 +425,7 @@ nomore()
+ * Before edit of new file check that either an ! follows
+ * or the file has not been changed.
+ */
++int
+ quickly()
+ {
+
+@@ -432,6 +445,7 @@ quickly()
+ /*
+ * Reset the flavor of the output to print mode with no numbering.
+ */
++void
+ resetflav()
+ {
+
+@@ -448,10 +462,11 @@ resetflav()
+ * Print an error message with a %s type argument to printf.
+ * Message text comes from error message file.
+ */
++void
+ #ifndef __STDC__
+ serror(str, cp)
+ #ifdef lint
+- register char *str;
++ register const char *str;
+ #else
+ register int str;
+ #endif
+@@ -463,7 +478,7 @@ serror(str, cp)
+ error1(str);
+ }
+ #else /* __STDC__ */
+-serror(char *str, ...)
++serror(const char *str, ...)
+ {
+ va_list ap;
+
+@@ -482,6 +497,7 @@ serror(char *str, ...)
+ * and either use normally decoded (ARPAnet standard) characters or list mode,
+ * where end of lines are marked and tabs print as ^I.
+ */
++void
+ setflav()
+ {
+
+@@ -495,6 +511,7 @@ setflav()
+ /*
+ * Skip white space and tell whether command ends then.
+ */
++int
+ skipend()
+ {
+
+@@ -505,6 +522,7 @@ skipend()
+ /*
+ * Set the command name for non-word commands.
+ */
++void
+ tailspec(c)
+ int c;
+ {
+@@ -518,15 +536,17 @@ tailspec(c)
+ * Try to read off the rest of the command word.
+ * If alphabetics follow, then this is not the command we seek.
+ */
++void
+ tail(comm)
+- char *comm;
++ const char *comm;
+ {
+
+ tailprim(comm, 1, 0);
+ }
+
++void
+ tail2of(comm)
+- char *comm;
++ const char *comm;
+ {
+
+ tailprim(comm, 2, 0);
+@@ -534,8 +554,9 @@ tail2of(comm)
+
+ char tcommand[20];
+
++void
+ tailprim(comm, i, notinvis)
+- register char *comm;
++ register const char *comm;
+ int i;
+ bool notinvis;
+ {
+@@ -574,6 +595,7 @@ ret:
+ /*
+ * Continue after a : command from open/visual.
+ */
++void
+ vcontin(ask)
+ bool ask;
+ {
+@@ -643,6 +665,7 @@ vcontin(ask)
+ * Put out a newline (before a shell escape)
+ * if in open/visual.
+ */
++void
+ vnfl()
+ {
+
diff --git a/editors/ex/patches/patch-ex__cmds_c b/editors/ex/patches/patch-ex__cmds_c
new file mode 100644
index 00000000000..3bae7cb4713
--- /dev/null
+++ b/editors/ex/patches/patch-ex__cmds_c
@@ -0,0 +1,42 @@
+$NetBSD: patch-ex__cmds_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- declare void functions void
+- silence warnings about && and || precedence
+- silence warnings about braces
+
+--- ex_cmds.c~ 2012-12-27 20:24:51.000000000 +0000
++++ ex_cmds.c
+@@ -96,6 +96,7 @@ int poffset;
+ * is to strip command addresses, do a little address oriented
+ * processing and call command routines to do the real work.
+ */
++void
+ commands(noprompt, exitoneof)
+ bool noprompt, exitoneof;
+ {
+@@ -127,7 +128,7 @@ commands(noprompt, exitoneof)
+ * before the next command.
+ */
+ if (pflag ||
+- lchng != chng && value(AUTOPRINT) && !inglobal && !inopen && endline) {
++ (lchng != chng && value(AUTOPRINT) && !inglobal && !inopen && endline)) {
+ pflag = 0;
+ nochng();
+ if (dol != zero) {
+@@ -165,7 +166,7 @@ error(catgets(catd, 1, 17,
+ addr1 = addr2;
+ addr = address(0);
+ c = getcd();
+- if (addr == 0)
++ if (addr == 0) {
+ if (c == ',')
+ addr = dot;
+ else if (addr1 != 0) {
+@@ -173,6 +174,7 @@ error(catgets(catd, 1, 17,
+ break;
+ } else
+ break;
++ }
+ addr2 = addr;
+ given++;
+ if (c == ';') {
diff --git a/editors/ex/patches/patch-ex__cmdsub_c b/editors/ex/patches/patch-ex__cmdsub_c
new file mode 100644
index 00000000000..d3f95ad22e2
--- /dev/null
+++ b/editors/ex/patches/patch-ex__cmdsub_c
@@ -0,0 +1,296 @@
+$NetBSD: patch-ex__cmdsub_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- declare local functions static
+- avoid implicit int
+- declare void functions void
+- silence warnings about assignments in conditionals
+- use const for string constants
+
+--- ex_cmdsub.c.orig 2012-12-27 21:58:41.000000000 +0000
++++ ex_cmdsub.c
+@@ -93,15 +93,18 @@ static char sccsid[] = "@(#)ex_cmdsub.c
+
+ bool endline = 1;
+ line *tad1;
+-static jnoop();
++
++static int jnoop(void);
++static int getcopy(void);
+
+ /*
+ * Append after line a lines returned by function f.
+ * Be careful about intermediate states to avoid scramble
+ * if an interrupt comes in.
+ */
++int
+ append(f, a)
+- int (*f)();
++ int (*f)(void);
+ line *a;
+ {
+ register line *a1, *a2, *rdot;
+@@ -144,6 +147,7 @@ append(f, a)
+ return (nline);
+ }
+
++void
+ appendnone()
+ {
+
+@@ -156,6 +160,7 @@ appendnone()
+ /*
+ * Print out the argument list, with []'s around the current name.
+ */
++void
+ pargs()
+ {
+ register char **av = argv0, *as = args0;
+@@ -182,6 +187,7 @@ pargs()
+ * Delete lines; two cases are if we are really deleting,
+ * more commonly we are just moving lines to the undo save area.
+ */
++void
+ delete(hush)
+ bool hush;
+ {
+@@ -242,6 +248,7 @@ delete(hush)
+ killed();
+ }
+
++void
+ deletenone()
+ {
+
+@@ -256,6 +263,7 @@ deletenone()
+ * Crush out the undo save area, moving the open/visual
+ * save area down in its place.
+ */
++void
+ squish()
+ {
+ register line *a1 = dol + 1, *a2 = unddol + 1, *a3 = truedol + 1;
+@@ -276,8 +284,9 @@ squish()
+ * Join lines. Special hacks put in spaces, two spaces if
+ * preceding line ends with '.', or no spaces if next line starts with ).
+ */
+-static int jcount, jnoop();
++static int jcount;
+
++void
+ join(c)
+ int c;
+ {
+@@ -300,7 +309,7 @@ join(c)
+ }
+ }
+ }
+- while (*cp++ = *cp1++)
++ while ((*cp++ = *cp1++) != 0)
+ if (cp > &genbuf[LBSIZE-2])
+ error(catgets(catd, 1, 40,
+ "Line overflow|Result line of join would be too long"));
+@@ -316,8 +325,8 @@ join(c)
+ vundkind = VMANY;
+ }
+
+-static
+-jnoop()
++static int
++jnoop(void)
+ {
+
+ return(--jcount);
+@@ -327,11 +336,9 @@ jnoop()
+ * Move and copy lines. Hard work is done by move1 which
+ * is also called by undo.
+ */
+-int getcopy();
+
+-move1(cflag, addrt)
+- int cflag;
+- line *addrt;
++static void
++move1(int cflag, line *addrt)
+ {
+ register line *adt, *ad1, *ad2;
+ int lines;
+@@ -384,6 +391,7 @@ move1(cflag, addrt)
+ }
+ }
+
++void
+ move()
+ {
+ register line *adt;
+@@ -406,7 +414,8 @@ move()
+ killed();
+ }
+
+-getcopy()
++static int
++getcopy(void)
+ {
+
+ if (tad1 > addr2)
+@@ -418,7 +427,8 @@ getcopy()
+ /*
+ * Put lines in the buffer from the undo save area.
+ */
+-getput()
++static int
++getput(void)
+ {
+
+ if (tad1 > unddol)
+@@ -428,6 +438,7 @@ getput()
+ return (0);
+ }
+
++void
+ put()
+ {
+ register int cnt;
+@@ -452,6 +463,7 @@ put()
+ * Argument says pkills have meaning, e.g. called from
+ * put; it is 0 on calls from putreg.
+ */
++void
+ pragged(kill)
+ bool kill;
+ {
+@@ -489,6 +501,7 @@ pragged(kill)
+ * Shift lines, based on c.
+ * If c is neither < nor >, then this is a lisp aligning =.
+ */
++void
+ shift(c, cnt)
+ int c;
+ int cnt;
+@@ -546,6 +559,7 @@ shift(c, cnt)
+ * Find a tag in the tags file.
+ * Most work here is in parsing the tags file itself.
+ */
++void
+ tagfind(quick)
+ bool quick;
+ {
+@@ -634,7 +648,7 @@ badtag:
+ /* loop for each tags file entry */
+ register char *cp = linebuf;
+ register char *lp = lasttag;
+- char *oglobp;
++ const char *oglobp;
+
+ #ifdef FASTTAG
+ mid = (top + bot) / 2;
+@@ -777,6 +791,7 @@ badtags:
+ * Save lines from addr1 thru addr2 as though
+ * they had been deleted.
+ */
++void
+ yank()
+ {
+
+@@ -801,6 +816,7 @@ bool zhadpr;
+ bool znoclear;
+ short zweight;
+
++void
+ zop(hadpr)
+ int hadpr;
+ {
+@@ -862,8 +878,8 @@ zop(hadpr)
+ zop2(lines, op);
+ }
+
+-static
+-splitit()
++static void
++splitit(void)
+ {
+ register int l;
+
+@@ -872,6 +888,7 @@ splitit()
+ putnl();
+ }
+
++void
+ zop2(lines, op)
+ register int lines;
+ register int op;
+@@ -956,6 +973,7 @@ zop2(lines, op)
+ plines(addr1, addr2, 0);
+ }
+
++void
+ plines(adr1, adr2, movedot)
+ line *adr1;
+ register line *adr2;
+@@ -981,6 +999,7 @@ plines(adr1, adr2, movedot)
+ }
+ }
+
++void
+ pofix()
+ {
+
+@@ -994,6 +1013,7 @@ pofix()
+ * Be (almost completely) sure there really
+ * was a change, before claiming to undo.
+ */
++static void
+ somechange()
+ {
+ register line *ip, *jp;
+@@ -1045,6 +1065,7 @@ somechange()
+ *
+ * Undo is its own inverse.
+ */
++void
+ undo(c)
+ bool c;
+ {
+@@ -1191,6 +1212,7 @@ undo(c)
+ * Map command:
+ * map src dest
+ */
++void
+ mapcmd(un, ab)
+ int un; /* true if this is unmap command */
+ int ab; /* true if this is abbr command */
+@@ -1287,8 +1309,10 @@ mapcmd(un, ab)
+ * using NOSTR for dest. Dname is what to show in listings. mp is
+ * the structure to affect (arrows, etc).
+ */
++void
+ addmac(src,dest,dname,mp)
+- register char *src, *dest, *dname;
++ register char *src;
++ register const char *dest, *dname;
+ register struct maps *mp;
+ {
+ register int slot, zer;
+@@ -1314,7 +1338,7 @@ addmac(src,dest,dname,mp)
+ * linefeed, and escape, he can screw himself. This is
+ * so weird I don't bother to check for it.
+ */
+- if (isalpha(cuc(src[0])) && src[1] || any(src[0],":"))
++ if ((isalpha(cuc(src[0])) && src[1]) || any(src[0],":"))
+ error(catgets(catd, 1, 64,
+ "Too dangerous to map that"));
+ }
+@@ -1385,12 +1409,13 @@ addmac(src,dest,dname,mp)
+ * Implements macros from command mode. c is the buffer to
+ * get the macro from.
+ */
++void
+ cmdmac(c)
+ char c;
+ {
+ char macbuf[BUFSIZ];
+ line *ad, *a1, *a2;
+- char *oglobp;
++ const char *oglobp;
+ short pk;
+ bool oinglobal;
+
diff --git a/editors/ex/patches/patch-ex__get_c b/editors/ex/patches/patch-ex__get_c
new file mode 100644
index 00000000000..26b2472fc57
--- /dev/null
+++ b/editors/ex/patches/patch-ex__get_c
@@ -0,0 +1,121 @@
+$NetBSD: patch-ex__get_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- declare void functions void
+- avoid implicit int
+- silence warnings about assignments in conditionals
+- silence warnings about braces
+- don't put external declarations inside functions
+
+--- ex_get.c.orig 2012-12-27 21:58:42.000000000 +0000
++++ ex_get.c
+@@ -90,12 +90,14 @@ static char sccsid[] = "@(#)ex_get.c 1.1
+ static bool junkbs;
+ short lastc = '\n';
+
++void
+ ignchar()
+ {
+ ignore(getchar());
+ }
+
+-getach()
++static int
++getach(void)
+ {
+ register int c;
+ static char in_line[BUFSIZ];
+@@ -114,7 +116,7 @@ getach()
+ }
+ top:
+ if (input) {
+- if (c = *input++&0377) {
++ if ((c = *input++&0377) != 0) {
+ if (verbose && !intty)
+ write(2, &input[-1], 1);
+ #ifndef BIT8
+@@ -156,6 +158,7 @@ top:
+ goto top;
+ }
+
++int
+ getchar()
+ {
+ register int c;
+@@ -166,7 +169,8 @@ getchar()
+ return (c);
+ }
+
+-checkjunk(c)
++static void
++checkjunk(int c)
+ {
+
+ if (junkbs == 0 && c == '\b') {
+@@ -175,6 +179,7 @@ checkjunk(c)
+ }
+ }
+
++int
+ getcd()
+ {
+ register int c;
+@@ -188,16 +193,18 @@ again:
+ #else
+ c &= TRIM;
+ #endif
+- if (!inopen)
++ if (!inopen) {
+ if (!globp && c == CTRL('d'))
+ setlastchar('\n');
+ else if (junk(c)) {
+ checkjunk(c);
+ goto again;
+ }
++ }
+ return (c);
+ }
+
++int
+ peekchar()
+ {
+
+@@ -206,6 +213,7 @@ peekchar()
+ return (peekc);
+ }
+
++int
+ peekcd()
+ {
+ if (peekc == 0)
+@@ -220,6 +228,7 @@ peekcd()
+ * This should really be done differently so as to use the whitecnt routine
+ * and also to hack indenting for LISP.
+ */
++static int
+ smunch(col, ocp)
+ register int col;
+ char *ocp;
+@@ -251,13 +260,12 @@ smunch(col, ocp)
+ */
+ static short lastin;
+
++int
+ gettty()
+ {
+ register int c = 0;
+ register char *cp = genbuf;
+ char hadup = 0;
+- int numbline();
+- extern int (*Pline)();
+ int offset = Pline == numbline ? 8 : 0;
+ int ch;
+
+@@ -354,7 +362,7 @@ gettty()
+ return (0);
+ }
+
+-line *
++void
+ setin(addr)
+ line *addr;
+ {
diff --git a/editors/ex/patches/patch-ex__io_c b/editors/ex/patches/patch-ex__io_c
new file mode 100644
index 00000000000..f8eef346ce3
--- /dev/null
+++ b/editors/ex/patches/patch-ex__io_c
@@ -0,0 +1,238 @@
+$NetBSD: patch-ex__io_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- avoid implicit int
+- silence miscellaneous gcc45 warning
+- silence warnings about braces
+- silence warnings about unused arguments
+- use const for string constants
+
+--- ex_io.c~ 2012-12-27 20:24:51.000000000 +0000
++++ ex_io.c
+@@ -109,13 +109,14 @@ long cntnull; /* Count of nulls " */
+ long cntodd; /* Count of non-ascii characters " */
+ #endif
+
+-int checkmodeline __P((char *));
++static void checkmodeline __P((char *));
+
+ /*
+ * Parse file name for command encoded by comm.
+ * If comm is E then command is doomed and we are
+ * parsing just so user won't have to retype the name.
+ */
++void
+ filename(comm)
+ int comm;
+ {
+@@ -168,7 +169,7 @@ filename(comm)
+ break;
+ }
+ }
+- if (hush && comm != 'f' || comm == 'E')
++ if ((hush && comm != 'f') || comm == 'E')
+ return;
+ if (file[0] != 0) {
+ lprintf("\"%s\"", file);
+@@ -196,6 +197,7 @@ filename(comm)
+ * Get the argument words for a command into genbuf
+ * expanding # and %.
+ */
++int
+ getargs()
+ {
+ register int c;
+@@ -271,7 +273,8 @@ filexp:
+ * Scan genbuf for shell metacharacters.
+ * Set is union of v7 shell and csh metas.
+ */
+-gscan()
++static int
++gscan(void)
+ {
+ register char *cp;
+
+@@ -285,6 +288,7 @@ gscan()
+ * Glob the argument words in genbuf, or if no globbing
+ * is implied, just split them up directly.
+ */
++void
+ gglob(gp)
+ struct glob *gp;
+ {
+@@ -372,6 +376,8 @@ gglob(gp)
+ * Parse one filename into file.
+ */
+ struct glob G;
++
++void
+ getone()
+ {
+ register char *str;
+@@ -393,6 +399,7 @@ missing:
+ /*
+ * Are these two really the same inode?
+ */
++static int
+ samei(sp, cp)
+ struct stat *sp;
+ char *cp;
+@@ -408,6 +415,7 @@ samei(sp, cp)
+ * Read a file from the world.
+ * C is command, 'e' if this really an edit (or a recover).
+ */
++void
+ rop(c)
+ int c;
+ {
+@@ -603,6 +611,7 @@ end_ft:
+ rop3(c);
+ }
+
++void
+ rop2()
+ {
+ line *first, *last, *a;
+@@ -638,7 +647,8 @@ rop2()
+ /*
+ * Io is finished, close the unit and print statistics.
+ */
+-iostats()
++static int
++iostats(void)
+ {
+
+ fsync(io);
+@@ -683,6 +693,7 @@ iostats()
+ );
+ }
+
++void
+ rop3(c)
+ int c;
+ {
+@@ -732,10 +743,13 @@ other:
+ * if this is a partial buffer, and distinguish
+ * all cases.
+ */
+-edfile()
++static int
++edfile(void)
+ {
++ /* work around gcc45 warning in eq() because file is a char[] */
++ char *fyle = file;
+
+- if (!edited || !eq(file, savedfile))
++ if (!edited || !eq(fyle, savedfile))
+ return (NOTEDF);
+ return (addr1 == one && addr2 == dol ? EDF : PARTBUF);
+ }
+@@ -743,6 +757,7 @@ edfile()
+ /*
+ * Write a file.
+ */
++void
+ wop(dofname)
+ bool dofname; /* if 1 call filename, else use savedfile */
+ {
+@@ -831,12 +846,13 @@ cre:
+ if (io < 0)
+ syserror();
+ writing = 1;
+- if (hush == 0)
++ if (hush == 0) {
+ if (nonexist)
+ printf(catgets(catd, 1, 115, " [New file]"));
+ else if (value(WRITEANY) && edfile() != EDF)
+ printf(catgets(catd, 1, 116,
+ " [Existing file]"));
++ }
+ break;
+
+ case 2:
+@@ -852,7 +868,10 @@ cre:
+ putfile(0);
+ ignore(iostats());
+ if (c != 2 && addr1 == one && addr2 == dol) {
+- if (eq(file, savedfile))
++ /* work around gcc45 warning in eq() because file is a char[] */
++ char *fyle = file;
++
++ if (eq(fyle, savedfile))
+ edited = 1;
+ synced();
+ }
+@@ -868,6 +887,7 @@ cre:
+ */
+ char *nextip;
+
++int
+ getfile()
+ {
+ register short c;
+@@ -922,6 +942,7 @@ getfile()
+ /*
+ * Write a range onto the io stream.
+ */
++void
+ putfile(isfilter)
+ int isfilter;
+ {
+@@ -930,6 +951,8 @@ int isfilter;
+ register int nib;
+ struct stat statb;
+
++ (void)isfilter;
++
+ a1 = addr1;
+ clrstats();
+ cntln = fixedzero ? 0 : addr2 - a1 + 1;
+@@ -975,10 +998,13 @@ int isfilter;
+ * the edited file then we consider it to have changed since it is
+ * now likely scrambled.
+ */
++void
+ wrerror()
+ {
++ /* work around gcc45 warning in eq() because file is a char[] */
++ char *fyle = file;
+
+- if (eq(file, savedfile) && edited)
++ if (eq(fyle, savedfile) && edited)
+ change();
+ syserror();
+ }
+@@ -990,13 +1016,14 @@ wrerror()
+ short slevel;
+ short ttyindes;
+
++void
+ source(fil, okfail)
+- char *fil;
++ const char *fil;
+ bool okfail;
+ {
+ JMP_BUF osetexit;
+ register int saveinp, ointty, oerrno;
+- char *saveglobp;
++ const char *saveglobp;
+ short savepeekc;
+
+ signal(SIGINT, SIG_IGN);
+@@ -1050,6 +1077,7 @@ source(fil, okfail)
+ /*
+ * Clear io statistics before a read or write.
+ */
++void
+ clrstats()
+ {
+
+@@ -1082,6 +1110,7 @@ char *strrchr();
+ #endif /* !USG3TTY */
+ #endif /* !__STDC__ */
+
++static void
+ checkmodeline(lin)
+ char *lin;
+ {
diff --git a/editors/ex/patches/patch-ex__proto_h b/editors/ex/patches/patch-ex__proto_h
new file mode 100644
index 00000000000..2598cac47fc
--- /dev/null
+++ b/editors/ex/patches/patch-ex__proto_h
@@ -0,0 +1,595 @@
+$NetBSD: patch-ex__proto_h,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- declare void functions void
+- fix up function pointer casting mess
+- don't declare static functions in header files
+- avoid sloppy code that subtracts 1 from the base address of a char[]
+ (which isn't valid)
+
+--- ex_proto.h.orig 2012-12-27 21:58:42.000000000 +0000
++++ ex_proto.h
+@@ -81,352 +81,356 @@
+ #ifdef POSIX_1
+ shand setsig __P((int, shand));
+ #endif
+-int init __P((void));
++void init __P((void));
+ /* ex_addr.c */
+-int setdot __P((void));
+-int setdot1 __P((void));
+-int setcount __P((void));
++void setdot __P((void));
++void setdot1 __P((void));
++void setcount __P((void));
+ int getnum __P((void));
+-int setall __P((void));
+-int setnoaddr __P((void));
++void setall __P((void));
++void setnoaddr __P((void));
+ line *address __P((char *));
+-int setCNL __P((void));
+-int setNAEOL __P((void));
++void setCNL __P((void));
++void setNAEOL __P((void));
+ /* ex_cmds.c */
+-int commands __P((int, int));
++void commands __P((int, int));
+ /* ex_cmds2.c */
+ int cmdreg __P((void));
+ int endcmd __P((int));
+-int eol __P((void));
+-int error __P((char *, ...));
+-int erewind __P((void));
+-int fixol __P((void));
++void eol __P((void));
++void error __P((const char *, ...));
++void erewind __P((void));
++void fixol __P((void));
+ int exclam __P((void));
+-int makargs __P((void));
+-int next __P((void));
+-int newline __P((void));
+-int nomore __P((void));
++void makargs __P((void));
++void next __P((void));
++void newline __P((void));
++void nomore __P((void));
+ int quickly __P((void));
+-int resetflav __P((void));
+-int serror __P((char *, ...));
+-int setflav __P((void));
++void resetflav __P((void));
++void serror __P((const char *, ...));
++void setflav __P((void));
+ int skipend __P((void));
+-int tailspec __P((int));
+-int tail __P((char *));
+-int tail2of __P((char *));
+-int tailprim __P((char *, int, int));
+-int vcontin __P((int));
+-int vnfl __P((void));
++void tailspec __P((int));
++void tail __P((const char *));
++void tail2of __P((const char *));
++void tailprim __P((const char *, int, int));
++void vcontin __P((int));
++void vnfl __P((void));
+ /* ex_cmdsub.c */
+-int append __P((int (*)(), line *));
+-int appendnone __P((void));
+-int pargs __P((void));
+-int delete __P((int));
+-int deletenone __P((void));
+-int squish __P((void));
+-int join __P((int));
+-int move __P((void));
+-int put __P((void));
+-int pragged __P((int));
+-int shift __P((int, int));
+-int tagfind __P((int));
+-int yank __P((void));
+-int zop __P((int));
+-int zop2 __P((int, int));
+-int plines __P((line *, line *, int));
+-int pofix __P((void));
+-int undo __P((int));
+-int mapcmd __P((int, int));
+-int cmdmac __P((int));
++int append __P((int (*)(void), line *));
++void appendnone __P((void));
++void pargs __P((void));
++void delete __P((int));
++void deletenone __P((void));
++void squish __P((void));
++void join __P((int));
++void move __P((void));
++void put __P((void));
++void pragged __P((int));
++void shift __P((int, int));
++void tagfind __P((int));
++void yank __P((void));
++void zop __P((int));
++void zop2 __P((int, int));
++void plines __P((line *, line *, int));
++void pofix __P((void));
++void undo __P((int));
++void mapcmd __P((int, int));
++void cmdmac __P((int));
+ /* ex_data.c */
+ /* ex_extern.c */
+ /* ex_get.c */
+-int ignchar __P((void));
++void ignchar __P((void));
+ int getchar __P((void));
+ int getcd __P((void));
+ int peekchar __P((void));
+ int peekcd __P((void));
+ int gettty __P((void));
+-line *setin __P((line *));
++void setin __P((line *));
+ /* ex_io.c */
+-int filename __P((int));
++void filename __P((int));
+ int getargs __P((void));
+-int getone __P((void));
+-int rop __P((int));
+-int rop2 __P((void));
+-int rop3 __P((int));
+-int wop __P((int));
++void getone __P((void));
++void rop __P((int));
++void rop2 __P((void));
++void rop3 __P((int));
++void wop __P((int));
+ int getfile __P((void));
+-int putfile __P((int));
+-int wrerror __P((void));
+-int source __P((char *, int));
+-int clrstats __P((void));
++void putfile __P((int));
++void wrerror __P((void));
++void source __P((const char *, int));
++void clrstats __P((void));
+ /* ex_put.c */
+-int (*setlist __P((int))) __P((void));
+-int (*setnumb __P((int))) __P((void));
++int (*setlist __P((bool))) __P((int));
++int (*setnumb __P((bool))) __P((int));
+ int listchar __P((int));
+ int normchar __P((int));
+ int numbline __P((int));
+-int normline __P((void));
++int normline __P((int));
+ int putchar __P((int));
+ int termchar __P((int));
+-int flush __P((void));
+-int flush1 __P((void));
+-int fgoto __P((void));
+-int tab __P((int));
+-int noteinp __P((void));
+-int termreset __P((void));
+-int draino __P((void));
+-int flusho __P((void));
+-int putnl __P((void));
++void flush __P((void));
++void flush1 __P((void));
++void fgoto __P((void));
++void tab __P((int));
++void noteinp __P((void));
++void termreset __P((void));
++void draino __P((void));
++void flusho __P((void));
++void putnl __P((void));
+ int putch __P((int));
+-int putpad __P((char *));
+-int setoutt __P((void));
+-int vlprintf __P((char *, va_list));
+-int lprintf __P((char *, ...));
+-int putNFL __P((void));
+-int pstart __P((void));
+-int pstop __P((void));
+-int tostart __P((void));
+-int tostop __P((void));
+-int gTTY __P((int));
+-int noonl __P((void));
++void putpad __P((const char *));
++void setoutt __P((void));
++void vlprintf __P((const char *, va_list));
++void lprintf __P((const char *, ...));
++void putNFL __P((void));
++void pstart __P((void));
++void pstop __P((void));
++void tostart __P((void));
++void tostop __P((void));
++void vcook __P((void));
++void vraw __P((void));
++void gTTY __P((int));
++void noonl __P((void));
+ /* ex_re.c */
+-int global __P((int));
++void global __P((int));
+ int substitute __P((int));
+ int getsub __P((void));
+-char *place __P((char *, char *, char *));
+ int compile __P((int, int));
+ int same __P((int, int));
+ int execute __P((int, line *));
+ int advance __P((char *, char *));
+ /* ex_set.c */
+-int set __P((void));
++void set __P((void));
+ /* ex_subr.c */
+-int any __P((int, char *));
++int any __P((int, const char *));
+ int backtab __P((int));
+-int change __P((void));
++void change __P((void));
+ int column __P((char *));
+-int comment __P((void));
+-int Copy __P((char *, char *, int));
+-int copyw __P((line *, line *, int));
+-int copywR __P((line *, line *, int));
++void comment __P((void));
++void Copy __P((char *, char *, int));
++void copyw __P((line *, line *, int));
++void copywR __P((line *, line *, int));
+ int ctlof __P((int));
+-int dingdong __P((void));
++void dingdong __P((void));
+ int fixindent __P((int));
+-int filioerr __P((char *));
++void filioerr __P((const char *));
+ char *genindent __P((int));
+-int getDOT __P((void));
++void getDOT __P((void));
+ line *getmark __P((int));
+ int getn __P((char *));
+-int ignnEOF __P((void));
++void ignnEOF __P((void));
+ int is_white __P((int));
+ int junk __P((int));
+-int killed __P((void));
+-int killcnt __P((int));
++void killed __P((void));
++void killcnt __P((int));
+ int lineno __P((line *));
+ int lineDOL __P((void));
+ int lineDOT __P((void));
+-int markDOT __P((void));
+-int markpr __P((line *));
++void markDOT __P((void));
++void markpr __P((line *));
+ int markreg __P((int));
+-char *mesg __P((char *));
+-int vmerror __P((char *, va_list));
+-int merror __P((char *, ...));
++char *mesg __P((const char *));
++void vmerror __P((const char *, va_list));
++void merror __P((const char *, ...));
+ int morelines __P((void));
+-int nonzero __P((void));
++void nonzero __P((void));
+ int notable __P((int));
+-int notempty __P((void));
+-int netchHAD __P((int));
+-int netchange __P((int));
++void notempty __P((void));
++void netchHAD __P((int));
++void netchange __P((int));
+ int printof __P((int));
+-int putmark __P((line *));
+-int putmk1 __P((line *, int));
+-char *plural __P((long));
+-int qcolumn __P((char *, char *));
+-int reverse __P((line *, line *));
+-int save __P((line *, line *));
+-int save12 __P((void));
+-int saveall __P((void));
++void putmark __P((line *));
++void putmk1 __P((line *, int));
++const char *plural __P((long));
++int qcolumn2 __P((char *, char *));
++void reverse __P((line *, line *));
++void save __P((line *, line *));
++void save12 __P((void));
++void saveall __P((void));
+ int span __P((void));
+-int synced __P((void));
++void synced __P((void));
+ int skipwh __P((void));
+-int vsmerror __P((char *, va_list));
+-int smerror __P((char *, ...));
++void vsmerror __P((const char *, va_list));
++void smerror __P((const char *, ...));
+ char *strend __P((char *));
+-int strcLIN __P((char *));
+-int syserror __P((void));
++const char *strendk __P((const char *));
++void strcLIN __P((const char *));
++void syserror __P((void));
+ int tabcol __P((int, int));
+ char *vfindcol __P((int));
+ char *vskipwh __P((char *));
+ char *vpastwh __P((char *));
+ int whitecnt __P((char *));
+-int markit __P((line *));
+-int setrupt __P((void));
++void markit __P((line *));
++void setrupt __P((void));
+ int preserve __P((void));
+-int exitex __P((int));
++dead void exitex __P((int));
+ /* ex_tagio.c */
+ int topen __P((char *, char *));
+ int tseek __P((int, off_t));
+ int tgets __P((char *, int, int));
+-int tclose __P((int));
++void tclose __P((int));
+ /* ex_temp.c */
+-int fileinit __P((void));
+-int cleanup __P((int));
+-int get_line __P((line));
++void fileinit __P((void));
++void cleanup __P((int));
++void get_line __P((line));
+ int putline __P((void));
+-int tlaste __P((void));
+-int tflush __P((void));
+-int synctmp __P((void));
+-int TSYNC __P((void));
+-int putreg __P((int));
++void tlaste __P((void));
++void tflush __P((void));
++void synctmp __P((void));
++void TSYNC __P((void));
++void putreg __P((int));
+ int partreg __P((int));
+-int notpart __P((int));
+-int YANKreg __P((int));
+-int kshift __P((void));
+-int regbuf __P((int, char *, int));
++void notpart __P((int));
++void YANKreg __P((int));
++void kshift __P((void));
++void regbuf __P((int, char *, int));
+ /* ex_tty.c */
+-int gettmode __P((void));
+-int setterm __P((char *));
+-int setsize __P((void));
++void gettmode __P((void));
++void setterm __P((const char *));
++void setsize __P((void));
+ char *fkey __P((int));
+-int cost __P((char *));
++int cost __P((const char *));
+ /* ex_unix.c */
+-int unix0 __P((int));
+-int filter __P((int));
+-int recover __P((void));
+-int waitfor __P((void));
+-int revocer __P((void));
++void unix0 __P((int));
++void filter __P((int));
++void recover __P((void));
++void waitfor __P((void));
++void revocer __P((void));
+ /* ex_v.c */
+-int oop __P((void));
+-int vop __P((void));
+-int fixzero __P((void));
+-int savevis __P((void));
+-int undvis __P((void));
+-int vsetsiz __P((int));
++void oop __P((void));
++void vop __P((void));
++void fixzero __P((void));
++void savevis __P((void));
++void undvis __P((void));
++void vsetsiz __P((int));
+ /* ex_vadj.c */
+-int vopen __P((line *, int));
++void vopen __P((line *, int));
+ int vreopen __P((int, int, int));
+ int vglitchup __P((int, int));
+-int vinslin __P((int, int, int));
+-int vrollup __P((int));
+-int vup1 __P((void));
+-int vmoveitup __P((int, int));
+-int vscrap __P((void));
+-int vrepaint __P((char *));
+-int vredraw __P((int));
+-int vsyncCL __P((void));
+-int vsync __P((int));
+-int vsync1 __P((int));
+-int vreplace __P((int, int, int));
+-int sethard __P((void));
+-int vdirty __P((int, int));
++void vinslin __P((int, int, int));
++void vrollup __P((int));
++void vup1 __P((void));
++void vmoveitup __P((int, int));
++void vscrap __P((void));
++void vrepaint __P((char *));
++void vredraw __P((int));
++void vsyncCL __P((void));
++void vsync __P((int));
++void vsync1 __P((int));
++void vreplace __P((int, int, int));
++void sethard __P((void));
++void vdirty __P((int, int));
+ /* ex_version.c */
+-int printver __P((void));
++void printver __P((void));
+ /* ex_vget.c */
+-int ungetkey __P((int));
++void ungetkey __P((int));
+ int getkey __P((void));
+ int peekbr __P((void));
+ int getbr __P((void));
+ int getesc __P((void));
+ int peekkey __P((void));
+ int readecho __P((int));
+-int setLAST __P((void));
+-int addtext __P((char *));
+-int setDEL __P((void));
+-int setBUF __P((cell *));
++void setLAST __P((void));
++void addtext __P((char *));
++void setDEL __P((void));
++void setBUF __P((cell *));
+ int noteit __P((int));
+-int macpush __P((char *, int));
++void macpush __P((const char *, int));
++void vudump __P((const char *s));
+ int vgetcnt __P((void));
+ /* ex_vmain.c */
+-int vmain __P((void));
+-int prepapp __P((void));
+-int vremote __P((int, int (*)(), int));
+-int vsave __P((void));
++void vmain __P((void));
++void prepapp __P((void));
++void vremote __P((int, void (*)(int), int));
++void vsave __P((void));
+ cell *str2cell __P((cell *, char *));
+ char *cell2str __P((char *, cell *));
+ cell *cellcpy __P((cell *, cell *));
+ size_t cellen __P((cell *));
+ cell *cellcat __P((cell *, cell *));
+ /* ex_voper.c */
+-int operate __P((int, int));
++void operate __P((int, int));
+ int find __P((int));
+-int word __P((int (*)(), int));
+-int eend __P((int (*)()));
++int word __P((void (*)(int), int));
++void eend __P((void (*)(int)));
+ int wordof __P((int, char *));
+ int wordch __P((char *));
+ int margin __P((void));
+ /* ex_vops.c */
+-int vUndo __P((void));
+-int vundo __P((int));
+-int vmacchng __P((int));
+-int vnoapp __P((void));
+-int vmove __P((void));
+-int vdelete __P((int));
+-int vchange __P((int));
+-int voOpen __P((int, int));
+-int vshftop __P((void));
+-int vfilter __P((void));
+-int vrep __P((int));
+-int vyankit __P((void));
++void vUndo __P((void));
++void vundo __P((int));
++void vmacchng __P((int));
++void vnoapp __P((void));
++void vmove __P((void));
++void vmove_i __P((int));
++void vdelete __P((int));
++void vchange __P((int));
++void voOpen __P((int, int));
++void vshftop __P((void));
++void vfilter __P((void));
++void vrep __P((int));
++void vyankit __P((void));
+ /* ex_vops2.c */
+-int bleep __P((int, char *));
++void bleep __P((int, char *));
+ int vdcMID __P((void));
+-int takeout __P((cell *));
++void takeout __P((cell *));
+ int ateopr __P((void));
+-int showmode __P((int));
+-int vappend __P((int, int, int));
+-int back1 __P((void));
++void showmode __P((int));
++void vappend __P((int, int, int));
++void back1 __P((void));
+ char *vget_line __P((int, char *, bool *, int));
+-int vdoappend __P((char *));
++void vdoappend __P((const char *));
+ /* ex_vops3.c */
+-int llfind __P((int, int, int (*)(), line *));
++int llfind __P((int, int, void (*)(int), line *));
+ int lindent __P((line *));
+ int lmatchp __P((line *));
+-int lsmatch __P((char *));
++void lsmatch __P((char *));
+ int lnext __P((void));
+-int lbrack __P((int, int (*)()));
++int lbrack __P((int, void (*)(int)));
+ /* ex_vput.c */
+-int vclear __P((void));
+-int vclrcell __P((cell *, int));
+-int vclrlin __P((int, line *));
+-int vclreol __P((void));
+-int vclrech __P((int));
+-int fixech __P((void));
+-int vcursbef __P((char *));
+-int vcursat __P((char *));
+-int vcursaft __P((char *));
+-int vfixcurs __P((void));
+-int vsetcurs __P((char *));
+-int vigoto __P((int, int));
+-int vcsync __P((void));
+-int vgotoCL __P((int));
+-int vgoto __P((int, int));
+-int vprepins __P((void));
++void vclear __P((void));
++void vclrcell __P((cell *, int));
++void vclrlin __P((int, line *));
++void vclreol __P((void));
++void vclrech __P((int));
++void fixech __P((void));
++void vcursbef __P((char *));
++void vcursat __P((char *));
++void vcursaft __P((char *));
++void vfixcurs __P((void));
++void vsetcurs __P((char *));
++void vigoto __P((int, int));
++void vcsync __P((void));
++void vgotoCL __P((int));
++void vgoto __P((int, int));
++void vprepins __P((void));
+ int vputch __P((int));
+ int vinschar __P((int));
+-int goim __P((void));
+-int endim __P((void));
++void goim __P((void));
++void endim __P((void));
+ int vputchar __P((int));
+-int physdc __P((int, int));
++void physdc __P((int, int));
+ /* ex_vwind.c */
+-int vmoveto __P((line *, char *, int));
+-int vjumpto __P((line *, char *, int));
+-int vupdown __P((int, char *));
+-int vup __P((int, int, int));
+-int vdown __P((int, int, int));
+-int vcontext __P((line *, int));
+-int vclean __P((void));
+-int vshow __P((line *, line *));
+-int vroll __P((int));
++void vmoveto __P((line *, char *, int));
++void vjumpto __P((line *, char *, int));
++void vupdown __P((int, char *));
++void vup __P((int, int, int));
++void vdown __P((int, int, int));
++void vcontext __P((line *, int));
++void vclean __P((void));
++void vshow __P((line *, line *));
++void vroll __P((int));
+ int vdepth __P((void));
+-int vnline __P((char *));
++void vnline __P((char *));
+ /* malloc.c */
+ char *poolsbrk __P((intptr_t));
+ /* printf.c */
+ int printf __P((const char *, ...));
+ int vprintf __P((const char *, va_list));
+-char *p_dconv __P((long, char *));
++char *p_dconv __P((unsigned long, char *));
+
+ woid onemt __P((int));
+ woid onhup __P((int));
diff --git a/editors/ex/patches/patch-ex__put_c b/editors/ex/patches/patch-ex__put_c
new file mode 100644
index 00000000000..bdcd03e6669
--- /dev/null
+++ b/editors/ex/patches/patch-ex__put_c
@@ -0,0 +1,530 @@
+$NetBSD: patch-ex__put_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- fix up function pointer casting mess
+- avoid implicit int
+- silence warnings about && and || precedence
+- use const for string constants
+- return values from non-void functions
+- silence warnings about braces
+- declare void functions void
+- remove unused function
+
+--- ex_put.c.orig 2012-12-27 21:58:42.000000000 +0000
++++ ex_put.c
+@@ -99,15 +99,13 @@ static char sccsid[] = "@(#)ex_put.c 1.1
+ * During open/visual, outchar and putchar will be set to
+ * routines in the file ex_vput.c (vputchar, vinschar, etc.).
+ */
+-int (*Outchar)() = termchar;
+-int (*Putchar)() = normchar;
+-int (*Pline)() = normline;
+-
+-int (*
+-setlist(t))()
+- bool t;
++int (*Outchar)(int) = termchar;
++int (*Putchar)(int) = normchar;
++int (*Pline)(int) = normline;
++
++int (*setlist(bool t))(int)
+ {
+- register int (*P)();
++ register int (*P)(int);
+
+ listf = t;
+ P = Putchar;
+@@ -115,15 +113,13 @@ setlist(t))()
+ return (P);
+ }
+
+-int (*
+-setnumb(t))()
+- bool t;
++int (*setnumb(bool t))(int)
+ {
+- register int (*P)();
++ register int (*P)(int);
+
+ numberf = t;
+ P = Pline;
+- Pline = t ? (int(*)()) numbline : (int(*)()) normline;
++ Pline = t ? numbline : normline;
+ return (P);
+ }
+
+@@ -131,6 +127,7 @@ setnumb(t))()
+ * Format c for list mode; leave things in common
+ * with normal print mode to be done by normchar.
+ */
++int
+ listchar(c)
+ register short c;
+ {
+@@ -167,23 +164,24 @@ listchar(c)
+ if (c < ' ' && c != '\n')
+ outchar('^'), c = ctlof(c);
+ #else /* !BIT8 */
+- if (!is_print(c) && c != '\n' || c == DELETE)
++ if ((!is_print(c) && c != '\n') || c == DELETE)
+ c = printof(c);
+ #endif
+ break;
+ }
+- normchar(c);
++ return normchar(c);
+ }
+
+ /*
+ * Format c for printing. Handle funnies of upper case terminals
+ * and crocky hazeltines which don't have ~.
+ */
++int
+ normchar(c)
+ register short c;
+ {
+ #ifdef UCVISUAL
+- register char *colp;
++ register const char *colp;
+
+ if (c == '~' && xHZ) {
+ normchar('\\');
+@@ -196,7 +194,7 @@ normchar(c)
+ if (c & QUOTE) {
+ #else
+ if (c == overbuf)
+- return;
++ return c;
+ if (quot(c)) {
+ #endif
+ switch (c) {
+@@ -231,7 +229,7 @@ normchar(c)
+ putchar('^'), c = ctlof(c);
+ #endif /* !BIT8 */
+ #ifdef UCVISUAL
+- else if (UPPERCASE)
++ else if (UPPERCASE) {
+ if (isupper(c)) {
+ outchar('\\');
+ c = tolower(c);
+@@ -244,11 +242,13 @@ normchar(c)
+ break;
+ }
+ }
++ }
+ #endif /* UCVISUAL */
+ #ifdef BIT8
+ }
+ #endif
+ outchar(c);
++ return c;
+ }
+
+ /*
+@@ -256,8 +256,8 @@ normchar(c)
+ * the printing of the line will erase or otherwise obliterate
+ * the prompt which was printed before. If it won't, do it now.
+ */
+-slobber(c)
+- int c;
++static void
++slobber(int c)
+ {
+
+ shudclob = 0;
+@@ -288,6 +288,7 @@ slobber(c)
+ /*
+ * Print a line with a number.
+ */
++int
+ numbline(i)
+ int i;
+ {
+@@ -295,13 +296,14 @@ numbline(i)
+ if (shudclob)
+ slobber(' ');
+ printf("%6d ", i);
+- normline();
++ return normline(i);
+ }
+
+ /*
+ * Normal line output, no numbering.
+ */
+-normline()
++int
++normline(int arg)
+ {
+ register char *cp;
+
+@@ -320,6 +322,7 @@ normline()
+ putchar('\n');
+ #endif
+ }
++ return arg;
+ }
+
+ /*
+@@ -340,11 +343,12 @@ static bool phadnl;
+ /*
+ * Indirect to current definition of putchar.
+ */
++int
+ putchar(c)
+ int c;
+ {
+
+- (*Putchar)(c);
++ return (*Putchar)(c);
+ }
+
+ /*
+@@ -353,6 +357,7 @@ putchar(c)
+ * Otherwise flush into next level of buffering when
+ * small buffer fills or at a newline.
+ */
++int
+ termchar(c)
+ int c;
+ {
+@@ -368,9 +373,11 @@ termchar(c)
+ fgoto();
+ flush1();
+ }
++ return c;
+ }
+
+-flush2()
++static void
++flush2(void)
+ {
+
+ fgoto();
+@@ -378,6 +385,7 @@ flush2()
+ pstop();
+ }
+
++void
+ flush()
+ {
+
+@@ -390,6 +398,7 @@ flush()
+ * Work here is destroying motion into positions, and then
+ * letting fgoto do the optimized motion.
+ */
++void
+ flush1()
+ {
+ register char *lp;
+@@ -472,16 +481,19 @@ static int plodcnt, plodflg;
+ * and backspace.
+ */
+
+-plodput(c)
++static int
++plodput(int c)
+ {
+
+ if (plodflg)
+ plodcnt--;
+ else
+ putch(c);
++ return c;
+ }
+
+-plod(cnt)
++static int
++plod(int cnt)
+ {
+ register int i, j, k = 0;
+ register int soutcol, soutline;
+@@ -585,7 +597,7 @@ plod(cnt)
+ * If it will be cheaper, or if we can't back up, then send
+ * a return preliminarily.
+ */
+- if (j > i + 1 || outcol > destcol && !BS && !BC) {
++ if (j > i + 1 || (outcol > destcol && !BS && !BC)) {
+ /*
+ * BUG: this doesn't take the (possibly long) length
+ * of xCR into account.
+@@ -764,6 +776,7 @@ out:
+ * column position implied by wraparound or the lack thereof and
+ * rolling up the screen to get destline on the screen.
+ */
++void
+ fgoto()
+ {
+ register int l, c;
+@@ -778,11 +791,12 @@ fgoto()
+ outcol %= TCOLUMNS;
+ if (AM == 0) {
+ while (l > 0) {
+- if (pfast)
++ if (pfast) {
+ if (xCR)
+ tputs(xCR, 0, putch);
+ else
+ putch('\r');
++ }
+ if (xNL)
+ tputs(xNL, 0, putch);
+ else
+@@ -834,7 +848,7 @@ fgoto()
+ outcol = 0;
+ }
+ }
+- if (destline < outline && !(CA && !holdcm || UP != NOSTR))
++ if (destline < outline && !((CA && !holdcm) || UP != NOSTR))
+ destline = outline;
+ if (CA && !holdcm)
+ if (plod(costCM) > 0)
+@@ -851,6 +865,7 @@ fgoto()
+ * Tab to column col by flushing and then setting destcol.
+ * Used by "set all".
+ */
++void
+ tab(col)
+ int col;
+ {
+@@ -865,6 +880,7 @@ tab(col)
+ * Approximate because kill character echoes newline with
+ * no feedback and also because of long input lines.
+ */
++void
+ noteinp()
+ {
+
+@@ -883,6 +899,7 @@ noteinp()
+ * On cursor addressible terminals setting to unknown
+ * will force a cursor address soon.
+ */
++void
+ termreset()
+ {
+
+@@ -906,12 +923,14 @@ termreset()
+ */
+ char *obp = obuf;
+
++void
+ draino()
+ {
+
+ obp = obuf;
+ }
+
++void
+ flusho()
+ {
+
+@@ -921,12 +940,15 @@ flusho()
+ }
+ }
+
++void
+ putnl()
+ {
+
+ putchar('\n');
+ }
+
++#if 0 /* unused */
++void
+ putS(cp)
+ char *cp;
+ {
+@@ -936,8 +958,10 @@ putS(cp)
+ while (*cp)
+ putch(*cp++);
+ }
++#endif
+
+
++int
+ putch(c)
+ int c;
+ {
+@@ -953,6 +977,7 @@ putch(c)
+ #endif
+ if (obp >= &obuf[sizeof obuf])
+ flusho();
++ return c;
+ }
+
+ /*
+@@ -962,8 +987,9 @@ putch(c)
+ /*
+ * Put with padding
+ */
++void
+ putpad(cp)
+- char *cp;
++ const char *cp;
+ {
+
+ flush();
+@@ -973,6 +999,7 @@ putpad(cp)
+ /*
+ * Set output through normal command mode routine.
+ */
++void
+ setoutt()
+ {
+
+@@ -983,27 +1010,29 @@ setoutt()
+ * Printf (temporarily) in list mode.
+ */
+ /*VARARGS2*/
++void
+ #ifndef __STDC__
+ lprintf(cp, dp)
+- char *cp, *dp;
++ const char *cp, *dp;
+ {
+- register int (*P)();
++ register int (*P)(int);
+
+ P = setlist(1);
+ printf(cp, dp);
+ Putchar = P;
+ }
+ #else
+-vlprintf(char *cp, va_list ap)
++vlprintf(const char *cp, va_list ap)
+ {
+- register int (*P)();
++ register int (*P)(int);
+
+ P = setlist(1);
+ vprintf(cp, ap);
+ Putchar = P;
+ }
+
+-lprintf(char *cp, ...)
++void
++lprintf(const char *cp, ...)
+ {
+ va_list ap;
+
+@@ -1016,6 +1045,7 @@ lprintf(char *cp, ...)
+ /*
+ * Newline + flush.
+ */
++void
+ putNFL()
+ {
+
+@@ -1027,8 +1057,8 @@ putNFL()
+ * sTTY: set the tty modes on file descriptor i to be what's
+ * currently in global "tty". (Also use nttyc if needed.)
+ */
+-sTTY(i)
+- int i;
++static void
++sTTY(int i)
+ {
+
+ #ifdef POSIX_1
+@@ -1067,6 +1097,7 @@ sTTY(i)
+ /*
+ * Try to start -nl mode.
+ */
++void
+ pstart()
+ {
+
+@@ -1101,6 +1132,7 @@ pstart()
+ /*
+ * Stop -nl mode.
+ */
++void
+ pstop()
+ {
+
+@@ -1121,7 +1153,8 @@ pstop()
+ */
+ #ifndef TERMIO_S
+ #ifdef TIOCGETC
+-ttcharoff()
++static void
++ttcharoff(void)
+ {
+ nttyc.t_quitc = '\377';
+ if (nttyc.t_startc != CTRL('q'))
+@@ -1138,7 +1171,8 @@ ttcharoff()
+ #endif
+
+ #else /* TERMIO_S */
+-ttcharoff()
++static void
++ttcharoff(void)
+ {
+ #ifdef _PC_VDISABLE
+ long vdis;
+@@ -1239,6 +1273,7 @@ ostart()
+ }
+
+ /* actions associated with putting the terminal in open mode */
++void
+ tostart()
+ {
+ putpad(VS);
+@@ -1275,6 +1310,7 @@ tostart()
+ /*
+ * Stop open, restoring tty modes.
+ */
++void
+ ostop(f)
+ ttymode f;
+ {
+@@ -1290,6 +1326,7 @@ ostop(f)
+ }
+
+ /* Actions associated with putting the terminal in the right mode. */
++void
+ tostop()
+ {
+ putpad(VE);
+@@ -1302,7 +1339,8 @@ tostop()
+ /*
+ * Into cooked mode for interruptibility.
+ */
+-vcook()
++void
++vcook(void)
+ {
+
+ tty.sg_flags &= ~RAW;
+@@ -1312,7 +1350,8 @@ vcook()
+ /*
+ * Back into raw mode.
+ */
+-vraw()
++void
++vraw(void)
+ {
+
+ tty.sg_flags |= RAW;
+@@ -1323,6 +1362,7 @@ vraw()
+ /*
+ * Restore flags to normal state f.
+ */
++void
+ normal(f)
+ ttymode f;
+ {
+@@ -1365,6 +1405,7 @@ setty(f)
+ return (ot);
+ }
+
++void
+ gTTY(i)
+ int i;
+ {
+@@ -1391,6 +1432,7 @@ gTTY(i)
+ /*
+ * Print newline, or blank if in open/visual
+ */
++void
+ noonl()
+ {
+
diff --git a/editors/ex/patches/patch-ex__re_c b/editors/ex/patches/patch-ex__re_c
new file mode 100644
index 00000000000..836f8ccc023
--- /dev/null
+++ b/editors/ex/patches/patch-ex__re_c
@@ -0,0 +1,348 @@
+$NetBSD: patch-ex__re_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- use const for string constants
+- wrap unused function in the proper matching ifdef
+- avoid implicit int
+- fix signed/unsigned mismatch
+- silence warnings about assignments in conditionals
+- silence warnings about && and || precedence
+
+--- ex_re.c~ 2012-12-27 21:58:42.000000000 +0000
++++ ex_re.c
+@@ -82,32 +82,35 @@ static char sccsid[] = "@(#)ex_re.c 1.37
+ #include "ex.h"
+ #include "ex_re.h"
+
+-int compsub __P((int));
+-int dosubcon __P((int, line *));
+-int snote __P((register int, register int));
+-int comprhs __P((int));
+-int confirmed __P((line *));
+-int dosub __P((void));
+-int ugo __P((int, int));
+-int fixcase __P((register int));
+-int cerror __P((char *));
+-int cclass __P((register char *, register int, int));
++static int compsub __P((int));
++static int dosubcon __P((int, line *));
++static void snote __P((register int, register int));
++static void comprhs __P((int));
++static int confirmed __P((line *));
++static void dosub __P((void));
++static void ugo __P((int, int));
++static int fixcase __P((register int));
++static char *place __P((char *, char *, char *));
++static void cerror __P((const char *));
++static int cclass __P((register const char *, register int, int));
+
+ /*
+ * Global, substitute and regular expressions.
+ * Very similar to ed, with some re extensions and
+ * confirmed substitute.
+ */
++void
+ global(k)
+ bool k;
+ {
+ register char *gp;
+ register int c;
+ register line *a1;
+- char globuf[GBSIZE], *Cwas;
++ char globuf[GBSIZE];
++ const char *Cwas;
+ int lines = lineDOL();
+ int oinglobal = inglobal;
+- char *oglobp = globp;
++ const char *oglobp = globp;
+
+ Cwas = Command;
+ /*
+@@ -220,6 +223,7 @@ brkwh:
+ }
+ }
+
++#ifdef notdef /* used above in a notdef block */
+ /*
+ * gdelete: delete inside a global command. Handles the
+ * special case g/r.e./d. All lines to be deleted have
+@@ -228,7 +232,8 @@ brkwh:
+ * and g/r.e./.,/r.e.2/d are not treated specially. There is no
+ * good reason for this except the question: where to you draw the line?
+ */
+-gdelete()
++static void
++gdelete(void)
+ {
+ register line *a1, *a2, *a3;
+
+@@ -250,16 +255,19 @@ gdelete()
+ dot = dol;
+ change();
+ }
++#endif
+
+ bool cflag;
+ int scount, slines, stotal;
+
++int
+ substitute(c)
+ int c;
+ {
+ register line *addr;
+ register int n;
+- int gsubf, hopcount;
++ int gsubf;
++ unsigned hopcount;
+
+ gsubf = compsub(c);
+ if(FIXUNDO)
+@@ -267,7 +275,8 @@ substitute(c)
+ stotal = 0;
+ slines = 0;
+ for (addr = addr1; addr <= addr2; addr++) {
+- scount = hopcount = 0;
++ scount = 0;
++ hopcount = 0;
+ if (dosubcon(0, addr) == 0)
+ continue;
+ if (gsubf) {
+@@ -299,7 +308,8 @@ substitute(c)
+ return (stotal);
+ }
+
+-compsub(ch)
++static int
++compsub(int ch)
+ {
+ register int seof, c, uselastre;
+ static int gsubf;
+@@ -368,6 +378,7 @@ compsub(ch)
+ }
+ }
+
++static void
+ comprhs(seof)
+ int seof;
+ {
+@@ -469,6 +480,7 @@ endrhs:
+ *rp++ = 0;
+ }
+
++int
+ getsub()
+ {
+ register char *p;
+@@ -480,6 +492,7 @@ getsub()
+ return (0);
+ }
+
++static int
+ dosubcon(f, a)
+ bool f;
+ line *a;
+@@ -494,11 +507,12 @@ dosubcon(f, a)
+ return (1);
+ }
+
++static int
+ confirmed(a)
+ line *a;
+ {
+ register int c;
+- char *yesstr = catgets(catd, 1, 249, "y");
++ const char *yesstr = catgets(catd, 1, 249, "y");
+ int okay = -1;
+
+ if (cflag == 0)
+@@ -539,6 +553,7 @@ again:
+ }
+
+ #ifdef notdef
++int
+ ex_getch()
+ {
+ char c;
+@@ -553,6 +568,7 @@ ex_getch()
+ }
+ #endif /* notdef */
+
++static void
+ ugo(cnt, with)
+ int with;
+ int cnt;
+@@ -567,7 +583,8 @@ ugo(cnt, with)
+ int casecnt;
+ bool destuc;
+
+-dosub()
++static void
++dosub(void)
+ {
+ register char *lp, *sp, *rp;
+ int c;
+@@ -585,7 +602,7 @@ dosub()
+ while (lp < loc1)
+ *sp++ = *lp++;
+ casecnt = 0;
+- while (c = *rp++) {
++ while ((c = *rp++) != 0) {
+ #ifdef BIT8
+ c = cuc(c);
+ q = *qp++;
+@@ -661,12 +678,13 @@ ovflo:
+ }
+ lp = loc2;
+ loc2 = sp + (linebuf - genbuf);
+- while (*sp++ = *lp++)
++ while ((*sp++ = *lp++) != 0)
+ if (sp >= &genbuf[LBSIZE])
+ goto ovflo;
+ strcLIN(genbuf);
+ }
+
++static int
+ fixcase(c)
+ register int c;
+ {
+@@ -683,7 +701,7 @@ fixcase(c)
+ return (c);
+ }
+
+-char *
++static char *
+ place(sp, l1, l2)
+ register char *sp, *l1, *l2;
+ {
+@@ -696,6 +714,7 @@ place(sp, l1, l2)
+ return (sp);
+ }
+
++static void
+ snote(total, lines)
+ register int total, lines;
+ {
+@@ -709,16 +728,17 @@ snote(total, lines)
+ flush();
+ }
+
++static void
+ cerror(s)
+- char *s;
++ const char *s;
+ {
+ expbuf[0] = '\0';
+ error(s);
+ }
+
+ #ifdef UXRE
+-refree(rp)
+-struct regexp *rp;
++static void
++refree(struct regexp *rp)
+ {
+ struct regexp *r1 = NULL, *r2 = NULL;
+
+@@ -986,8 +1006,7 @@ complex: cerror(catgets(catd, 1, 139,
+ }
+
+ int
+-execute(gf, addr)
+-line *addr;
++execute(int gf, line *addr)
+ {
+ char *p;
+ int c;
+@@ -1041,6 +1060,7 @@ line *addr;
+ goto complex; \
+ }
+
++int
+ compile(eof, oknl)
+ int eof;
+ int oknl;
+@@ -1123,7 +1143,7 @@ complex:
+ return (eof);
+ }
+ if (value(MAGIC)) {
+- if (c != '*' && (c != '\\' || peekchar() != '{') ||
++ if ((c != '*' && (c != '\\' || peekchar() != '{')) ||
+ ep == expbuf) {
+ lastep = ep;
+ }
+@@ -1349,7 +1369,7 @@ magic:
+ "Badly formed re|Missing closing delimiter for regular expression"));
+
+ case '$':
+- if (peekchar() == eof || peekchar() == EOF || oknl && peekchar() == '\n') {
++ if (peekchar() == eof || peekchar() == EOF || (oknl && peekchar() == '\n')) {
+ *ep++ = CDOL;
+ continue;
+ }
+@@ -1370,17 +1390,19 @@ defchar:
+ }
+ }
+
++int
+ same(a, b)
+ register int a, b;
+ {
+
+- return (a == b || value(IGNORECASE) &&
+- ((islower(a) && toupper(a) == b) || (islower(b) && toupper(b) == a)));
++ return (a == b ||
++ (value(IGNORECASE) &&
++ ((islower(a) && toupper(a) == b) ||
++ (islower(b) && toupper(b) == a))));
+ }
+
+-ecmp(a, b, count)
+- register char *a, *b;
+- register int count;
++static int
++ecmp(register char *a, register char *b, register int count)
+ {
+ while (count--)
+ if (!same(*a++, *b++))
+@@ -1390,8 +1412,8 @@ ecmp(a, b, count)
+
+ char *locs;
+
+-execute(gf, addr)
+- line *addr;
++int
++execute(int gf, line *addr)
+ {
+ register char *p1, *p2;
+ register int c;
+@@ -1437,8 +1459,8 @@ execute(gf, addr)
+ return (0);
+ }
+
+-getrnge(str)
+- register char *str;
++static void
++getrnge(register char *str)
+ {
+ low = *str++ & 0377;
+ siz = (*str & 0377) == 255 ? 20000 : (*str & 0377) - low;
+@@ -1446,6 +1468,7 @@ getrnge(str)
+
+ #define uletter(c) (isalpha(c) || c == '_')
+
++int
+ advance(lp, ep)
+ register char *lp, *ep;
+ {
+@@ -1628,8 +1651,9 @@ star:
+ }
+ }
+
++static int
+ cclass(set, c, af)
+- register char *set;
++ register const char *set;
+ register int c;
+ int af;
+ {
diff --git a/editors/ex/patches/patch-ex__set_c b/editors/ex/patches/patch-ex__set_c
new file mode 100644
index 00000000000..a0a1537530f
--- /dev/null
+++ b/editors/ex/patches/patch-ex__set_c
@@ -0,0 +1,128 @@
+$NetBSD: patch-ex__set_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- avoid implicit int
+- use const for string constants
+- silence warnings about && and || precedence
+
+--- ex_set.c~ 2012-12-27 21:58:42.000000000 +0000
++++ ex_set.c
+@@ -88,18 +88,19 @@ static char sccsid[] = "@(#)ex_set.c 1.8
+ */
+ char optname[ONMSZ];
+
+-int setend __P((void));
+-int prall __P((void));
+-int propts __P((void));
+-int propt __P((register struct option *));
++static int setend __P((void));
++static void prall __P((void));
++static void propts __P((void));
++static void propt __P((register struct option *));
+
++void
+ set()
+ {
+- register char *cp;
++ register const char *cp;
++ register char *cp2;
+ register struct option *op;
+ register int c;
+ bool no;
+- extern short ospeed;
+
+ setnoaddr();
+ if (skipend()) {
+@@ -109,12 +110,12 @@ set()
+ return;
+ }
+ do {
+- cp = optname;
++ cp2 = optname;
+ do {
+- if (cp < &optname[ONMSZ - 2])
+- *cp++ = getchar();
++ if (cp2 < &optname[ONMSZ - 2])
++ *cp2++ = getchar();
+ } while (isalnum(peekchar()));
+- *cp = 0;
++ *cp2 = 0;
+ cp = optname;
+ if (eq("all", cp)) {
+ if (inopen)
+@@ -146,7 +147,7 @@ dontset:
+ cp = "window";
+ }
+ for (op = options; op < &options[NOPTS]; op++)
+- if (eq(op->oname, cp) || op->oabbrev && eq(op->oabbrev, cp))
++ if (eq(op->oname, cp) || (op->oabbrev && eq(op->oabbrev, cp)))
+ break;
+ if (op->oname == 0)
+ serror(catgets(catd, 1, 159,
+@@ -193,18 +194,18 @@ printone:
+
+ case STRING:
+ case OTERM:
+- cp = optname;
++ cp2 = optname;
+ while (!setend()) {
+- if (cp >= &optname[ONMSZ])
++ if (cp2 >= &optname[ONMSZ])
+ error(catgets(catd, 1, 163,
+ "String too long@in option assignment"));
+ /* adb change: allow whitepace in strings */
+- if( (*cp = getchar()) == '\\')
++ if( (*cp2 = getchar()) == '\\')
+ if( peekchar() != EOF)
+- *cp = getchar();
+- cp++;
++ *cp2 = getchar();
++ cp2++;
+ }
+- *cp = 0;
++ *cp2 = 0;
+ if (op->otype == OTERM) {
+ /*
+ * At first glance it seems like we shouldn't care if the terminal type
+@@ -237,13 +238,15 @@ setnext:
+ eol();
+ }
+
++static int
+ setend()
+ {
+
+ return (is_white(peekchar()) || endcmd(peekchar()));
+ }
+
+-prall()
++static void
++prall(void)
+ {
+ register int incr = (NOPTS + 2) / 3;
+ register int rows = incr;
+@@ -261,7 +264,8 @@ prall()
+ }
+ }
+
+-propts()
++static void
++propts(void)
+ {
+ register struct option *op;
+
+@@ -292,10 +296,10 @@ propts()
+ flush();
+ }
+
+-propt(op)
+- register struct option *op;
++static void
++propt(register struct option *op)
+ {
+- register char *name;
++ register const char *name;
+
+ name = op->oname;
+
diff --git a/editors/ex/patches/patch-ex__subr_c b/editors/ex/patches/patch-ex__subr_c
new file mode 100644
index 00000000000..599b88f6ee2
--- /dev/null
+++ b/editors/ex/patches/patch-ex__subr_c
@@ -0,0 +1,686 @@
+$NetBSD: patch-ex__subr_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- use standard headers
+- avoid sloppy code that subtracts 1 from the base address of a char[]
+ (which isn't valid) (although this could be tidied further)
+- avoid implicit int
+- silence warnings about && and || precedence
+- declare void functions void
+- use const for string constants
+- use <ctype.h> functions properly
+- fix up function pointer casting mess
+- silence warnings about unused arguments
+- teach it about dead functions
+
+--- ex_subr.c~ 2012-12-27 21:58:42.000000000 +0000
++++ ex_subr.c
+@@ -79,27 +79,33 @@ static char sccsid[] = "@(#)ex_subr.c 1.
+
+ /* from ex_subr.c 7.10.1 (2.11BSD) 1996/3/22 */
+
++#include <sys/ioctl.h>
++
+ #include "ex.h"
+ #include "ex_re.h"
+ #include "ex_tty.h"
+ #include "ex_vis.h"
+
++static int qcolumn __P((char *, char *));
++
+ /*
+ * Random routines, in alphabetical order.
+ */
+
++int
+ any(c, s)
+ int c;
+- register char *s;
++ register const char *s;
+ {
+ register int x;
+
+- while (x = *s++)
++ while ((x = *s++) != 0)
+ if (x == c)
+ return (1);
+ return (0);
+ }
+
++int
+ backtab(i)
+ register int i;
+ {
+@@ -114,6 +120,7 @@ backtab(i)
+ return (i);
+ }
+
++void
+ change()
+ {
+
+@@ -128,6 +135,7 @@ change()
+ * characters through position cp of the
+ * current line.
+ */
++int
+ column(cp)
+ register char *cp;
+ {
+@@ -141,6 +149,7 @@ column(cp)
+ * Ignore a comment to the end of the line.
+ * This routine eats the trailing newline so don't call newline().
+ */
++void
+ comment()
+ {
+ register int c;
+@@ -152,6 +161,7 @@ comment()
+ ungetchar(c);
+ }
+
++void
+ Copy(to, from, size)
+ register char *from, *to;
+ register int size;
+@@ -163,6 +173,7 @@ Copy(to, from, size)
+ while (--size > 0);
+ }
+
++void
+ copyw(to, from, size)
+ register line *from, *to;
+ register int size;
+@@ -174,6 +185,7 @@ copyw(to, from, size)
+ while (--size > 0);
+ }
+
++void
+ copywR(to, from, size)
+ register line *from, *to;
+ register int size;
+@@ -183,6 +195,7 @@ copywR(to, from, size)
+ to[size] = from[size];
+ }
+
++int
+ ctlof(c)
+ int c;
+ {
+@@ -190,6 +203,7 @@ ctlof(c)
+ return (c == DELETE ? '?' : c | ('A' - 1));
+ }
+
++void
+ dingdong()
+ {
+
+@@ -199,6 +213,7 @@ dingdong()
+ putch('\207');
+ }
+
++int
+ fixindent(indent)
+ int indent;
+ {
+@@ -215,8 +230,9 @@ fixindent(indent)
+ return (i);
+ }
+
++void
+ filioerr(cp)
+- char *cp;
++ const char *cp;
+ {
+ register int oerrno = errno;
+
+@@ -238,6 +254,7 @@ genindent(indent)
+ return (cp);
+ }
+
++void
+ getDOT()
+ {
+
+@@ -257,6 +274,7 @@ getmark(c)
+ return (0);
+ }
+
++int
+ getn(cp)
+ register char *cp;
+ {
+@@ -269,6 +287,7 @@ getn(cp)
+ return (i);
+ }
+
++void
+ ignnEOF()
+ {
+ register int c = getchar();
+@@ -279,6 +298,7 @@ ignnEOF()
+ comment();
+ }
+
++int
+ is_white(c)
+ int c;
+ {
+@@ -286,11 +306,12 @@ is_white(c)
+ #ifndef BIT8
+ return (c == ' ' || c == '\t');
+ #else
+- return (isspace(c) && c != '\n' && c != '\r'
++ return (isspace((unsigned char)c) && c != '\n' && c != '\r'
+ && c != '\f' && c != '\v');
+ #endif
+ }
+
++int
+ junk(c)
+ register int c;
+ {
+@@ -315,12 +336,14 @@ junk(c)
+ }
+ }
+
++void
+ killed()
+ {
+
+ killcnt(addr2 - addr1 + 1);
+ }
+
++void
+ killcnt(cnt)
+ register int cnt;
+ {
+@@ -343,6 +366,7 @@ killcnt(cnt)
+ putNFL();
+ }
+
++int
+ lineno(a)
+ line *a;
+ {
+@@ -350,24 +374,28 @@ lineno(a)
+ return (a - zero);
+ }
+
++int
+ lineDOL()
+ {
+
+ return (lineno(dol));
+ }
+
++int
+ lineDOT()
+ {
+
+ return (lineno(dot));
+ }
+
++void
+ markDOT()
+ {
+
+ markpr(dot);
+ }
+
++void
+ markpr(which)
+ line *which;
+ {
+@@ -379,6 +407,7 @@ markpr(which)
+ }
+ }
+
++int
+ markreg(c)
+ register int c;
+ {
+@@ -397,12 +426,13 @@ markreg(c)
+ * All others map to themselves.
+ */
+ char *
+-mesg(str)
+- register char *str;
++mesg(arg)
++ const char *arg;
+ {
++ register char *str;
+ register char *cp;
+
+- str = strcpy(genbuf, str);
++ str = strcpy(genbuf, arg);
+ for (cp = str; *cp; cp++)
+ switch (*cp) {
+
+@@ -422,12 +452,13 @@ mesg(str)
+ return (str);
+ }
+
++static void
+ merror1(seekpt)
+ #ifdef VMUNIX
+- char *seekpt;
++ const char *seekpt;
+ #else
+ # ifdef lint
+- char *seekpt;
++ const char *seekpt;
+ # else
+ int seekpt;
+ # endif
+@@ -444,20 +475,21 @@ merror1(seekpt)
+ }
+
+ /*VARARGS2*/
++void
+ #ifndef __STDC__
+ merror(seekpt, i)
+ #ifdef VMUNIX
+- char *seekpt;
++ const char *seekpt;
+ #else
+ # ifdef lint
+- char *seekpt;
++ const char *seekpt;
+ # else
+ int seekpt;
+ # endif
+ #endif
+ int i;
+ #else
+-vmerror(char *seekpt, va_list ap)
++vmerror(const char *seekpt, va_list ap)
+ #endif
+ {
+
+@@ -482,7 +514,8 @@ vmerror(char *seekpt, va_list ap)
+ }
+
+ #ifdef __STDC__
+-merror(char *cp, ...)
++void
++merror(const char *cp, ...)
+ {
+ va_list ap;
+
+@@ -494,6 +527,7 @@ merror(char *cp, ...)
+ }
+ #endif
+
++int
+ morelines()
+ {
+ #ifdef _SC_PAGESIZE
+@@ -517,6 +551,7 @@ morelines()
+ #endif /* !_SC_PAGESIZE */
+ }
+
++void
+ nonzero()
+ {
+
+@@ -527,6 +562,7 @@ nonzero()
+ }
+ }
+
++int
+ notable(i)
+ int i;
+ {
+@@ -534,7 +570,7 @@ notable(i)
+ return (hush == 0 && !inglobal && i > value(REPORT));
+ }
+
+-
++void
+ notempty()
+ {
+
+@@ -542,7 +578,7 @@ notempty()
+ error(catgets(catd, 1, 173, "No lines@in the buffer"));
+ }
+
+-
++void
+ netchHAD(cnt)
+ int cnt;
+ {
+@@ -550,10 +586,11 @@ netchHAD(cnt)
+ netchange(lineDOL() - cnt);
+ }
+
++void
+ netchange(i)
+ register int i;
+ {
+- register char *cp;
++ register const char *cp;
+
+ if (i > 0)
+ notesgn = cp = catgets(catd, 1, 174, "more ");
+@@ -575,10 +612,11 @@ netchange(i)
+ * Print an escape sequence corresponding to c.
+ */
+ #ifdef BIT8
++int
+ printof(c)
+ int c;
+ {
+- char *nums = "01234567";
++ const char *nums = "01234567";
+ int d;
+
+ if (c < 040 || c == DELETE) {
+@@ -597,6 +635,7 @@ printof(c)
+ }
+ #endif
+
++void
+ putmark(addr)
+ line *addr;
+ {
+@@ -604,6 +643,7 @@ putmark(addr)
+ putmk1(addr, putline());
+ }
+
++void
+ putmk1(addr, n)
+ register line *addr;
+ int n;
+@@ -620,7 +660,7 @@ putmk1(addr, n)
+ *addr = n | oldglobmk;
+ }
+
+-char *
++const char *
+ plural(i)
+ long i;
+ {
+@@ -629,14 +669,15 @@ plural(i)
+ : catgets(catd, 1, 179, "s"));
+ }
+
+-int qcount();
++static int qcount(int c);
+ short vcntcol;
+
++static int
+ qcolumn(lim, gp)
+ register char *lim, *gp;
+ {
+ register int x = 0;
+- int (*OO)();
++ int (*OO)(int);
+
+ OO = Outchar;
+ Outchar = qcount;
+@@ -653,18 +694,33 @@ qcolumn(lim, gp)
+ return (vcntcol);
+ }
+
++/*
++ * Like qcolumn() but doesn't require subtracting 1 from the first
++ * argument before calling it.
++ */
+ int
++qcolumn2(char *lim, char *gp)
++{
++ if (lim != NULL) {
++ lim--;
++ }
++ return qcolumn(lim, gp);
++}
++
++static int
+ qcount(c)
+ int c;
+ {
+
+ if (c == '\t') {
+ vcntcol += value(TABSTOP) - vcntcol % value(TABSTOP);
+- return;
++ return c;
+ }
+ vcntcol++;
++ return c;
+ }
+
++void
+ reverse(a1, a2)
+ register line *a1, *a2;
+ {
+@@ -679,6 +735,7 @@ reverse(a1, a2)
+ }
+ }
+
++void
+ save(a1, a2)
+ line *a1;
+ register line *a2;
+@@ -714,24 +771,28 @@ save(a1, a2)
+ #endif
+ }
+
++void
+ save12()
+ {
+
+ save(addr1, addr2);
+ }
+
++void
+ saveall()
+ {
+
+ save(one, dol);
+ }
+
++int
+ span()
+ {
+
+ return (addr2 - addr1 + 1);
+ }
+
++void
+ synced()
+ {
+
+@@ -740,7 +801,7 @@ synced()
+ xchng = 0;
+ }
+
+-
++int
+ skipwh()
+ {
+ register int wh;
+@@ -754,17 +815,18 @@ skipwh()
+ }
+
+ /*VARARGS2*/
++void
+ #ifndef __STDC__
+ smerror(seekpt, cp)
+ #ifdef lint
+- char *seekpt;
++ const char *seekpt;
+ #else
+ int seekpt;
+ #endif
+- char *cp;
++ const char *cp;
+ {
+ #else
+-vsmerror(char *seekpt, va_list ap)
++vsmerror(const char *seekpt, va_list ap)
+ {
+
+ #endif
+@@ -786,7 +848,8 @@ vsmerror(char *seekpt, va_list ap)
+ }
+
+ #ifdef __STDC__
+-smerror(char *seekpt, ...)
++void
++smerror(const char *seekpt, ...)
+ {
+ va_list ap;
+
+@@ -808,13 +871,25 @@ strend(cp)
+ return (cp);
+ }
+
++const char *
++strendk(cp)
++ register const char *cp;
++{
++
++ while (*cp)
++ cp++;
++ return (cp);
++}
++
++void
+ strcLIN(dp)
+- char *dp;
++ const char *dp;
+ {
+
+ CP(linebuf, dp);
+ }
+
++void
+ syserror()
+ {
+
+@@ -828,6 +903,7 @@ syserror()
+ * hitting a tab, where tabs are set every ts columns. Work right for
+ * the case where col > TCOLUMNS, even if ts does not divide TCOLUMNS.
+ */
++int
+ tabcol(col, ts)
+ int col, ts;
+ {
+@@ -847,10 +923,10 @@ vfindcol(i)
+ int i;
+ {
+ register char *cp;
+- register int (*OO)() = Outchar;
++ register int (*OO)(int) = Outchar;
+
+ Outchar = qcount;
+- ignore(qcolumn(linebuf - 1, NOSTR));
++ ignore(qcolumn2(linebuf, NOSTR));
+ for (cp = linebuf; *cp && vcntcol < i; cp++)
+ putchar(*cp);
+ if (cp != linebuf)
+@@ -880,6 +956,7 @@ vpastwh(cp)
+ return (cp);
+ }
+
++int
+ whitecnt(cp)
+ register char *cp;
+ {
+@@ -911,13 +988,14 @@ Ignore(a)
+ }
+
+ Ignorf(a)
+- int (*a)();
++ int (*a)(int);
+ {
+
+ a = a;
+ }
+ #endif
+
++void
+ markit(addr)
+ line *addr;
+ {
+@@ -937,10 +1015,12 @@ markit(addr)
+ */
+ int _ovno;
+ woid
+-onemt(signum)
++onemt(int signum)
+ {
+ int oovno;
+
++ (void)signum;
++
+ #ifndef POSIX_1
+ signal(SIGEMT, onemt);
+ #endif
+@@ -963,8 +1043,9 @@ onemt(signum)
+ * are not removed.
+ */
+ woid
+-onhup(signum)
++onhup(int signum)
+ {
++ (void)signum;
+
+ /*
+ * USG tty driver can send multiple HUP's!!
+@@ -993,9 +1074,11 @@ onhup(signum)
+ * suppressed in visual mode).
+ */
+ woid
+-onintr(signum)
++onintr(int signum)
+ {
+
++ (void)signum;
++
+ #ifndef POSIX_1
+ #ifndef CBREAK
+ signal(SIGINT, onintr);
+@@ -1022,6 +1105,7 @@ onintr(signum)
+ * In some critical sections we turn interrupts off,
+ * but not very often.
+ */
++void
+ setrupt()
+ {
+
+@@ -1040,6 +1124,7 @@ setrupt()
+ }
+ }
+
++int
+ preserve()
+ {
+
+@@ -1063,6 +1148,8 @@ preserve()
+ }
+
+ #ifndef V6
++dead
++void
+ exitex(i)
+ int i;
+ {
+@@ -1081,7 +1168,7 @@ exitex(i)
+ * We have just gotten a susp. Suspend and prepare to resume.
+ */
+ woid
+-onsusp(signum)
++onsusp(int signum)
+ {
+ ttymode f;
+ /* int omask; */
+@@ -1092,6 +1179,8 @@ onsusp(signum)
+ sigset_t set;
+ #endif
+
++ (void)signum;
++
+ f = setty(normf);
+ vnfl();
+ putpad(TE);
diff --git a/editors/ex/patches/patch-ex__tagio_c b/editors/ex/patches/patch-ex__tagio_c
new file mode 100644
index 00000000000..fc4314e0b67
--- /dev/null
+++ b/editors/ex/patches/patch-ex__tagio_c
@@ -0,0 +1,63 @@
+$NetBSD: patch-ex__tagio_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- avoid implicit int
+- don't misuse NULL
+- declare void functions void
+
+--- ex_tagio.c~ 2003-09-03 19:53:02.000000000 +0000
++++ ex_tagio.c
+@@ -96,6 +96,7 @@ static int bcnt = 0;
+ static int b_size = MAXBSIZE;
+ static char *ibuf;
+
++int
+ topen(file, buf)
+ char *file, *buf;
+ {
+@@ -116,6 +117,7 @@ char *file, *buf;
+ return(fd);
+ }
+
++int
+ tseek(fd, off)
+ int fd;
+ off_t off;
+@@ -134,6 +136,7 @@ off_t off;
+ return(0);
+ }
+
++int
+ tgets(buf, cnt, fd)
+ register char *buf;
+ int cnt;
+@@ -145,19 +148,19 @@ int fd;
+ cc = offset;
+ if (cc == -1) {
+ if ((bcnt = read(fd, ibuf, b_size)) <= 0)
+- return (NULL);
++ return 0;
+ cc = 0;
+ block = 0;
+ }
+ if (bcnt == 0) /* EOF */
+- return(NULL);
++ return 0;
+ cp = ibuf + cc;
+ while (--cnt > 0) {
+ if (++cc > bcnt) {
+ block += b_size;
+ if ((bcnt = read(fd, ibuf, b_size)) <= 0) {
+ offset = cc;
+- return (NULL);
++ return 0;
+ }
+ cp = ibuf;
+ cc = 1;
+@@ -170,6 +173,7 @@ int fd;
+ return(1);
+ }
+
++void
+ tclose(fd)
+ int fd;
+ {
diff --git a/editors/ex/patches/patch-ex__temp_c b/editors/ex/patches/patch-ex__temp_c
new file mode 100644
index 00000000000..f3350266a31
--- /dev/null
+++ b/editors/ex/patches/patch-ex__temp_c
@@ -0,0 +1,255 @@
+$NetBSD: patch-ex__temp_c,v 1.1 2012/12/28 03:03:08 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- avoid implicit int
+- silence warnings about assignments in conditionals
+- silence signed/unsigned compiler warning
+- return values from non-void functions
+
+--- ex_temp.c~ 2012-12-27 21:58:41.000000000 +0000
++++ ex_temp.c
+@@ -106,11 +106,14 @@ int havetmp;
+ int tfile = -1;
+ int rfile = -1;
+
+-int YANKline __P((void));
+-int rbflush __P((void));
+-int blkio __P((bloc, char *, ssize_t (*) __P((int, void *, size_t))));
+-char *getblock __P((line, int));
++static void YANKline __P((void));
++static void rbflush __P((void));
++static void blkio __P((bloc, char *, ssize_t (*) __P((int, void *, size_t))));
++static char *getblock __P((line, int));
++static ssize_t shread __P((void));
++static int getREG __P((void));
+
++void
+ fileinit()
+ {
+ register char *p;
+@@ -196,6 +199,7 @@ dumbness:
+ /* brk((char *)fendcore); */
+ }
+
++void
+ cleanup(all)
+ bool all;
+ {
+@@ -213,6 +217,7 @@ cleanup(all)
+ }
+ }
+
++void
+ get_line(tl)
+ line tl;
+ {
+@@ -223,13 +228,14 @@ get_line(tl)
+ bp = getblock(tl, READ);
+ nl = nleft;
+ tl &= ~OFFMSK;
+- while (*lp++ = *bp++)
++ while ((*lp++ = *bp++) != 0)
+ if (--nl == 0) {
+ bp = getblock(tl += INCRMT, READ);
+ nl = nleft;
+ }
+ }
+
++int
+ putline()
+ {
+ register char *bp, *lp;
+@@ -243,7 +249,7 @@ putline()
+ bp = getblock(tl, WRITE);
+ nl = nleft;
+ tl &= ~OFFMSK;
+- while (*bp = *lp++) {
++ while ((*bp = *lp++) != 0) {
+ if (*bp++ == '\n') {
+ *--bp = 0;
+ linebp = lp;
+@@ -264,7 +270,7 @@ ssize_t read __P((int, void *, size_t));
+ ssize_t write __P((int, void *, size_t));
+ #endif
+
+-char *
++static char *
+ getblock(atl, iof)
+ line atl;
+ int iof;
+@@ -321,8 +327,8 @@ char incorb[INCORB+1][BUFSIZ];
+ bloc stilinc; /* up to here not written yet */
+ #endif
+
++static void
+ #ifdef __STDC__
+-int
+ blkio(bloc b, char *buf, ssize_t (*iofcn)(int, void *, size_t))
+ #else /* !__STDC__ */
+ blkio(b, buf, iofcn)
+@@ -353,6 +359,7 @@ blkio(b, buf, iofcn)
+ }
+
+ #ifdef INCORB
++void
+ tlaste()
+ {
+
+@@ -360,6 +367,7 @@ tlaste()
+ dirtcnt = 0;
+ }
+
++void
+ tflush()
+ {
+ bbloc i = stilinc;
+@@ -375,6 +383,7 @@ tflush()
+ * Synchronize the state of the temporary file in case
+ * a crash occurs.
+ */
++void
+ synctmp()
+ {
+ register bbloc cnt;
+@@ -438,6 +447,7 @@ oops:
+ #endif
+ }
+
++void
+ TSYNC()
+ {
+
+@@ -493,6 +503,7 @@ short rblock;
+ short rnext;
+ char *rbufcp;
+
++static void
+ regio(b, iofcn)
+ short b;
+ ssize_t (*iofcn) __P((int, void *, size_t));
+@@ -542,11 +553,12 @@ oops:
+ rblock = b;
+ }
+
++static int
+ REGblk()
+ {
+ register int i, j, m;
+
+- for (i = 0; i < sizeof rused / sizeof rused[0]; i++) {
++ for (i = 0; i < (int)(sizeof rused / sizeof rused[0]); i++) {
+ m = (rused[i] ^ 0177777) & 0177777;
+ if (i == 0)
+ m &= ~1;
+@@ -562,10 +574,11 @@ REGblk()
+ }
+ }
+ error(catgets(catd, 1, 186, "Out of register space (ugh)"));
+- /*NOTREACHED*/
++ /* XXX what do we do here? */
++ return 0;
+ }
+
+-struct strreg *
++static struct strreg *
+ mapreg(c)
+ register int c;
+ {
+@@ -575,8 +588,7 @@ mapreg(c)
+ return (isdigit(c) ? &strregs[('z'-'a'+1)+(c-'0')] : &strregs[c-'a']);
+ }
+
+-ssize_t shread();
+-
++static void
+ KILLreg(c)
+ register int c;
+ {
+@@ -598,8 +610,8 @@ KILLreg(c)
+ }
+
+ /*VARARGS*/
+-ssize_t
+-shread()
++static ssize_t
++shread(void)
+ {
+ struct front { short a; short b; };
+
+@@ -608,9 +620,8 @@ shread()
+ return (0);
+ }
+
+-int getREG();
+-
+-putreg(c)
++void
++putreg(int c)
+ {
+ register line *odot = dot;
+ register line *odol = dol;
+@@ -651,12 +662,14 @@ putreg(c)
+ notecnt = cnt;
+ }
+
+-partreg(c)
++int
++partreg(int c)
+ {
+
+ return (mapreg(c)->rg_flags);
+ }
+
++void
+ notpart(c)
+ register int c;
+ {
+@@ -665,6 +678,7 @@ notpart(c)
+ mapreg(c)->rg_flags = 0;
+ }
+
++static int
+ getREG()
+ {
+ register char *lp = linebuf;
+@@ -691,6 +705,7 @@ getREG()
+ }
+ }
+
++void
+ YANKreg(c)
+ register int c;
+ {
+@@ -729,6 +744,7 @@ YANKreg(c)
+ CP(linebuf,savelb);
+ }
+
++void
+ kshift()
+ {
+ register int i;
+@@ -738,6 +754,7 @@ kshift()
+ copy(mapreg(i+1), mapreg(i), sizeof (struct strreg));
+ }
+
++static void
+ YANKline()
+ {
+ register char *lp = linebuf;
+@@ -764,6 +781,7 @@ YANKline()
+ *rbufcp = 0;
+ }
+
++static void
+ rbflush()
+ {
+ register struct strreg *sp = strp;
+@@ -778,6 +796,7 @@ rbflush()
+ }
+
+ /* Register c to char buffer buf of size buflen */
++void
+ regbuf(c, buf, buflen)
+ char c;
+ char *buf;
diff --git a/editors/ex/patches/patch-ex__tty_c b/editors/ex/patches/patch-ex__tty_c
new file mode 100644
index 00000000000..497f08fb345
--- /dev/null
+++ b/editors/ex/patches/patch-ex__tty_c
@@ -0,0 +1,147 @@
+$NetBSD: patch-ex__tty_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- use standard headers
+- declare local functions (and data) static
+- declare void functions void
+- don't put function declarations inside other functions
+- return values from non-void functions
+
+--- ex_tty.c~ 2003-03-18 20:29:07.000000000 +0000
++++ ex_tty.c
+@@ -79,14 +79,16 @@ static char sccsid[] = "@(#)ex_tty.c 1.1
+
+ /* from ex_tty.c 7.10.1 (2.11BSD GTE) 12/9/94 */
+
++#include <sys/ioctl.h>
++
+ #include "ex.h"
+ #include "ex_tty.h"
+
+ int ATTN = DELETE;
+
+-int gettmode __P((void));
+-char *gettlongname __P((char *, char *));
+-int zap __P((void));
++static const char *gettlongname __P((char *, const char *));
++static void zap __P((void));
++static int countnum(int ch);
+
+ /*
+ * Terminal type initialization routines,
+@@ -95,6 +97,7 @@ int zap __P((void));
+ */
+ /* short ospeed = -1; mjm: def also in tputs.c of termcap.a */
+
++void
+ gettmode()
+ {
+ #ifdef POSIX_1
+@@ -171,7 +174,7 @@ gettmode()
+ }
+
+ char *xPC;
+-char **sstrs[] = {
++static char **sstrs[] = {
+ &AL, &BC, &BT, &CD, &CE, &CL, &CM, &xCR, &xCS, &DC, &DL, &DM, &DO,
+ &ED, &EI, &F0, &F1, &F2, &F3, &F4, &F5, &F6, &F7, &F8, &F9,
+ &HO, &IC, &IM, &IP, &KD, &KE, &KH, &KL, &KR, &KS, &KU, &LL, &ND, &xNL,
+@@ -189,13 +192,17 @@ bool *sflags[] = {
+ char **fkeys[10] = {
+ &F0, &F1, &F2, &F3, &F4, &F5, &F6, &F7, &F8, &F9
+ };
++
++void
+ setterm(type)
+- char *type;
++ const char *type;
+ {
+- char *tgoto();
+ register int unknown;
+ char ltcbuf[TCBUFSIZE];
+
++ /* to avoid needing to make all the terminal strings const */
++ static char empty[] = "";
++
+ if (type[0] == 0)
+ type = "xx";
+ unknown = 0;
+@@ -221,13 +228,13 @@ setterm(type)
+ * Handle funny termcap capabilities
+ */
+ if (xCS && SC && RC) {
+- if (AL==NULL) AL="";
+- if (DL==NULL) DL="";
++ if (AL==NULL) AL=empty;
++ if (DL==NULL) DL=empty;
+ }
+- if (AL_PARM && AL==NULL) AL="";
+- if (DL_PARM && DL==NULL) DL="";
+- if (IC && IM==NULL) IM="";
+- if (IC && EI==NULL) EI="";
++ if (AL_PARM && AL==NULL) AL=empty;
++ if (DL_PARM && DL==NULL) DL=empty;
++ if (IC && IM==NULL) IM=empty;
++ if (IC && EI==NULL) EI=empty;
+ if (!GT) BT=NULL; /* If we can't tab, we can't backtab either */
+
+ #ifndef USG3TTY
+@@ -313,6 +320,7 @@ setterm(type)
+ "%s: Unknown terminal type"), type);
+ }
+
++void
+ setsize()
+ {
+ register int l, i;
+@@ -369,9 +377,10 @@ setsize()
+ TLINES = 2;
+ }
+
+-zap()
++static void
++zap(void)
+ {
+- register char *namp;
++ register const char *namp;
+ register bool **fp;
+ register char ***sp;
+ int flag;
+@@ -397,10 +406,10 @@ zap()
+ } while (*namp);
+ }
+
+-char *
++static const char *
+ gettlongname(bp, def)
+ register char *bp;
+- char *def;
++ const char *def;
+ {
+ register char *cp;
+
+@@ -438,11 +447,11 @@ fkey(i)
+ * than AL vs SR, won't be really affected.)
+ */
+ static int costnum;
++
++int
+ cost(str)
+-char *str;
++const char *str;
+ {
+- int countnum();
+-
+ if (str == NULL || *str=='O') /* OOPS */
+ return 10000; /* infinity */
+ costnum = 0;
+@@ -451,8 +460,10 @@ char *str;
+ }
+
+ /* ARGSUSED */
++static int
+ countnum(ch)
+ char ch;
+ {
+ costnum++;
++ return ch;
+ }
diff --git a/editors/ex/patches/patch-ex__tty_h b/editors/ex/patches/patch-ex__tty_h
new file mode 100644
index 00000000000..6a2f94961c2
--- /dev/null
+++ b/editors/ex/patches/patch-ex__tty_h
@@ -0,0 +1,39 @@
+$NetBSD: patch-ex__tty_h,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- use const for string constants
+- declare void functions void
+- don't declare local functions in header files
+
+--- ex_tty.h.orig 2002-02-06 00:43:55.000000000 +0000
++++ ex_tty.h
+@@ -259,9 +259,9 @@ var short costRP; /* likewise for RIGHT_
+ # define MAXCHARMACS 1536 /* max # of chars total in macros */
+ #endif
+ struct maps {
+- char *cap; /* pressing button that sends this.. */
+- char *mapto; /* .. maps to this string */
+- char *descr; /* legible description of key */
++ const char *cap; /* pressing button that sends this.. */
++ const char *mapto; /* .. maps to this string */
++ const char *descr; /* legible description of key */
+ bool hadthis; /* did this mapping already (avoid recursion) */
+ };
+ var struct maps arrows[MAXNOMACS]; /* macro defs - 1st 5 built in */
+@@ -275,12 +275,11 @@ var bool anyabbrs; /* true if abbr or un
+ var char ttynbuf[20]; /* result of ttyname() */
+ var int ttymesg; /* original mode of users tty */
+
+-int addmac __P((register char *, register char *, register char *, register struct maps *));
++void addmac __P((register char *, register const char *, register const char *, register struct maps *));
+ ttymode ostart __P((void));
+-int normal __P((ttymode));
+-int ostop __P((ttymode));
++void normal __P((ttymode));
++void ostop __P((ttymode));
+ ttymode setty __P((ttymode));
+-ttymode unixex __P((char *, char *, int, int));
+-int unixwt __P((int, ttymode));
+-int ovend __P((ttymode));
++ttymode unixex __P((const char *, char *, int, int));
++void unixwt __P((int, ttymode));
+ int map __P((register int, register struct maps *));
diff --git a/editors/ex/patches/patch-ex__unix_c b/editors/ex/patches/patch-ex__unix_c
new file mode 100644
index 00000000000..49b7ca304ff
--- /dev/null
+++ b/editors/ex/patches/patch-ex__unix_c
@@ -0,0 +1,65 @@
+$NetBSD: patch-ex__unix_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare void functions void
+- use const for string constants
+
+--- ex_unix.c~ 2003-09-03 19:53:02.000000000 +0000
++++ ex_unix.c
+@@ -95,6 +95,7 @@ static char sccsid[] = "@(#)ex_unix.c 1.
+ * First part of a shell escape,
+ * parse the line, expanding # and % and ! and printing if implied.
+ */
++void
+ unix0(warn)
+ bool warn;
+ {
+@@ -217,7 +218,8 @@ uexp:
+ */
+ ttymode
+ unixex(opt, up, newstdin, mode)
+- char *opt, *up;
++ const char *opt;
++ char *up;
+ int newstdin, mode;
+ {
+ int pvec[2];
+@@ -299,6 +301,7 @@ unixex(opt, up, newstdin, mode)
+ * F is for restoration of tty mode if from open/visual.
+ * C flags suppression of printing.
+ */
++void
+ unixwt(c, f)
+ bool c;
+ ttymode f;
+@@ -328,6 +331,7 @@ unixwt(c, f)
+ * the filter, then a child editor is created to write it.
+ * If output is catch it from io which is created by unixex.
+ */
++void
+ filter(mode)
+ register int mode;
+ {
+@@ -391,6 +395,7 @@ filter(mode)
+ * Set up to do a recover, getting io to be a pipe from
+ * the recover process.
+ */
++void
+ recover()
+ {
+ static int pvec[2];
+@@ -420,6 +425,7 @@ recover()
+ /*
+ * Wait for the process (pid an external) to complete.
+ */
++void
+ waitfor()
+ {
+ int stat = 0;
+@@ -449,6 +455,7 @@ waitfor()
+ * exits non-zero, force not edited; otherwise force
+ * a write.
+ */
++void
+ revocer()
+ {
+
diff --git a/editors/ex/patches/patch-ex__v_c b/editors/ex/patches/patch-ex__v_c
new file mode 100644
index 00000000000..f25572baa51
--- /dev/null
+++ b/editors/ex/patches/patch-ex__v_c
@@ -0,0 +1,155 @@
+$NetBSD: patch-ex__v_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- don't declare local functions in headers
+- silence warnings about assignments in conditionals
+- avoid implicit int
+- silence warnings about unused arguments
+
+--- ex_v.c~ 2012-12-27 21:58:42.000000000 +0000
++++ ex_v.c
+@@ -127,9 +127,10 @@ static char sccsid[] = "@(#)ex_v.c 1.14
+
+ JMP_BUF venv;
+
+-int ovbeg __P((void));
+-int setwind __P((void));
+-int vok __P((cell *));
++static void ovbeg __P((void));
++static void ovend __P((ttymode f));
++static void setwind __P((void));
++static void vok __P((cell *));
+
+ /*
+ * Enter open mode
+@@ -137,6 +138,7 @@ int vok __P((cell *));
+ #ifdef u370
+ cell atube[TUBESIZE+LBSIZE];
+ #endif
++void
+ oop()
+ {
+ register char *ic;
+@@ -146,7 +148,7 @@ oop()
+ ttymode f; /* mjm: was register */
+ int resize;
+
+- if (resize = SETJMP(venv)) {
++ if ((resize = SETJMP(venv)) != 0) {
+ setsize();
+ initev = (char *)0;
+ inopen = 0;
+@@ -217,7 +219,8 @@ oop()
+ #endif
+ }
+
+-ovbeg()
++static void
++ovbeg(void)
+ {
+
+ if (!value(OPEN))
+@@ -233,8 +236,8 @@ ovbeg()
+ dot = addr2;
+ }
+
+-ovend(f)
+- ttymode f;
++static void
++ovend(ttymode f)
+ {
+
+ splitw++;
+@@ -255,6 +258,7 @@ ovend(f)
+ /*
+ * Enter visual mode
+ */
++void
+ vop()
+ {
+ register int c;
+@@ -292,7 +296,7 @@ toopen:
+ goto toopen;
+ error(catgets(catd, 1, 214, "Visual requires scrolling"));
+ }
+- if (resize = SETJMP(venv)) {
++ if ((resize = SETJMP(venv)) != 0) {
+ setsize();
+ initev = (char *)0;
+ inopen = 0;
+@@ -333,6 +337,7 @@ toopen:
+ * empty buffer since routines internally
+ * demand at least one line.
+ */
++void
+ fixzero()
+ {
+
+@@ -361,6 +366,7 @@ fixzero()
+ * at some point, and then quit from the visual and undo
+ * you get the old file back. Somewhat weird.
+ */
++void
+ savevis()
+ {
+
+@@ -376,6 +382,7 @@ savevis()
+ * Restore a sensible state after a visual/open, moving the saved
+ * stuff back to [unddol,dol], and killing the partial line kill indicators.
+ */
++void
+ undvis()
+ {
+
+@@ -396,6 +403,7 @@ undvis()
+ * Set the window parameters based on the base state bastate
+ * and the available buffer space.
+ */
++static void
+ setwind()
+ {
+
+@@ -436,6 +444,7 @@ setwind()
+ * If so, then divide the screen buffer up into lines,
+ * and initialize a bunch of state variables before we start.
+ */
++static void
+ vok(atube)
+ register cell *atube;
+ {
+@@ -478,11 +487,13 @@ vok(atube)
+
+ #ifdef CBREAK
+ woid
+-vintr(signum)
++vintr(int signum)
+ {
+ extern JMP_BUF readbuf;
+ extern int doingread;
+
++ (void)signum;
++
+ signal(SIGINT, vintr);
+ if (vcatch)
+ onintr(SIGINT);
+@@ -499,6 +510,7 @@ vintr(signum)
+ * Set the size of the screen to size lines, to take effect the
+ * next time the screen is redrawn.
+ */
++void
+ vsetsiz(size)
+ int size;
+ {
+@@ -517,8 +529,10 @@ vsetsiz(size)
+
+ #ifdef SIGWINCH
+ woid
+-onwinch(signum)
++onwinch(int signum)
+ {
++ (void)signum;
++
+ vsave();
+ setty(normf);
+ LONGJMP(venv, 1);
diff --git a/editors/ex/patches/patch-ex__vadj_c b/editors/ex/patches/patch-ex__vadj_c
new file mode 100644
index 00000000000..577eb6dc166
--- /dev/null
+++ b/editors/ex/patches/patch-ex__vadj_c
@@ -0,0 +1,259 @@
+$NetBSD: patch-ex__vadj_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- avoid implicit int
+- silence warnings about braces
+- silence warnings about && and || precedence
+
+--- ex_vadj.c~ 2012-12-27 21:58:42.000000000 +0000
++++ ex_vadj.c
+@@ -90,12 +90,12 @@ static char sccsid[] = "@(#)ex_vadj.c 1.
+ * screen cleanup after a change.
+ */
+
+-int vdellin __P((int, int, int));
+-int vscroll __P((register int));
+-int vadjAL __P((int, int));
+-int vcloseup __P((int, register int));
+-int vopenup __P((int, int, int));
+-int vadjDL __P((int, int));
++static void vdellin __P((int, int, int));
++static void vscroll __P((register int));
++static void vadjAL __P((int, int));
++static void vcloseup __P((int, register int));
++static void vopenup __P((int, int, int));
++static void vadjDL __P((int, int));
+
+ /*
+ * Display a new line at physical line p, returning
+@@ -106,6 +106,7 @@ int vadjDL __P((int, int));
+ * on the screen in which case the line may actually end up
+ * somewhere other than line p.
+ */
++void
+ vopen(tp, p)
+ line *tp;
+ int p;
+@@ -118,11 +119,12 @@ vopen(tp, p)
+ tfixnl(), fprintf(trace, "vopen(%d, %d)\n", lineno(tp), p);
+ #endif
+ if (state != VISUAL) {
+- if (vcnt)
++ if (vcnt) {
+ if (hold & HOLDROL)
+ vup1();
+ else
+ vclean();
++ }
+
+ /*
+ * Forget all that we once knew.
+@@ -169,6 +171,7 @@ vopen(tp, p)
+ /*
+ * Redisplay logical line l at physical line p with line number lineno.
+ */
++int
+ vreopen(p, lineno, l)
+ int p, lineno, l;
+ {
+@@ -256,6 +259,7 @@ vreopen(p, lineno, l)
+ * delete some (blank) lines from the top of the screen so that
+ * later inserts will not push stuff off the bottom.
+ */
++int
+ vglitchup(l, o)
+ int l, o;
+ {
+@@ -297,6 +301,7 @@ vglitchup(l, o)
+ * Insert cnt blank lines before line p,
+ * logically and (if supported) physically.
+ */
++void
+ vinslin(p, cnt, l)
+ register int p, cnt;
+ int l;
+@@ -378,9 +383,11 @@ vinslin(p, cnt, l)
+ * it ourselves (brute force) we will squish out @ lines in the process
+ * if this will save us work.
+ */
++static void
+ vopenup(cnt, could, l)
+ int cnt;
+ bool could;
++ int l;
+ {
+ register struct vlinfo *vc = &vlinfo[l + 1];
+ register struct vlinfo *ve = &vlinfo[vcnt];
+@@ -423,6 +430,7 @@ vopenup(cnt, could, l)
+ * Adjust data structure internally to account for insertion of
+ * blank lines on the screen.
+ */
++static void
+ vadjAL(p, cnt)
+ int p, cnt;
+ {
+@@ -451,6 +459,7 @@ vadjAL(p, cnt)
+ * Roll the screen up logically and physically
+ * so that line dl is the bottom line on the screen.
+ */
++void
+ vrollup(dl)
+ int dl;
+ {
+@@ -469,6 +478,7 @@ vrollup(dl)
+ destline = dl - cnt, destcol = dc;
+ }
+
++void
+ vup1()
+ {
+
+@@ -480,6 +490,7 @@ vup1()
+ * If doclr is true, do a clear eol if the terminal
+ * has standout (to prevent it from scrolling up)
+ */
++void
+ vmoveitup(cnt, doclr)
+ register int cnt;
+ bool doclr;
+@@ -513,6 +524,7 @@ vmoveitup(cnt, doclr)
+ /*
+ * Scroll the screen up cnt lines logically.
+ */
++static void
+ vscroll(cnt)
+ register int cnt;
+ {
+@@ -541,6 +553,7 @@ vscroll(cnt)
+ /*
+ * Discard logical lines due to physical wandering off the screen.
+ */
++void
+ vscrap()
+ {
+ register int i, j;
+@@ -591,6 +604,7 @@ vscrap()
+ * Repaint the screen, with cursor at curs, aftern an arbitrary change.
+ * Handle notification on large changes.
+ */
++void
+ vrepaint(curs)
+ char *curs;
+ {
+@@ -605,15 +619,16 @@ vrepaint(curs)
+ /*
+ * Deal with a totally useless display.
+ */
+- if (vcnt == 0 || vcline < 0 || vcline > vcnt || holdupd && state != VISUAL) {
++ if (vcnt == 0 || vcline < 0 || vcline > vcnt || (holdupd && state != VISUAL)) {
+ register line *odol = dol;
+
+ vcnt = 0;
+- if (holdupd)
++ if (holdupd) {
+ if (state == VISUAL)
+ ignore(peekkey());
+ else
+ vup1();
++ }
+ holdupd = 0;
+ if (odol == zero)
+ fixzero();
+@@ -682,6 +697,7 @@ vrepaint(curs)
+ * line after last won't completely fit. The routine vsync is
+ * more conservative and much less work on dumb terminals.
+ */
++void
+ vredraw(p)
+ register int p;
+ {
+@@ -803,6 +819,7 @@ vredraw(p)
+ * Do the real work in deleting cnt lines starting at line p from
+ * the display. First affected line is line l.
+ */
++static void
+ vdellin(p, cnt, l)
+ int p, cnt, l;
+ {
+@@ -849,6 +866,7 @@ vdellin(p, cnt, l)
+ /*
+ * Adjust internal physical screen image to account for deleted lines.
+ */
++static void
+ vadjDL(p, cnt)
+ int p, cnt;
+ {
+@@ -878,12 +896,14 @@ vadjDL(p, cnt)
+ * In any case, if the redraw option is set then all syncs map to redraws
+ * as if vsync didn't exist.
+ */
++void
+ vsyncCL()
+ {
+
+ vsync(LINE(vcline));
+ }
+
++void
+ vsync(p)
+ register int p;
+ {
+@@ -898,6 +918,7 @@ vsync(p)
+ * The guts of a sync. Similar to redraw but
+ * just less ambitous.
+ */
++void
+ vsync1(p)
+ register int p;
+ {
+@@ -933,7 +954,7 @@ vsync1(p)
+ * the current line, or if this line is piled under the
+ * next line (vreplace does this and we undo it).
+ */
+- if (l == 0 && state != VISUAL ||
++ if ((l == 0 && state != VISUAL) ||
+ (l < vcnt && (vp->vliny <= p || vp[0].vliny == vp[1].vliny))) {
+ if (l == 0 || vp->vliny < p || (vp->vflags & VDIRT)) {
+ if (l == vcline)
+@@ -972,6 +993,7 @@ vsync1(p)
+ * Subtract (logically) cnt physical lines from the
+ * displayed position of lines starting with line l.
+ */
++static void
+ vcloseup(l, cnt)
+ int l;
+ register int cnt;
+@@ -996,6 +1018,7 @@ vcloseup(l, cnt)
+ *
+ * Many boundary conditions here.
+ */
++void
+ vreplace(l, cnt, newcnt)
+ int l, cnt, newcnt;
+ {
+@@ -1054,7 +1077,7 @@ vreplace(l, cnt, newcnt)
+ * over them, since otherwise we will push them
+ * slowly off the screen, a clear lose.
+ */
+- if (cnt == newcnt || vcnt - l == newcnt && AL && DL) {
++ if (cnt == newcnt || (vcnt - l == newcnt && AL && DL)) {
+ if (cnt > 1 && l + cnt > vcnt)
+ savenote++;
+ vdirty(l, newcnt);
+@@ -1135,6 +1158,7 @@ skip:
+ * If we are in a scroll ^D within hardcopy open then all this
+ * is suppressed.
+ */
++void
+ sethard()
+ {
+
+@@ -1155,6 +1179,7 @@ sethard()
+ * as dirty so that they will be checked for correct
+ * display at next sync/redraw.
+ */
++void
+ vdirty(base, i)
+ register int base, i;
+ {
diff --git a/editors/ex/patches/patch-ex__version_c b/editors/ex/patches/patch-ex__version_c
new file mode 100644
index 00000000000..8f6c4956db1
--- /dev/null
+++ b/editors/ex/patches/patch-ex__version_c
@@ -0,0 +1,21 @@
+$NetBSD: patch-ex__version_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare void functions void
+- use const for string constants
+
+--- ex_version.c~ 2004-01-03 14:11:39.000000000 +0000
++++ ex_version.c
+@@ -74,10 +74,11 @@
+ */
+
+ #include "ex.h"
++#include "ex_proto.h"
+
+-static char *versionstring = "@(#)Version 3.7, 6/7/85 (gritter) 1/3/04";
++static const char *versionstring = "@(#)Version 3.7, 6/7/85 (gritter) 1/3/04";
+
+-int
++void
+ printver()
+ {
+ printf("%s%s%s", versionstring + 4,
diff --git a/editors/ex/patches/patch-ex__vget_c b/editors/ex/patches/patch-ex__vget_c
new file mode 100644
index 00000000000..5e55b18ec04
--- /dev/null
+++ b/editors/ex/patches/patch-ex__vget_c
@@ -0,0 +1,258 @@
+$NetBSD: patch-ex__vget_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- avoid implicit int
+- use const for string constants
+- silence warnings about assignments in conditionals
+- silence warnings about && and || precedence
+- silence warnings about unused arguments
+
+--- ex_vget.c~ 2012-12-27 21:58:42.000000000 +0000
++++ ex_vget.c
+@@ -89,12 +89,13 @@ static char sccsid[] = "@(#)ex_vget.c 1.
+ * large changes which appears in the echo area.
+ */
+
+-int addto __P((cell *, char *));
+-int fastpeekkey __P((void));
++static void addto __P((cell *, char *));
++static int fastpeekkey __P((void));
+
+ /*
+ * Return the key.
+ */
++void
+ ungetkey(c)
+ int c; /* mjm: char --> int */
+ {
+@@ -106,6 +107,7 @@ ungetkey(c)
+ /*
+ * Return a keystroke, but never a ^@.
+ */
++int
+ getkey()
+ {
+ register int c; /* mjm: char --> int */
+@@ -121,6 +123,7 @@ getkey()
+ /*
+ * Tell whether next keystroke would be a ^@.
+ */
++int
+ peekbr()
+ {
+
+@@ -139,13 +142,14 @@ int doingread = 0;
+ * from repeating commands with .), and finally new
+ * keystrokes.
+ */
++int
+ getbr()
+ {
+ char ch;
+ register int c;
+ #ifdef UCVISUAL
+ register int d;
+- register char *colp;
++ register const char *colp;
+ #endif
+ #ifdef BEEHIVE
+ int cnt;
+@@ -248,7 +252,7 @@ again:
+ d = toupper(c);
+ else {
+ colp = "({)}!|^~'~";
+- while (d = *colp++)
++ while ((d = *colp++) != 0)
+ if (d == c) {
+ d = *colp++;
+ break;
+@@ -292,6 +296,7 @@ again:
+ * Get a key, but if a delete, quit or attention
+ * is typed return 0 so we will abort a partial command.
+ */
++int
+ getesc()
+ {
+ register int c;
+@@ -320,6 +325,7 @@ case_ATTN:
+ /*
+ * Peek at the next keystroke.
+ */
++int
+ peekkey()
+ {
+
+@@ -331,7 +337,8 @@ peekkey()
+ * Read a line from the echo area, with single character prompt c.
+ * A return value of 1 means the user blewit or blewit away.
+ */
+-readecho(c)
++int
++readecho(int c)
+ {
+ register char *sc = cursor;
+ register int (*OP)();
+@@ -383,6 +390,7 @@ blewit:
+ * the purposes of repeat, so copy it from
+ * the working to the previous command buffer.
+ */
++void
+ setLAST()
+ {
+
+@@ -400,6 +408,7 @@ setLAST()
+ * If the insertion buffer oveflows, then destroy
+ * the repeatability of the insert.
+ */
++void
+ addtext(cp)
+ char *cp;
+ {
+@@ -415,6 +424,7 @@ addtext(cp)
+ lastcmd[0] = 0;
+ }
+
++void
+ setDEL()
+ {
+
+@@ -424,6 +434,7 @@ setDEL()
+ /*
+ * Put text from cursor upto wcursor in BUF.
+ */
++void
+ setBUF(BUF)
+ register cell *BUF;
+ {
+@@ -437,6 +448,7 @@ setBUF(BUF)
+ *wp = c;
+ }
+
++static void
+ addto(buf, str)
+ register cell *buf;
+ register char *str;
+@@ -467,12 +479,13 @@ addto(buf, str)
+ * to do this for open modes now; return and save for later
+ * notification in visual.
+ */
++int
+ noteit(must)
+ bool must;
+ {
+ register int sdl = destline, sdc = destcol;
+
+- if (notecnt < 2 || !must && state == VISUAL)
++ if (notecnt < 2 || (!must && state == VISUAL))
+ return (0);
+ splitw++;
+ if (WBOT == WECHO)
+@@ -483,7 +496,7 @@ noteit(must)
+ putchar('s');
+ if (*notenam) {
+ printf(" %s", notenam);
+- if (*(strend(notenam) - 1) != 'e')
++ if (*(strendk(notenam) - 1) != 'e')
+ putchar('e');
+ putchar('d');
+ }
+@@ -502,7 +515,8 @@ noteit(must)
+ * Rrrrringgggggg.
+ * If possible, use flash (VB).
+ */
+-beep()
++void
++beep(void)
+ {
+
+ if (VB && value(FLASH))
+@@ -517,13 +531,14 @@ beep()
+ * motions. I.e. on an adm3a we might map ^K to ^P.
+ * DM1520 for example has a lot of mappable characters.
+ */
+-
++int
+ map(c,maps)
+ register int c;
+ register struct maps *maps;
+ {
+ register int d;
+- register char *p, *q;
++ register const char *p;
++ register char *q;
+ char b[10]; /* Assumption: no keypad sends string longer than 10 */
+
+ /*
+@@ -559,7 +574,7 @@ map(c,maps)
+ if (trace)
+ fprintf(trace,"\ntry '%s', ",maps[d].cap);
+ #endif
+- if (p = maps[d].cap) {
++ if ((p = maps[d].cap) != NULL) {
+ for (q=b; *p; p++, q++) {
+ #ifdef MDEBUG
+ if (trace)
+@@ -633,8 +648,9 @@ map(c,maps)
+ * is false for, for example, pushing back lookahead from fastpeekkey(),
+ * since otherwise two fast escapes can clobber our undo.
+ */
++void
+ macpush(st, canundo)
+-char *st;
++const char *st;
+ int canundo;
+ {
+ char tmpbuf[BUFSIZ];
+@@ -671,8 +687,8 @@ int canundo;
+ }
+
+ #ifdef TRACE
+-visdump(s)
+-char *s;
++static void
++visdump(const char *s)
+ {
+ register int i;
+
+@@ -688,8 +704,8 @@ char *s;
+ tvliny();
+ }
+
+-vudump(s)
+-char *s;
++void
++vudump(const char *s)
+ {
+ register line *p;
+ char savelb[1024];
+@@ -717,6 +733,7 @@ char *s;
+ * Get a count from the keyed input stream.
+ * A zero count is indistinguishable from no count.
+ */
++int
+ vgetcnt()
+ {
+ register int c, cnt;
+@@ -734,8 +751,11 @@ vgetcnt()
+ return(cnt);
+ }
+
+-woid
+-trapalarm(signum) {
++static woid
++trapalarm(int signum)
++{
++ (void)signum;
++
+ alarm(0);
+ if (vcatch)
+ LONGJMP(vreslab,1);
+@@ -747,6 +767,7 @@ trapalarm(signum) {
+ * a machine generated sequence (such as a function pad from an escape
+ * flavor terminal) but fail for a human hitting escape then waiting.
+ */
++static int
+ fastpeekkey()
+ {
+ shand Oint;
diff --git a/editors/ex/patches/patch-ex__vis_h b/editors/ex/patches/patch-ex__vis_h
new file mode 100644
index 00000000000..6f6abca2521
--- /dev/null
+++ b/editors/ex/patches/patch-ex__vis_h
@@ -0,0 +1,36 @@
+$NetBSD: patch-ex__vis_h,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- use const for string constants
+- declare void functions void
+- remove stray extra copies of function declarations from elsewhere
+
+--- ex_vis.h~ 2012-12-27 21:58:42.000000000 +0000
++++ ex_vis.h
+@@ -300,8 +300,8 @@ var bool lasthad; /* Last command had a
+ var short lastvgk; /* Previous input key, if not from keyboard */
+ var short lastreg; /* Register with last command */
+ var char *ncols['z'-'a'+2]; /* Cursor positions of marks */
+-var char *notenam; /* Name to be noted with change count */
+-var char *notesgn; /* Change count from last command */
++var const char *notenam; /* Name to be noted with change count */
++var const char *notesgn; /* Change count from last command */
+ var char op; /* Operation of current command */
+ var short Peekkey; /* Peek ahead key */
+ var bool rubble; /* Line is filthy (in hardcopy open), redraw! */
+@@ -333,13 +333,7 @@ var cell workcmd[5]; /* Temporary for la
+ /*
+ * Function types
+ */
+-int beep();
+-int qcount();
+-int vchange();
+-int vdelete();
++void beep(void);
+ int vgrabit();
+-int vinschar();
+-int vmove();
+-int vputchar();
+-int vshift();
+-int vyankit();
++
++
diff --git a/editors/ex/patches/patch-ex__vmain_c b/editors/ex/patches/patch-ex__vmain_c
new file mode 100644
index 00000000000..52012ba41ac
--- /dev/null
+++ b/editors/ex/patches/patch-ex__vmain_c
@@ -0,0 +1,209 @@
+$NetBSD: patch-ex__vmain_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- use volatile for compiler warnings about setjmp/vfork clobbering
+- fix up function pointer casting mess
+- silence warnings about assignments in conditionals
+- use <ctype.h> functions correctly
+- silence warnings about && and || precedence
+
+--- ex_vmain.c~ 2012-12-27 21:58:42.000000000 +0000
++++ ex_vmain.c
+@@ -83,8 +83,8 @@ static char sccsid[] = "@(#)ex_vmain.c 1
+ #include "ex_tty.h"
+ #include "ex_vis.h"
+
+-int vzop __P((int, int, register int));
+-int grabtag __P((void));
++static void vzop __P((int, int, register int));
++static void grabtag __P((void));
+
+ /*
+ * This is the main routine for visual.
+@@ -96,17 +96,26 @@ int grabtag __P((void));
+
+ #define forbid(a) { if (a) goto fonfon; }
+
++static void
++doput(int ignore)
++{
++ (void)ignore;
++ put();
++}
++
++void
+ vmain()
+ {
+ int c, cnt, i;
+ cell esave[TUBECOLS];
+- char *oglobp;
+- short d;
+- line *addr;
++ const char *volatile oglobp;
++ volatile short d;
++ line *volatile addr;
+ int ind, nlput;
+- int shouldpo = 0;
+- int onumber = 0, olist = 0,
+- (*OPline)() = NULL, (*OPutchar)() = NULL;
++ volatile int shouldpo = 0;
++ volatile int onumber = 0, olist = 0;
++ int (*volatile OPline)(int) = NULL;
++ int (*volatile OPutchar)(int) = NULL;
+
+ CLOBBGRD(c);
+ CLOBBGRD(cnt);
+@@ -160,7 +169,7 @@ vmain()
+ Xhadcnt = hadcnt = 0;
+ Xcnt = cnt = 1;
+ splitw = 0;
+- if (i = holdupd) {
++ if ((i = holdupd) != 0) {
+ if (state == VISUAL)
+ ignore(peekkey());
+ holdupd = 0;
+@@ -205,7 +214,7 @@ looptop:
+ * an 'empty' named buffer spec in the routine
+ * kshift (see ex_temp.c).
+ */
+- forbid (c == '0' || !isalpha(c) && !isdigit(c));
++ forbid (c == '0' || (!isalpha((unsigned char)c) && !isdigit((unsigned char)c)));
+ vreg = c;
+ }
+ reread:
+@@ -635,8 +644,8 @@ reread:
+ if (isalpha(cuc(mbuf[1])))
+ {
+ char x = cuc(mbuf[1]);
+- mbuf[1] = isupper(x) ?
+- tolower(x) : toupper(x);
++ mbuf[1] = isupper((unsigned char)x) ?
++ tolower((unsigned char)x) : toupper((unsigned char)x);
+ }
+ macpush(mbuf, 1);
+ }
+@@ -865,7 +874,7 @@ case_ATTN:
+ vmacchng(1);
+ setLAST();
+ i = 0;
+- if (vreg && partreg(vreg) || !vreg && pkill[0]) {
++ if ((vreg && partreg(vreg)) || (!vreg && pkill[0])) {
+ /*
+ * Restoring multiple lines which were partial
+ * lines; will leave cursor in middle
+@@ -898,8 +907,7 @@ case_ATTN:
+ */
+ addr = dol; /* old dol */
+ CATCH
+- vremote(1, vreg ? (int(*)())putreg
+- : (int(*)())put, vreg);
++ vremote(1, vreg ? putreg : doput, vreg);
+ ONERR
+ if (vreg == -1) {
+ splitw = 0;
+@@ -1160,7 +1168,7 @@ fixup:
+ * in open mode and . moved, then redraw.
+ */
+ i = vcline + (dot - addr);
+- if (i < 0 || i >= vcnt && i >= -vcnt || state != VISUAL && dot != addr) {
++ if (i < 0 || (i >= vcnt && i >= -vcnt) || (state != VISUAL && dot != addr)) {
+ if (state == CRTOPEN)
+ vup1();
+ if (vcnt > 0)
+@@ -1247,6 +1255,7 @@ fonfon:
+ /*
+ * Grab the word after the cursor so we can look for it as a tag.
+ */
++static void
+ grabtag()
+ {
+ register char *cp, *dp;
+@@ -1271,6 +1280,7 @@ grabtag()
+ * Before appending lines, set up addr1 and
+ * the command mode undo information.
+ */
++void
+ prepapp()
+ {
+
+@@ -1284,8 +1294,8 @@ prepapp()
+ * Execute function f with the address bounds addr1
+ * and addr2 surrounding cnt lines starting at dot.
+ */
+-vremote(cnt, f, arg)
+- int cnt, (*f)(), arg;
++void
++vremote(int cnt, void (*f)(int), int arg)
+ {
+ register int oing = inglobal;
+
+@@ -1301,15 +1311,23 @@ vremote(cnt, f, arg)
+ vmcurs = 0;
+ }
+
++static void
++doyank(int ignore)
++{
++ (void)ignore;
++ yank();
++}
++
+ /*
+ * Save the current contents of linebuf, if it has changed.
+ */
++void
+ vsave()
+ {
+ char temp[LBSIZE];
+
+ CP(temp, linebuf);
+- if (FIXUNDO && vundkind == VCHNG || vundkind == VCAPU) {
++ if ((FIXUNDO && vundkind == VCHNG) || vundkind == VCAPU) {
+ /*
+ * If the undo state is saved in the temporary buffer
+ * vutmp, then we sync this into the temp file so that
+@@ -1321,7 +1339,7 @@ vsave()
+ prepapp();
+ CP(linebuf, vutmp);
+ putmark(dot);
+- vremote(1, yank, 0);
++ vremote(1, doyank, 0);
+ vundkind = VMCHNG;
+ notecnt = 0;
+ undkind = UNDCHANGE;
+@@ -1345,6 +1363,7 @@ vsave()
+ * Do a z operation.
+ * Code here is rather long, and very uninteresting.
+ */
++static void
+ vzop(hadcnt, cnt, c)
+ bool hadcnt;
+ int cnt;
+@@ -1434,7 +1453,7 @@ register char *src;
+ {
+ register cell *cp = dst;
+
+- while (*cp++ = *src++ & 0377);
++ while ((*cp++ = *src++ & 0377) != 0);
+ return dst;
+ }
+
+@@ -1445,7 +1464,7 @@ register cell *src;
+ {
+ register char *cp = dst;
+
+- while (*cp++ = *src++);
++ while ((*cp++ = *src++) != 0);
+ return dst;
+ }
+
+@@ -1456,7 +1475,7 @@ register cell *src;
+ {
+ register cell *cp = dst;
+
+- while (*cp++ = *src++);
++ while ((*cp++ = *src++) != 0);
+ return dst;
+ }
+
diff --git a/editors/ex/patches/patch-ex__voper_c b/editors/ex/patches/patch-ex__voper_c
new file mode 100644
index 00000000000..0a6be127f5b
--- /dev/null
+++ b/editors/ex/patches/patch-ex__voper_c
@@ -0,0 +1,351 @@
+$NetBSD: patch-ex__voper_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions static
+- fix up function pointer casting mess
+- declare void functions void
+- use const for string constants
+- silence warnings about && and || precedence
+- use <ctype.h> functions correctly
+- avoid implicit int
+
+--- ex_voper.c~ 2012-12-27 21:58:41.000000000 +0000
++++ ex_voper.c
+@@ -89,7 +89,35 @@ static char sccsid[] = "@(#)ex_voper.c 1
+
+ cell vscandir[2] = { '/', 0 };
+
+-int edge __P((void));
++static int edge __P((void));
++
++static void
++dovfilter(int ignore)
++{
++ (void)ignore;
++ vfilter();
++}
++
++static void
++dovshftop(int ignore)
++{
++ (void)ignore;
++ vshftop();
++}
++
++static void
++dovyankit(int ignore)
++{
++ (void)ignore;
++ vyankit();
++}
++
++static void
++dobeep(int ignore)
++{
++ (void)ignore;
++ beep();
++}
+
+ /*
+ * Decode an operator/operand type command.
+@@ -101,14 +129,17 @@ int edge __P((void));
+ * and if wcursor is zero, then the first non-blank location of the
+ * other line is implied.
+ */
++void
+ operate(c, cnt)
+ register int c, cnt;
+ {
+ register int i = 0;
+- int (*moveop)(), (*deleteop)();
+- int (*opf)();
++ void (*volatile moveop)(int);
++ void (*deleteop)(int);
++ void (*opf)(int);
+ bool subop = 0;
+- char *oglobp, *ocurs;
++ const char *oglobp;
++ char *ocurs;
+ register line *addr;
+ line *odot;
+ static char lastFKND, lastFCHR;
+@@ -120,7 +151,8 @@ operate(c, cnt)
+ qmarkcell[0] = '?';
+ slashcell[0] = '/';
+ nullcell[0] = qmarkcell[1] = slashcell[1] = 0;
+- moveop = vmove, deleteop = vdelete;
++ moveop = vmove_i;
++ deleteop = vdelete;
+ wcursor = cursor;
+ wdot = NOLINE;
+ notecnt = 0;
+@@ -132,7 +164,7 @@ operate(c, cnt)
+ */
+ case 'd':
+ moveop = vdelete;
+- deleteop = beep;
++ deleteop = dobeep;
+ break;
+
+ /*
+@@ -147,18 +179,18 @@ operate(c, cnt)
+ * c Change operator.
+ */
+ case 'c':
+- if (c == 'c' && workcmd[0] == 'C' || workcmd[0] == 'S')
++ if ((c == 'c' && workcmd[0] == 'C') || workcmd[0] == 'S')
+ subop++;
+ moveop = vchange;
+- deleteop = beep;
++ deleteop = dobeep;
+ break;
+
+ /*
+ * ! Filter through a UNIX command.
+ */
+ case '!':
+- moveop = vfilter;
+- deleteop = beep;
++ moveop = dovfilter;
++ deleteop = dobeep;
+ break;
+
+ /*
+@@ -166,8 +198,8 @@ operate(c, cnt)
+ * can be put back with p/P. Also yanks to named buffers.
+ */
+ case 'y':
+- moveop = vyankit;
+- deleteop = beep;
++ moveop = dovyankit;
++ deleteop = dobeep;
+ break;
+
+ /*
+@@ -185,8 +217,8 @@ operate(c, cnt)
+ */
+ case '<':
+ case '>':
+- moveop = vshftop;
+- deleteop = beep;
++ moveop = dovshftop;
++ deleteop = dobeep;
+ break;
+
+ /*
+@@ -309,7 +341,7 @@ ein:
+ #endif
+ getDOT();
+ forbid(!i);
+- if (opf != vmove)
++ if (opf != vmove_i)
+ if (dir > 0)
+ wcursor++;
+ else
+@@ -353,8 +385,8 @@ ein:
+ */
+ case ',':
+ forbid (lastFKND == 0);
+- c = isupper(cuc(lastFKND))
+- ? tolower(lastFKND) : toupper(lastFKND);
++ c = isupper(cuc((unsigned char)lastFKND))
++ ? tolower((unsigned char)lastFKND) : toupper((unsigned char)lastFKND);
+ i = lastFCHR;
+ if (vglobp == 0)
+ vglobp = nullcell;
+@@ -415,7 +447,7 @@ ein:
+ wcursor--;
+ case 'f':
+ fixup:
+- if (moveop != vmove)
++ if (moveop != vmove_i)
+ wcursor++;
+ break;
+ }
+@@ -444,13 +476,13 @@ fixup:
+ * $ To end of line.
+ */
+ case '$':
+- if (opf == vmove) {
++ if (opf == vmove_i) {
+ vmoving = 1;
+ vmovcol = 20000;
+ } else
+ vmoving = 0;
+ if (cnt > 1) {
+- if (opf == vmove) {
++ if (opf == vmove_i) {
+ wcursor = 0;
+ cnt--;
+ } else
+@@ -480,10 +512,10 @@ fixup:
+ */
+ case 'l':
+ case ' ':
+- forbid (margin() || opf == vmove && edge());
++ forbid (margin() || (opf == vmove_i && edge()));
+ while (cnt > 0 && !margin())
+ wcursor += dir, cnt--;
+- if (margin() && opf == vmove || wcursor < linebuf)
++ if ((margin() && opf == vmove_i) || wcursor < linebuf)
+ wcursor -= dir;
+ vmoving = 0;
+ break;
+@@ -520,7 +552,7 @@ deleteit:
+ * Stuttered operators are equivalent to the operator on
+ * a line, thus turn dd into d_.
+ */
+- if (opf == vmove || c != workcmd[0]) {
++ if (opf == vmove_i || c != workcmd[0]) {
+ errlab:
+ beep();
+ vmacp = 0;
+@@ -545,7 +577,7 @@ errlab:
+ */
+ case 'H':
+ wdot = (dot - vcline) + cnt - 1;
+- if (opf == vmove)
++ if (opf == vmove_i)
+ markit(wdot);
+ vmoving = 0;
+ wcursor = 0;
+@@ -578,7 +610,7 @@ errlab:
+ */
+ case 'L':
+ wdot = dot + vcnt - vcline - cnt;
+- if (opf == vmove)
++ if (opf == vmove_i)
+ markit(wdot);
+ vmoving = 0;
+ wcursor = 0;
+@@ -589,7 +621,7 @@ errlab:
+ */
+ case 'M':
+ wdot = dot + ((vcnt + 1) / 2) - vcline - 1;
+- if (opf == vmove)
++ if (opf == vmove_i)
+ markit(wdot);
+ vmoving = 0;
+ wcursor = 0;
+@@ -656,7 +688,7 @@ errlab:
+ forbid (Xhadcnt);
+ vmoving = 0;
+ wcursor = d == '`' ? ncols[c - 'a'] : 0;
+- if (opf == vmove && (wdot != dot || (d == '`' && wcursor != cursor)))
++ if (opf == vmove_i && (wdot != dot || (d == '`' && wcursor != cursor)))
+ markDOT();
+ if (wcursor) {
+ vsave();
+@@ -678,7 +710,7 @@ errlab:
+ cnt = lineDOL();
+ wdot = zero + cnt;
+ forbid (wdot < one || wdot > dol);
+- if (opf == vmove)
++ if (opf == vmove_i)
+ markit(wdot);
+ vmoving = 0;
+ wcursor = 0;
+@@ -765,7 +797,7 @@ slerr:
+ wcursor = loc1;
+ if (i != 0)
+ vsetsiz(i);
+- if (opf == vmove) {
++ if (opf == vmove_i) {
+ if (state == ONEOPEN || state == HARDOPEN)
+ outline = destline = WBOT;
+ if (addr != dot || loc1 != cursor)
+@@ -804,7 +836,8 @@ slerr:
+ /*
+ * Find single character c, in direction dir from cursor.
+ */
+-find(c)
++int
++find(int c)
+ {
+
+ for(;;) {
+@@ -820,8 +853,9 @@ find(c)
+ * Do a word motion with operator op, and cnt more words
+ * to go after this.
+ */
++int
+ word(op, cnt)
+- register int (*op)();
++ register void (*op)(int);
+ int cnt;
+ {
+ register int which = 0;
+@@ -832,7 +866,7 @@ word(op, cnt)
+ iwc = wcursor;
+ which = wordch(wcursor);
+ while (wordof(which, wcursor)) {
+- if (cnt == 1 && op != vmove && wcursor[1] == 0) {
++ if (cnt == 1 && op != vmove_i && wcursor[1] == 0) {
+ wcursor++;
+ break;
+ }
+@@ -848,7 +882,7 @@ word(op, cnt)
+ else
+ if (wcursor == iwc && iwdot == wdot && *iwc)
+ wcursor++;
+- if (op == vmove && margin())
++ if (op == vmove_i && margin())
+ wcursor--;
+ } else {
+ if (!lnext())
+@@ -871,8 +905,9 @@ word(op, cnt)
+ * To end of word, with operator op and cnt more motions
+ * remaining after this.
+ */
++void
+ eend(op)
+- register int (*op)();
++ register void (*op)(int);
+ {
+ register int which;
+
+@@ -898,8 +933,8 @@ eend(op)
+ * Wordof tells whether the character at *wc is in a word of
+ * kind which (blank/nonblank words are 0, conservative words 1).
+ */
+-wordof(which, wc)
+- register char *wc;
++int
++wordof(int which, register char *wc)
+ {
+
+ if (isspace(cuc(*wc)))
+@@ -911,12 +946,13 @@ wordof(which, wc)
+ * Wordch tells whether character at *wc is a word character
+ * i.e. an alfa, digit, or underscore.
+ */
++int
+ wordch(wc)
+ char *wc;
+ {
+ register int c;
+
+- c = wc[0];
++ c = (unsigned char)wc[0];
+ return (isalpha(c) || isdigit(c) || c == '_'
+ #ifdef BIT8
+ #ifdef ISO8859_1
+@@ -935,7 +971,8 @@ wordch(wc)
+ /*
+ * Edge tells when we hit the last character in the current line.
+ */
+-edge()
++static int
++edge(void)
+ {
+
+ if (linebuf[0] == 0)
+@@ -949,7 +986,8 @@ edge()
+ /*
+ * Margin tells us when we have fallen off the end of the line.
+ */
+-margin()
++int
++margin(void)
+ {
+
+ return (wcursor < linebuf || wcursor[0] == 0);
diff --git a/editors/ex/patches/patch-ex__vops2_c b/editors/ex/patches/patch-ex__vops2_c
new file mode 100644
index 00000000000..c075dfe97d5
--- /dev/null
+++ b/editors/ex/patches/patch-ex__vops2_c
@@ -0,0 +1,211 @@
+$NetBSD: patch-ex__vops2_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- avoid implicit int
+- use const for string constants
+- fix up function pointer casting mess
+- avoid sloppy code that subtracts 1 from the base address of a char[]
+ (which isn't valid)
+- silence warnings about && and || precedence
+- silence warnings about braces
+
+
+--- ex_vops2.c~ 2012-12-27 21:58:42.000000000 +0000
++++ ex_vops2.c
+@@ -91,12 +91,14 @@ static char sccsid[] = "@(#)ex_vops2.c 1
+ extern char *vUA1, *vUA2; /* mjm: extern; also in ex_vops.c */
+ extern char *vUD1, *vUD2; /* mjm: extern; also in ex_vops.c */
+
+-int vmaxrep __P((int, register int));
++static int vmaxrep __P((int, register int));
++static int vgetsplit(void);
+
+ /*
+ * Obleeperate characters in hardcopy
+ * open with \'s.
+ */
++void
+ bleep(i, cp)
+ register int i;
+ char *cp;
+@@ -117,6 +119,7 @@ bleep(i, cp)
+ * Common code for middle part of delete
+ * and change operating on parts of lines.
+ */
++int
+ vdcMID()
+ {
+ register char *cp;
+@@ -136,6 +139,7 @@ vdcMID()
+ * in the VBSIZE buffer BUF. Used to save
+ * deleted text of part of line.
+ */
++void
+ takeout(BUF)
+ cell *BUF;
+ {
+@@ -165,6 +169,7 @@ takeout(BUF)
+ * Are we at the end of the printed representation of the
+ * line? Used internally in hardcopy open.
+ */
++int
+ ateopr()
+ {
+ register int i, c;
+@@ -185,10 +190,12 @@ ateopr()
+ return (1);
+ }
+
+-showmode(mode)
++void
++showmode(int mode)
+ {
+ int sdc = destcol, sdl = destline;
+- char *ocurs, *str;
++ char *ocurs;
++ const char *str;
+
+ if (value(SHOWMODE) == 0 || TCOLUMNS <= 20 || state == ONEOPEN
+ || state == HARDOPEN || vmacp != NULL)
+@@ -246,8 +253,8 @@ char *ogcursor;
+ * The addtext() and addto() routines combined, accepting a single
+ * cell character.
+ */
+-addc(c)
+-cell c;
++static void
++addc(cell c)
+ {
+ register cell *cp = INS;
+
+@@ -274,6 +281,14 @@ cell c;
+ }
+ }
+
++static void
++doyank(int ignore)
++{
++ (void)ignore;
++ yank();
++}
++
++void
+ vappend(ch, cnt, indent)
+ int ch; /* mjm: char --> int */
+ int cnt, indent;
+@@ -330,7 +345,7 @@ vappend(ch, cnt, indent)
+ if (value(AUTOINDENT) && indent != 0) {
+ gcursor = genindent(indent);
+ *gcursor = 0;
+- vgotoCL(qcolumn(cursor - 1, genbuf));
++ vgotoCL(qcolumn2(cursor, genbuf));
+ } else {
+ gcursor = genbuf;
+ *gcursor = 0;
+@@ -536,7 +551,7 @@ vappend(ch, cnt, indent)
+ * correctly later.
+ */
+ if (FIXUNDO && vundkind == VCHNG) {
+- vremote(1, yank, 0);
++ vremote(1, doyank, 0);
+ undap1--;
+ }
+
+@@ -561,7 +576,7 @@ vappend(ch, cnt, indent)
+ strcLIN(gcursor);
+ *gcursor = 0;
+ cursor = linebuf;
+- vgotoCL(qcolumn(cursor - 1, genbuf));
++ vgotoCL(qcolumn2(cursor, genbuf));
+ showmode(ch);
+ }
+
+@@ -594,6 +609,7 @@ vappend(ch, cnt, indent)
+ * backwards around end of lines (vgoto can't hack columns which are
+ * less than 0 in general).
+ */
++void
+ back1()
+ {
+
+@@ -620,6 +636,7 @@ vget_line(cnt, gcursor, aescaped, commch
+ int cnt;
+ register char *gcursor;
+ bool *aescaped;
++ int commch;
+ {
+ register int c, ch;
+ register char *cp;
+@@ -771,7 +788,7 @@ vbackup:
+ endim();
+ *cp = 0;
+ c = cindent();
+- vgotoCL(qcolumn(cursor - 1, genbuf));
++ vgotoCL(qcolumn2(cursor, genbuf));
+ if (doomed >= 0)
+ doomed += c - cindent();
+ gcursor = cp;
+@@ -836,7 +853,7 @@ vbackup:
+ }
+ if (value(WRAPMARGIN) &&
+ (outcol >= OCOLUMNS - value(WRAPMARGIN) ||
+- backsl && outcol==0) &&
++ (backsl && outcol==0)) &&
+ commch != 'r') {
+ /*
+ * At end of word and hit wrapmargin.
+@@ -991,7 +1008,7 @@ btrp:
+ * generated autoindent. We count the ^D for repeat
+ * purposes.
+ */
+- if (c == iwhite && c != 0)
++ if (c == iwhite && c != 0) {
+ if (cp == gcursor) {
+ iwhite = backtab(c);
+ CDCNT++;
+@@ -1015,6 +1032,7 @@ btrp:
+ vputchar(' ');
+ goto vbackup;
+ }
++ }
+ if (vglobp && vglobp - iglobp >= 2 &&
+ (vglobp[-2] == '^' || vglobp[-2] == '0')
+ && gcursor == ogcursor + 1)
+@@ -1057,15 +1075,15 @@ vadone:
+ return (gcursor);
+ }
+
+-int vgetsplit();
+-char *vsplitpt;
++static const char *vsplitpt;
+
+ /*
+ * Append the line in buffer at lp
+ * to the buffer after dot.
+ */
++void
+ vdoappend(lp)
+- char *lp;
++ const char *lp;
+ {
+ register int oing = inglobal;
+
+@@ -1078,6 +1096,7 @@ vdoappend(lp)
+ /*
+ * Subroutine for vdoappend to pass to append.
+ */
++static int
+ vgetsplit()
+ {
+
+@@ -1093,7 +1112,9 @@ vgetsplit()
+ * allowed that will yield total line length less than
+ * LBSIZE characters and also does hacks for the R command.
+ */
++static int
+ vmaxrep(ch, cnt)
++ int ch;
+ register int cnt;
+ {
+ register int len, replen;
diff --git a/editors/ex/patches/patch-ex__vops3_c b/editors/ex/patches/patch-ex__vops3_c
new file mode 100644
index 00000000000..f795885e9ef
--- /dev/null
+++ b/editors/ex/patches/patch-ex__vops3_c
@@ -0,0 +1,323 @@
+$NetBSD: patch-ex__vops3_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions (and data) static
+- fix up function pointer casting mess
+- avoid implicit int
+- silence warnings about && and || precedence
+- silence warnings about unused arguments
+- use const for string constants
+- declare void functions void
+
+
+--- ex_vops3.c~ 2012-12-27 21:58:41.000000000 +0000
++++ ex_vops3.c
+@@ -99,23 +99,26 @@ static char sccsid[] = "@(#)ex_vops3.c 1
+ *
+ * The code here is very hard to understand.
+ */
+-line *llimit;
+-int (*lf)();
++static line *llimit;
++static bool wasend;
+
+-int lskipa1 __P((register char *));
+-int endsent __P((int));
+-int endPS __P((void));
+-int lskipbal __P((register char *));
+-int ltosolid __P((void));
+-int lskipatom __P((void));
+-int isa __P((register char *));
+-int ltosol1 __P((register char *));
+-
+-#ifdef LISPCODE
+-int lindent();
+-#endif
++/*
++ * lf is never called, but is compared against other function pointers.
++ * lindent() is the wrong type, so instead of setting lf = lindent, set
++ * it to 0 and set lf_is_lindent to nonzero. Other assignments to lf
++ * whould be accompanied by lf_is_lindent = 0.
++ */
++static void (*lf)(int);
++static int lf_is_lindent;
+
+-bool wasend;
++static int lskipa1 __P((register const char *));
++static int endsent __P((int));
++static int endPS __P((void));
++static int lskipbal __P((register const char *));
++static int ltosolid __P((void));
++static int lskipatom __P((void));
++static int isa __P((register const char *));
++static int ltosol1 __P((register const char *));
+
+ /*
+ * Find over structure, repeated count times.
+@@ -124,9 +127,11 @@ bool wasend;
+ * rather than (), implying past atoms in a list (or a paragraph
+ * rather than a sentence.
+ */
++int
+ llfind(pastatom, cnt, f, limit)
+ bool pastatom;
+- int cnt, (*f)();
++ int cnt;
++ void (*f)(int);
+ line *limit;
+ {
+ #ifdef LISPCODE
+@@ -142,6 +147,7 @@ llfind(pastatom, cnt, f, limit)
+ */
+ wasend = 0;
+ lf = f;
++ lf_is_lindent = 0;
+ strcpy(save, linebuf);
+ if (limit == 0)
+ limit = dir < 0 ? one : dol;
+@@ -210,7 +216,7 @@ begin:
+ while (!endsent(pastatom))
+ if (!lnext())
+ goto ret;
+- if (!pastatom || wcursor == linebuf && endPS())
++ if (!pastatom || (wcursor == linebuf && endPS()))
+ if (--cnt <= 0)
+ break;
+ if (linebuf[0] == 0) {
+@@ -246,7 +252,7 @@ begin:
+ * If we are not at a section/paragraph division,
+ * advance to next.
+ */
+- if (wcursor == icurs && wdot == idot || wcursor != linebuf || !endPS())
++ if ((wcursor == icurs && wdot == idot) || wcursor != linebuf || !endPS())
+ ignore(lskipa1(""));
+ }
+ #ifdef LISPCODE
+@@ -256,7 +262,7 @@ begin:
+ * Startup by skipping if at a ( going left or a ) going
+ * right to keep from getting stuck immediately.
+ */
+- if (dir < 0 && c == '(' || dir > 0 && c == ')') {
++ if ((dir < 0 && c == '(') || (dir > 0 && c == ')')) {
+ if (!lnext()) {
+ rc = -1;
+ goto ret;
+@@ -272,7 +278,7 @@ begin:
+ */
+ while (cnt > 0) {
+ c = *wcursor;
+- if (dir < 0 && c == ')' || dir > 0 && c == '(') {
++ if ((dir < 0 && c == ')') || (dir > 0 && c == '(')) {
+ if (!lskipbal("()"))
+ goto ret;
+ /*
+@@ -285,7 +291,7 @@ begin:
+ if (!lnext() || !ltosolid())
+ goto ret;
+ --cnt;
+- } else if (dir < 0 && c == '(' || dir > 0 && c == ')')
++ } else if ((dir < 0 && c == '(') || (dir > 0 && c == ')'))
+ /* Found a higher level paren */
+ goto ret;
+ else {
+@@ -305,12 +311,15 @@ ret:
+ /*
+ * Is this the end of a sentence?
+ */
++static int
+ endsent(pastatom)
+ bool pastatom;
+ {
+ register char *cp = wcursor;
+ register int c, d;
+
++ (void)pastatom;
++
+ /*
+ * If this is the beginning of a line, then
+ * check for the end of a paragraph or section.
+@@ -330,7 +339,7 @@ endsent(pastatom)
+ if ((d = *++cp) == 0)
+ return (1);
+ while (any(d, ")]'"));
+- if (*cp == 0 || *cp++ == ' ' && *cp == ' ')
++ if (*cp == 0 || (*cp++ == ' ' && *cp == ' '))
+ return (1);
+ tryps:
+ if (cp[1] == 0)
+@@ -342,6 +351,7 @@ tryps:
+ * End of paragraphs/sections are respective
+ * macros as well as blank lines and form feeds.
+ */
++static int
+ endPS()
+ {
+
+@@ -351,6 +361,7 @@ endPS()
+ }
+
+ #ifdef LISPCODE
++int
+ lindent(addr)
+ line *addr;
+ {
+@@ -382,7 +393,8 @@ again:
+ wdot = addr;
+ dir = -1;
+ llimit = one;
+- lf = lindent;
++ lf = 0;
++ lf_is_lindent = 1;
+ if (!lskipbal("()"))
+ i = 0;
+ else if (wcursor == linebuf)
+@@ -407,16 +419,19 @@ again:
+ }
+ #endif
+
++int
+ lmatchp(addr)
+ line *addr;
+ {
+ register int i;
+- register char *parens, *cp;
++ register const char *parens;
++ register char *cp;
+
+ for (cp = cursor; !any(*cp, "({[)}]");)
+ if (*cp++ == 0)
+ return (0);
+ lf = 0;
++ lf_is_lindent = 0;
+ parens = any(*cp, "()") ? "()" : any(*cp, "[]") ? "[]" : "{}";
+ if (*cp == parens[1]) {
+ dir = -1;
+@@ -435,6 +450,7 @@ lmatchp(addr)
+ return (i);
+ }
+
++void
+ lsmatch(cp)
+ char *cp;
+ {
+@@ -473,14 +489,16 @@ lsmatch(cp)
+ cursor = scurs;
+ }
+
++static int
+ ltosolid()
+ {
+
+ return (ltosol1("()"));
+ }
+
++static int
+ ltosol1(parens)
+- register char *parens;
++ register const char *parens;
+ {
+ register char *cp;
+
+@@ -498,8 +516,9 @@ ltosol1(parens)
+ return (1);
+ }
+
++static int
+ lskipbal(parens)
+- register char *parens;
++ register const char *parens;
+ {
+ register int level = dir;
+ register int c;
+@@ -518,14 +537,16 @@ lskipbal(parens)
+ return (1);
+ }
+
++static int
+ lskipatom()
+ {
+
+ return (lskipa1("()"));
+ }
+
++static int
+ lskipa1(parens)
+- register char *parens;
++ register const char *parens;
+ {
+ register int c;
+
+@@ -546,6 +567,7 @@ lskipa1(parens)
+ return (ltosol1(parens));
+ }
+
++int
+ lnext()
+ {
+
+@@ -555,7 +577,7 @@ lnext()
+ if (*wcursor)
+ return (1);
+ if (wdot >= llimit) {
+- if (lf == vmove && wcursor > linebuf)
++ if (lf == vmove_i && wcursor > linebuf)
+ wcursor--;
+ return (0);
+ }
+@@ -568,7 +590,7 @@ lnext()
+ if (wcursor >= linebuf)
+ return (1);
+ #ifdef LISPCODE
+- if (lf == lindent && linebuf[0] == '(')
++ if (lf_is_lindent && linebuf[0] == '(')
+ llimit = wdot;
+ #endif
+ if (wdot <= llimit) {
+@@ -582,9 +604,10 @@ lnext()
+ }
+ }
+
++int
+ lbrack(c, f)
+ register int c;
+- int (*f)();
++ void (*f)(int);
+ {
+ register line *addr;
+
+@@ -598,21 +621,21 @@ lbrack(c, f)
+ get_line(*addr);
+ if (linebuf[0] == '{' ||
+ #ifdef LISPCODE
+- value(LISP) && linebuf[0] == '(' ||
++ (value(LISP) && linebuf[0] == '(') ||
+ #endif
+ isa(svalue(SECTIONS))) {
+- if (c == ']' && f != vmove) {
++ if (c == ']' && f != vmove_i) {
+ addr--;
+ get_line(*addr);
+ }
+ break;
+ }
+- if (c == ']' && f != vmove && linebuf[0] == '}')
++ if (c == ']' && f != vmove_i && linebuf[0] == '}')
+ break;
+ }
+ if (addr == dot)
+ return (0);
+- if (f != vmove)
++ if (f != vmove_i)
+ wcursor = c == ']' ? strend(linebuf) : linebuf;
+ else
+ wcursor = 0;
+@@ -621,8 +644,9 @@ lbrack(c, f)
+ return (1);
+ }
+
++static int
+ isa(cp)
+- register char *cp;
++ register const char *cp;
+ {
+
+ if (linebuf[0] != '.')
diff --git a/editors/ex/patches/patch-ex__vops_c b/editors/ex/patches/patch-ex__vops_c
new file mode 100644
index 00000000000..adee374cd39
--- /dev/null
+++ b/editors/ex/patches/patch-ex__vops_c
@@ -0,0 +1,240 @@
+$NetBSD: patch-ex__vops_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- silence warnings about braces
+- fix up function pointer casting mess
+- avoid implicit int
+- silence warnings about && and || precedence
+- use const for string constants
+- silence warnings about unused arguments
+- silence signed/unsigned compiler warning
+
+--- ex_vops.c~ 2012-12-27 21:58:42.000000000 +0000
++++ ex_vops.c
+@@ -89,8 +89,9 @@ static char sccsid[] = "@(#)ex_vops.c 1.
+ * display representations.
+ */
+
+-int xdw __P((void));
+-int setpk __P((void));
++static int xdw __P((void));
++static void vshift(int ignore);
++static void setpk __P((void));
+
+ /*
+ * Undo.
+@@ -111,6 +112,7 @@ int setpk __P((void));
+ char *vUA1, *vUA2;
+ char *vUD1, *vUD2;
+
++void
+ vUndo()
+ {
+
+@@ -137,6 +139,7 @@ vUndo()
+ vfixcurs();
+ }
+
++void
+ vundo(show)
+ bool show; /* if true update the screen */
+ {
+@@ -173,12 +176,13 @@ bool show; /* if true update the screen
+ * with dol through unddol-1. Hack screen image to
+ * reflect this replacement.
+ */
+- if (show)
++ if (show) {
+ if (undkind == UNDMOVE)
+ vdirty(0, TLINES);
+ else
+ vreplace(undap1 - addr, undap2 - undap1,
+ undkind == UNDPUT ? 0 : unddol - dol);
++ }
+ savenote = notecnt;
+ undo(1);
+ if (show && (vundkind != VMCHNG || addr != dot))
+@@ -250,6 +254,7 @@ bool show; /* if true update the screen
+ * opposed to an ex command). This has nothing to do with being
+ * in open/visual mode as :s/foo/bar is not fromvis.
+ */
++void
+ vmacchng(fromvis)
+ bool fromvis;
+ {
+@@ -259,7 +264,6 @@ bool fromvis;
+ int nlines, more;
+ /* register line *a1, *a2; */
+ /* char ch; */ /* DEBUG */
+- int copyw(), copywR();
+
+ if (!inopen)
+ return;
+@@ -338,6 +342,7 @@ bool fromvis;
+ /*
+ * Initialize undo information before an append.
+ */
++void
+ vnoapp()
+ {
+
+@@ -357,6 +362,7 @@ vnoapp()
+ /*
+ * Move is simple, except for moving onto new lines in hardcopy open mode.
+ */
++void
+ vmove()
+ {
+ register int cnt;
+@@ -423,6 +429,17 @@ vmove()
+ }
+
+ /*
++ * This is the same as vmove, but throws away its argument, so
++ * it can be used in combination with other function pointers.
++ */
++void
++vmove_i(int ignore)
++{
++ (void)ignore;
++ vmove();
++}
++
++/*
+ * Delete operator.
+ *
+ * Hard case of deleting a range where both wcursor and wdot
+@@ -430,7 +447,8 @@ vmove()
+ * by vchange (although vchange may pass it back if it degenerates
+ * to a full line range delete.)
+ */
+-vdelete(c)
++void
++vdelete(int c)
+ {
+ register char *cp;
+ register int i;
+@@ -489,7 +507,8 @@ vdelete(c)
+ * Across lines with both wcursor and wdot given, we delete
+ * and sync then append (but one operation for undo).
+ */
+-vchange(c)
++void
++vchange(int c)
+ {
+ register char *cp;
+ register int i, ind, cnt;
+@@ -705,6 +724,7 @@ smallchange:
+ * Actually counts are obsoleted, since if your terminal is slow
+ * you are better off with slowopen.
+ */
++void
+ voOpen(c, cnt)
+ int c; /* mjm: char --> int */
+ register int cnt;
+@@ -719,7 +739,7 @@ voOpen(c, cnt)
+ #endif
+ #endif
+
+- if (value(SLOWOPEN) || value(REDRAW) && AL && DL)
++ if (value(SLOWOPEN) || (value(REDRAW) && AL && DL))
+ cnt = 1;
+ #ifdef SIGWINCH
+ #ifndef POSIX_1
+@@ -794,6 +814,7 @@ voOpen(c, cnt)
+ */
+ char vshnam[2] = { 'x', 0 };
+
++void
+ vshftop()
+ {
+ register line *addr;
+@@ -817,11 +838,12 @@ vshftop()
+ *
+ * Filter portions of the buffer through unix commands.
+ */
++void
+ vfilter()
+ {
+ register line *addr;
+ register int cnt;
+- char *oglobp;
++ const char *oglobp;
+ short d;
+ #ifdef BIT8
+ cell cuxb[UXBSIZE + 2];
+@@ -885,6 +907,7 @@ vfilter()
+ * that wdot is reasonable. Its name comes from
+ * xchange dotand wdot
+ */
++static int
+ xdw()
+ {
+ register char *cp;
+@@ -956,9 +979,10 @@ xdw()
+ /*
+ * Routine for vremote to call to implement shifts.
+ */
+-vshift()
++static void
++vshift(int ignore)
+ {
+-
++ (void)ignore;
+ shift(op, 1);
+ }
+
+@@ -966,12 +990,13 @@ vshift()
+ * Replace a single character with the next input character.
+ * A funny kind of insert.
+ */
++void
+ vrep(cnt)
+ register int cnt;
+ {
+ register int i, c;
+
+- if (cnt > strlen(cursor)) {
++ if (cnt > (int)strlen(cursor)) {
+ beep();
+ return;
+ }
+@@ -1000,12 +1025,20 @@ vrep(cnt)
+ setLAST();
+ }
+
++static void
++doyank(int ignore)
++{
++ (void)ignore;
++ yank();
++}
++
+ /*
+ * Yank.
+ *
+ * Yanking to string registers occurs for free (essentially)
+ * in the routine xdw().
+ */
++void
+ vyankit()
+ {
+ register int cnt;
+@@ -1013,7 +1046,7 @@ vyankit()
+ if (wdot) {
+ if ((cnt = xdw()) < 0)
+ return;
+- vremote(cnt, yank, 0);
++ vremote(cnt, doyank, 0);
+ setpk();
+ notenam = "yank";
+ if (FIXUNDO)
+@@ -1036,6 +1069,7 @@ vyankit()
+ * the first and last lines. The compromise
+ * is for put to be more clever.
+ */
++static void
+ setpk()
+ {
+
diff --git a/editors/ex/patches/patch-ex__vput_c b/editors/ex/patches/patch-ex__vput_c
new file mode 100644
index 00000000000..d1cb1010855
--- /dev/null
+++ b/editors/ex/patches/patch-ex__vput_c
@@ -0,0 +1,471 @@
+$NetBSD: patch-ex__vput_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- avoid implicit int
+- return values from non-void functions
+- silence warnings about && and || precedence
+- silence warnings about braces
+- fix up function pointer casting mess
+
+--- ex_vput.c~ 2012-12-27 21:58:42.000000000 +0000
++++ ex_vput.c
+@@ -88,14 +88,14 @@ static char sccsid[] = "@(#)ex_vput.c 1.
+ #define vquot(c) (c == quotsp)
+ #endif /* BIT8 */
+
+-int vmaktop __P((int, cell *));
+-int vnpins __P((int));
+-int vrigid __P((void));
+-int vneedpos __P((int));
+-int vishft __P((void));
+-int viin __P((int));
+-int godm __P((void));
+-int enddm __P((void));
++static void vmaktop __P((int, cell *));
++static void vnpins __P((int));
++static void vrigid __P((void));
++static void vneedpos __P((int));
++static void vishft __P((void));
++static void viin __P((int));
++static void godm __P((void));
++static void enddm __P((void));
+
+ /*
+ * Deal with the screen, clearing, cursor positioning, putting characters
+@@ -103,6 +103,7 @@ int enddm __P((void));
+ * Really hard stuff here is utilizing insert character operations
+ * on intelligent terminals which differs widely from terminal to terminal.
+ */
++void
+ vclear()
+ {
+
+@@ -122,6 +123,7 @@ vclear()
+ /*
+ * Clear memory.
+ */
++void
+ vclrcell(cp, i)
+ register cell *cp;
+ register int i;
+@@ -135,6 +137,7 @@ vclrcell(cp, i)
+ /*
+ * Clear a physical display line, high level.
+ */
++void
+ vclrlin(l, tp)
+ int l;
+ line *tp;
+@@ -155,6 +158,7 @@ vclrlin(l, tp)
+ /*
+ * Clear to the end of the current physical line
+ */
++void
+ vclreol()
+ {
+ register int i, j;
+@@ -169,7 +173,7 @@ vclreol()
+ i = WCOLS - destcol;
+ tp = vtube[destline] + destcol;
+ if (CE) {
+- if (IN && *tp || !ateopr()) {
++ if ((IN && *tp) || !ateopr()) {
+ vcsync();
+ vputp(CE, 1);
+ }
+@@ -200,6 +204,7 @@ vclreol()
+ * If work here is being held off, just remember, in
+ * heldech, if work needs to be done, don't do anything.
+ */
++void
+ vclrech(didphys)
+ bool didphys;
+ {
+@@ -252,6 +257,7 @@ vclrech(didphys)
+ * the state variable splitw so we wont rollup
+ * when we move the cursor there.
+ */
++void
+ fixech()
+ {
+
+@@ -266,6 +272,7 @@ fixech()
+ /*
+ * Put the cursor ``before'' cp.
+ */
++void
+ vcursbef(cp)
+ register char *cp;
+ {
+@@ -279,6 +286,7 @@ vcursbef(cp)
+ /*
+ * Put the cursor ``at'' cp.
+ */
++void
+ vcursat(cp)
+ register char *cp;
+ {
+@@ -292,6 +300,7 @@ vcursat(cp)
+ /*
+ * Put the cursor ``after'' cp.
+ */
++void
+ vcursaft(cp)
+ register char *cp;
+ {
+@@ -303,6 +312,7 @@ vcursaft(cp)
+ * Fix the cursor to be positioned in the correct place
+ * to accept a command.
+ */
++void
+ vfixcurs()
+ {
+
+@@ -313,6 +323,7 @@ vfixcurs()
+ * Compute the column position implied by the cursor at ``nc'',
+ * and move the cursor there.
+ */
++void
+ vsetcurs(nc)
+ register char *nc;
+ {
+@@ -328,6 +339,7 @@ vsetcurs(nc)
+ /*
+ * Move the cursor invisibly, i.e. only remember to do it.
+ */
++void
+ vigoto(y, x)
+ int y, x;
+ {
+@@ -340,6 +352,7 @@ vigoto(y, x)
+ * Move the cursor to the position implied by any previous
+ * vigoto (or low level hacking with destcol/destline as in readecho).
+ */
++void
+ vcsync()
+ {
+
+@@ -349,6 +362,7 @@ vcsync()
+ /*
+ * Goto column x of the current line.
+ */
++void
+ vgotoCL(x)
+ register int x;
+ {
+@@ -362,8 +376,8 @@ vgotoCL(x)
+ /*
+ * Invisible goto column x of current line.
+ */
+-vigotoCL(x)
+- register int x;
++static void
++vigotoCL(register int x)
+ {
+
+ if (splitw)
+@@ -375,6 +389,7 @@ vigotoCL(x)
+ /*
+ * Move cursor to line y, column x, handling wraparound and scrolling.
+ */
++void
+ vgoto(y, x)
+ register int y, x;
+ {
+@@ -523,7 +538,8 @@ vgoto(y, x)
+ * with a QUOTE. We use QUOTE internally to represent a position
+ * which is part of the expansion of a tab.
+ */
+-vgotab()
++static void
++vgotab(void)
+ {
+ register int i = tabcol(destcol, value(TABSTOP)) - destcol;
+
+@@ -555,6 +571,7 @@ int slakused; /* This much of tabslack
+ * of the screen image buffer so it is easier for us to
+ * maniuplate them.
+ */
++void
+ vprepins()
+ {
+ register int i;
+@@ -566,6 +583,7 @@ vprepins()
+ }
+ }
+
++static void
+ vmaktop(p, cp)
+ register int p;
+ cell *cp;
+@@ -594,6 +612,7 @@ vmaktop(p, cp)
+ * for tabs) and code assumes this in several place
+ * to make life simpler.
+ */
++int
+ vinschar(c)
+ int c; /* mjm: char --> int */
+ {
+@@ -609,12 +628,12 @@ vinschar(c)
+ */
+ if (c == '\t') {
+ vgotab();
+- return;
++ return c;
+ }
+ vputchar(c);
+ if (DEPTH(vcline) * WCOLS + !value(REDRAW) >
+ (destline - LINE(vcline)) * WCOLS + destcol)
+- return;
++ return c;
+ /*
+ * The next line is about to be clobbered
+ * make space for another segment of this line
+@@ -627,14 +646,14 @@ vinschar(c)
+ } else {
+ c = LINE(vcline) + DEPTH(vcline);
+ if (c < LINE(vcline + 1) || c > WBOT)
+- return;
++ return c;
+ i = destcol;
+ vinslin(c, 1, vcline);
+ DEPTH(vcline)++;
+ vigoto(c, i);
+ vprepins();
+ }
+- return;
++ return c;
+ }
+ /*
+ * Compute the number of positions in the line image of the
+@@ -693,7 +712,7 @@ vinschar(c)
+ do
+ vputchar(c);
+ while (--inssiz);
+- return;
++ return c;
+ }
+
+ /*
+@@ -787,12 +806,14 @@ vinschar(c)
+ destline = LINE(vcline);
+ destcol = inscol + inssiz;
+ vcsync();
++ return c;
+ }
+
+ /*
+ * Rigidify the rest of the line after the first
+ * group of following tabs, typing blanks over ``spaces''.
+ */
++void
+ vrigid()
+ {
+ register int col;
+@@ -827,6 +848,7 @@ vrigid()
+ * On a dumb terminal we may infact redisplay the rest of the
+ * screen here brute force to keep it pretty.
+ */
++void
+ vneedpos(npcnt)
+ int npcnt;
+ {
+@@ -866,6 +888,7 @@ vneedpos(npcnt)
+ vnpins(1);
+ }
+
++void
+ vnpins(dosync)
+ int dosync;
+ {
+@@ -900,6 +923,7 @@ vnpins(dosync)
+ * Do the shift of the next tabstop implied by
+ * insertion so it expands.
+ */
++void
+ vishft()
+ {
+ int tshft = 0;
+@@ -1004,6 +1028,7 @@ vishft()
+ /*
+ * Now do the insert of the characters (finally).
+ */
++static void
+ viin(c)
+ int c; /* mjm: char --> int */
+ {
+@@ -1014,7 +1039,7 @@ viin(c)
+ short oldhold = hold;
+
+ hold |= HOLDPUPD;
+- if (tabsize && (IM && EI) && inssiz - doomed > tabslack)
++ if (tabsize && (IM && EI) && inssiz - doomed > tabslack) {
+ /*
+ * There is a tab out there which will be affected
+ * by the insertion since there aren't enough doomed
+@@ -1053,6 +1078,7 @@ viin(c)
+ enddm();
+ }
+ }
++ }
+
+ /*
+ * Now put out the characters of the actual insertion.
+@@ -1175,6 +1201,7 @@ viin(c)
+ * is the same as that which goes into insert
+ * mode, then we are in delete mode already.
+ */
++void
+ godm()
+ {
+
+@@ -1194,6 +1221,7 @@ godm()
+ * if we just moved over to delete space from part of
+ * a tab (above).
+ */
++static void
+ enddm()
+ {
+
+@@ -1211,6 +1239,7 @@ enddm()
+ * if the terminal does all insertions a single character
+ * at a time, since it branches based on whether IM is null.
+ */
++void
+ goim()
+ {
+
+@@ -1219,6 +1248,7 @@ goim()
+ insmode = 1;
+ }
+
++void
+ endim()
+ {
+
+@@ -1238,6 +1268,7 @@ endim()
+ * you can erase overstrikes with some work. CRT's which do underlining
+ * implicitly which has to be erased (like CONCEPTS) are also handled.
+ */
++int
+ vputchar(c)
+ register int c;
+ {
+@@ -1292,7 +1323,7 @@ vputchar(c)
+ *tp = overbuf;
+ #endif
+ destcol++;
+- return;
++ return c;
+ }
+ /*
+ * A ``space'' ontop of a part of a tab.
+@@ -1303,7 +1334,7 @@ vputchar(c)
+ if (vquot(*tp)) {
+ #endif
+ destcol++;
+- return;
++ return c;
+ }
+ #ifndef BIT8
+ c = ' ' | QUOTE;
+@@ -1328,7 +1359,7 @@ vputchar(c)
+
+ case '\t':
+ vgotab();
+- return;
++ return c;
+
+ case ' ':
+ /*
+@@ -1349,7 +1380,7 @@ vputchar(c)
+ ) {
+ *tp = ' ';
+ destcol++;
+- return;
++ return c;
+ }
+ goto def;
+
+@@ -1374,7 +1405,7 @@ def:
+ if ((hold & HOLDPUPD) == 0)
+ *tp = c;
+ destcol++;
+- return;
++ return c;
+ }
+ /*
+ * Backwards looking optimization.
+@@ -1413,7 +1444,7 @@ def:
+ e = trim(c);
+ if (!insmode && d && d != ' ' && d != e) {
+ #endif
+- if (EO && (OS || UL && (c == '_' || d == '_'))) {
++ if (EO && (OS || (UL && (c == '_' || d == '_')))) {
+ vputc(' ');
+ outcol++, destcol++;
+ back1();
+@@ -1478,12 +1509,14 @@ def:
+ vputc('\n');
+ }
+ }
++ return c;
+ }
+
+ /*
+ * Delete display positions stcol through endcol.
+ * Amount of use of special terminal features here is limited.
+ */
++void
+ physdc(stcol, endcol)
+ int stcol, endcol;
+ {
+@@ -1578,7 +1611,7 @@ physdc(stcol, endcol)
+ if (IN) {
+ up = vtube0 + stcol;
+ tp = vtube0 + endcol;
+- while (i = *tp++) {
++ while ((i = *tp++) != 0) {
+ #ifndef BIT8
+ if ((i & (QUOTE|TRIM)) == QUOTE)
+ #else
+@@ -1602,6 +1635,7 @@ physdc(stcol, endcol)
+ }
+
+ #ifdef TRACE
++void
+ tfixnl()
+ {
+
+@@ -1610,6 +1644,7 @@ tfixnl()
+ trubble = 0, techoin = 0;
+ }
+
++void
+ tvliny()
+ {
+ register int i;
+@@ -1630,6 +1665,7 @@ tvliny()
+ fprintf(trace, "\n");
+ }
+
++void
+ tracec(c)
+ int c; /* mjm: char --> int */
+ {
+@@ -1652,6 +1688,7 @@ tracec(c)
+ /*
+ * Put a character with possible tracing.
+ */
++int
+ vputch(c)
+ int c;
+ {
+@@ -1660,5 +1697,5 @@ vputch(c)
+ if (trace)
+ tracec(c);
+ #endif
+- vputc(c);
++ return vputc(c);
+ }
diff --git a/editors/ex/patches/patch-ex__vwind_c b/editors/ex/patches/patch-ex__vwind_c
new file mode 100644
index 00000000000..f3e20e22d72
--- /dev/null
+++ b/editors/ex/patches/patch-ex__vwind_c
@@ -0,0 +1,173 @@
+$NetBSD: patch-ex__vwind_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- avoid implicit int
+- hide unused function in the proper matching ifdef
+
+--- ex_vwind.c~ 2012-12-27 21:58:41.000000000 +0000
++++ ex_vwind.c
+@@ -89,10 +89,14 @@ static char sccsid[] = "@(#)ex_vwind.c 1
+ * directions. Code here is very dependent on mode (open versus visual).
+ */
+
+-int vfit __P((register line *, int));
+-int vrollR __P((register int));
+-line *vback __P((register line *, register int));
+-int vreset __P((int));
++static int vfit __P((register line *, int));
++static void vrollR __P((register int));
++static line *vback __P((register line *, register int));
++static void vreset __P((int));
++
++#ifndef CBREAK
++static int vcookit(register int cnt);
++#endif
+
+ /*
+ * Move in a nonlocal way to line addr.
+@@ -100,9 +104,11 @@ int vreset __P((int));
+ * New position for cursor is curs.
+ * Like most routines here, we vsave().
+ */
++void
+ vmoveto(addr, curs, context)
+ register line *addr;
+ char *curs;
++ int context;
+ {
+
+ markit(addr);
+@@ -114,9 +120,11 @@ vmoveto(addr, curs, context)
+ * Vjumpto is like vmoveto, but doesn't mark previous
+ * context or save linebuf as current line.
+ */
++void
+ vjumpto(addr, curs, context)
+ register line *addr;
+ char *curs;
++ int context;
+ {
+
+ noteit(0);
+@@ -131,6 +139,7 @@ vjumpto(addr, curs, context)
+ /*
+ * Go up or down cnt (negative is up) to new position curs.
+ */
++void
+ vupdown(cnt, curs)
+ register int cnt;
+ char *curs;
+@@ -152,6 +161,7 @@ vupdown(cnt, curs)
+ * If scroll, then we MUST use a scroll.
+ * Otherwise clear and redraw if motion is far.
+ */
++void
+ vup(cnt, ind, scroll)
+ register int cnt, ind;
+ bool scroll;
+@@ -201,6 +211,7 @@ okr:
+ /*
+ * Like vup, but scrolling down.
+ */
++void
+ vdown(cnt, ind, scroll)
+ register int cnt, ind;
+ bool scroll;
+@@ -250,8 +261,10 @@ dcontxt:
+ * Work here is in determining new top line implied by
+ * this placement of line addr, since we always draw from the top.
+ */
++void
+ vcontext(addr, where)
+ register line *addr;
++ int where;
+ {
+ register line *top;
+
+@@ -293,6 +306,7 @@ vcontext(addr, where)
+ * we may be able to reuse the line we are on
+ * if it is blank. This is a real win.
+ */
++void
+ vclean()
+ {
+
+@@ -310,6 +324,7 @@ vclean()
+ * (and call us recursively). Eventually, we clear the screen
+ * (or its open mode equivalent) and redraw.
+ */
++void
+ vshow(addr, top)
+ line *addr, *top;
+ {
+@@ -363,6 +378,7 @@ vshow(addr, top)
+ * area; we are called this way in the middle of a :e escape
+ * from visual, e.g.
+ */
++static void
+ vreset(inecho)
+ bool inecho;
+ {
+@@ -378,7 +394,7 @@ vreset(inecho)
+ * Starting from which line preceding tp uses almost (but not more
+ * than) cnt physical lines?
+ */
+-line *
++static line *
+ vback(tp, cnt)
+ register int cnt;
+ register line *tp;
+@@ -399,6 +415,7 @@ vback(tp, cnt)
+ /*
+ * How much scrolling will it take to roll cnt lines starting at tp?
+ */
++static int
+ vfit(tp, cnt)
+ register line *tp;
+ int cnt;
+@@ -419,6 +436,7 @@ vfit(tp, cnt)
+ /*
+ * Roll cnt lines onto the screen.
+ */
++void
+ vroll(cnt)
+ register int cnt;
+ {
+@@ -460,6 +478,7 @@ vroll(cnt)
+ /*
+ * Roll backwards (scroll up).
+ */
++static void
+ vrollR(cnt)
+ register int cnt;
+ {
+@@ -504,16 +523,20 @@ vrollR(cnt)
+ * BUG: An interrupt during a scroll in this way
+ * dumps to command mode.
+ */
++#ifndef CBREAK
++static int
+ vcookit(cnt)
+ register int cnt;
+ {
+
+ return (cnt > 1 && (ospeed < B1200 && !initev || cnt > TLINES * 2));
+ }
++#endif
+
+ /*
+ * Determine displayed depth of current line.
+ */
++int
+ vdepth()
+ {
+ register int d;
+@@ -529,6 +552,7 @@ vdepth()
+ /*
+ * Move onto a new line, with cursor at position curs.
+ */
++void
+ vnline(curs)
+ char *curs;
+ {
diff --git a/editors/ex/patches/patch-ex_c b/editors/ex/patches/patch-ex_c
new file mode 100644
index 00000000000..b8df97f15fa
--- /dev/null
+++ b/editors/ex/patches/patch-ex_c
@@ -0,0 +1,122 @@
+$NetBSD: patch-ex_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions static
+- declare void functions void
+- avoid implicit int
+- use volatile for compiler warnings about setjmp/vfork clobbering
+- silence warnings about assignments in conditionals
+
+--- ex.c~ 2003-03-18 20:47:50.000000000 +0000
++++ ex.c
+@@ -144,13 +144,15 @@ char tttrace[] = { '/','d','e','v','/','
+
+ static char *progname;
+
+-erropen()
++static void
++erropen(void)
+ {
+ close(1);
+ dup(2);
+ }
+
+-usage()
++static void
++usage(void)
+ {
+ printf(catgets(catd, 1, 1, "\
+ Usage: %s [- | -s] [-l] [-L] [-R] [-r [file]] [-t tag]\n\
+@@ -160,7 +162,8 @@ Usage: %s [- | -s] [-l] [-L] [-R] [-r [f
+ exitex(1);
+ }
+
+-needarg(c)
++static void
++needarg(int c)
+ {
+ erropen();
+ printf(catgets(catd, 1, 2,
+@@ -168,7 +171,8 @@ needarg(c)
+ usage();
+ }
+
+-invopt(c)
++static void
++invopt(int c)
+ {
+ erropen();
+ printf(catgets(catd, 1, 3, "%s: illegal option -- %c\n"), progname, c);
+@@ -178,9 +182,8 @@ invopt(c)
+ /*
+ * Return last component of unix path name p.
+ */
+-char *
+-tailpath(p)
+-register char *p;
++static char *
++tailpath(register char *p)
+ {
+ register char *r;
+
+@@ -194,8 +197,8 @@ register char *p;
+ * Check ownership of file. Return nonzero if it exists and is owned by the
+ * user or the option sourceany is used
+ */
+-iownit(file)
+-char *file;
++static int
++iownit(const char *file)
+ {
+ struct stat sb;
+
+@@ -214,8 +217,7 @@ char *file;
+
+ #ifdef POSIX_1
+ shand
+-setsig(signum, handler)
+-shand handler;
++setsig(int signum, shand handler)
+ {
+ struct sigaction nact, oact;
+
+@@ -244,7 +246,8 @@ shand handler;
+ * Main thing here is to get a new buffer (in fileinit),
+ * rest is peripheral state resetting.
+ */
+-init()
++void
++init(void)
+ {
+ register int i;
+
+@@ -268,6 +271,7 @@ init()
+ * there is a 'd' in our name. For edit we just diddle options;
+ * for vi we actually force an early visual command.
+ */
++int
+ main(ac, av)
+ register int ac;
+ register char *av[];
+@@ -280,7 +284,13 @@ main(ac, av)
+ #endif
+ char *cp = NULL;
+ register int c;
++#ifdef __STDC__
++ volatile
++#endif
+ bool ivis;
++#ifdef __STDC__
++ volatile
++#endif
+ bool fast = 0;
+ #ifdef TRACE
+ register char *tracef;
+@@ -560,7 +570,7 @@ argend:
+ setrupt();
+ intty = isatty(0);
+ value(PROMPT) = intty;
+- if (cp = getenv("SHELL"))
++ if ((cp = getenv("SHELL")) != NULL)
+ strcpy(shell, cp);
+ if (fast || !intty)
+ setterm("dumb");
diff --git a/editors/ex/patches/patch-expreserve_c b/editors/ex/patches/patch-expreserve_c
new file mode 100644
index 00000000000..9a2da49a846
--- /dev/null
+++ b/editors/ex/patches/patch-expreserve_c
@@ -0,0 +1,90 @@
+$NetBSD: patch-expreserve_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare void functions void
+- use static for local functions
+- use a bit of const
+- silence gcc warnings about unused arguments
+- avoid implicit int
+- don't pass a string constant to putenv()
+
+--- expreserve.c.orig 2002-08-27 04:14:56.000000000 +0000
++++ expreserve.c
+@@ -203,10 +203,10 @@ char xstr[1]; /* make loader happy */
+ #endif
+ #endif
+
+-int notify __P((uid_t uid, char *fname, int flag, time_t time));
+-int copyout __P((char *name));
+-int mkdigits __P((char *cp));
+-int mknext __P((char *cp));
++static void notify __P((uid_t uid, const char *fname, int flag, time_t time));
++static int copyout __P((char *name));
++static void mkdigits __P((char *cp));
++static void mknext __P((char *cp));
+
+ /*
+ * Expreserve - preserve a file in /usr/preserve
+@@ -275,6 +275,7 @@ char **argv;
+ exit(1);
+ exit(0);
+ }
++ (void)argv;
+
+ /*
+ * If not super user, then can only preserve standard input.
+@@ -328,9 +329,11 @@ char pattern[] = "/var/preserve/Exa`XXXX
+ /*
+ * Notify user uid that his file fname has been saved.
+ */
++static void
+ notify(uid, fname, flag, time)
+ uid_t uid;
+- char *fname;
++ const char *fname;
++ int flag;
+ time_t time;
+ {
+ struct passwd *pp = getpwuid(uid);
+@@ -345,6 +348,9 @@ notify(uid, fname, flag, time)
+ char croak[128];
+ char *timestamp, *ctime();
+
++ /* cannot properly string constants to putenv */
++ static char mailrc_var[] = "MAILRC=/dev/null";
++
+ if (pp == NULL)
+ return;
+ #ifndef POSIX_1
+@@ -355,7 +361,7 @@ notify(uid, fname, flag, time)
+ #endif
+ timestamp = ctime(&time);
+ timestamp[16] = 0; /* blast from seconds on */
+- putenv("MAILRC=/dev/null");
++ putenv(mailrc_var);
+ sprintf(cmd, "/bin/mail %s", pp->pw_name);
+ setuid(getuid());
+ mf = popen(cmd, "w");
+@@ -411,6 +417,7 @@ notify(uid, fname, flag, time)
+ * file (this is the slowest thing since we must stat
+ * to find a unique name), and finally copy the file.
+ */
++static int
+ copyout(name)
+ char *name;
+ {
+@@ -546,6 +553,7 @@ format:
+ /*
+ * Blast the last 5 characters of cp to be the process number.
+ */
++static void
+ mkdigits(cp)
+ char *cp;
+ {
+@@ -566,6 +574,7 @@ mkdigits(cp)
+ * three alphabetic characters into a sequence of the form 'aab', 'aac', etc.
+ * Mktemp gets weird names too quickly to be useful here.
+ */
++static void
+ mknext(cp)
+ char *cp;
+ {
diff --git a/editors/ex/patches/patch-exrecover_c b/editors/ex/patches/patch-exrecover_c
index 2b114aae0c9..f943fcac58a 100644
--- a/editors/ex/patches/patch-exrecover_c
+++ b/editors/ex/patches/patch-exrecover_c
@@ -1,23 +1,333 @@
-$NetBSD: patch-exrecover_c,v 1.1 2011/08/01 05:47:40 dholland Exp $
+$NetBSD: patch-exrecover_c,v 1.2 2012/12/28 03:03:09 dholland Exp $
-Fix illegal C caught by clang.
+- use standard headers
+- don't declare own perror
+- declare void functions void
+- avoid implicit int
+- silence signed/unsigned compiler warning
+- use const for string constants
+- silence warnings about assignments in conditionals
+- return values from non-void functions
+- silence warnings about unused arguments
---- exrecover.c~ 2002-04-07 12:02:27.000000000 +0000
+--- exrecover.c.orig 2012-12-27 21:58:41.000000000 +0000
+++ exrecover.c
-@@ -198,7 +198,7 @@ char *getblock __P((line, int));
- int blkio __P((bloc, char *, ssize_t (*) __P((int, void *, size_t))));
+@@ -98,6 +98,8 @@ static char sccsid[] UNUSED = "@(#)exrec
+ typedef int xFILE;
+ #endif
+
++#include <stdio.h>
++
+ #define var
+
+ #include "ex.h"
+@@ -193,30 +195,30 @@ int vercnt; /* Count number of version
+ #endif
+ #endif
+
+-extern int perror __P((const char *));
+ char *getblock __P((line, int));
+-int blkio __P((bloc, char *, ssize_t (*) __P((int, void *, size_t))));
++void blkio __P((bloc, char *, ssize_t (*) __P((int, void *, size_t))));
char *poolsbrk __P((intptr_t));
- int error __P((char *str, ...));
+-int error __P((char *str, ...));
-int listfiles __P((char *));
-+void listfiles __P((char *));
- int enter __P((struct svfile *, char *, int));
+-int enter __P((struct svfile *, char *, int));
++void error __P((const char *str, ...));
++void listfiles __P((const char *));
++void enter __P((struct svfile *, char *, int));
int qucmp __P((struct svfile *, struct svfile *));
- int findtmp __P((char *));
-@@ -384,6 +384,7 @@ error(char *str, ...)
+-int findtmp __P((char *));
+-int searchdir __P((char *));
+-int yeah __P((char *));
++void findtmp __P((const char *));
++void searchdir __P((const char *));
++int yeah __P((const char *));
+ int preserve __P((void));
+-int scrapbad __P((void));
+-int putfile __P((int));
+-int wrerror __P((void));
+-int clrstats __P((void));
+-int get_line __P((line));
+-int syserror __P((void));
+-int xvfprintf __P((xFILE *, char *, va_list));
+-int xfprintf __P((xFILE *, char *, ...));
++void scrapbad __P((void));
++void putfile __P((int));
++void wrerror __P((void));
++void clrstats __P((void));
++void get_line __P((line));
++void syserror __P((void));
++void xvfprintf __P((xFILE *, const char *, va_list));
++void xfprintf __P((xFILE *, const char *, ...));
+ #ifdef __STDC__
+ int vsprintf(char *, const char *, va_list);
+ #endif
+
++int
+ main(argc, argv)
+ int argc;
+ char *argv[];
+@@ -295,7 +297,7 @@ main(argc, argv)
+ while (H.Flines > 0) {
+ ignorl(lseek(tfile, (off_t) ((blocks[b] & BLKMSK) * BUFSIZ),
+ SEEK_SET));
+- i = H.Flines < BUFSIZ / sizeof (line) ?
++ i = H.Flines < (int)(BUFSIZ / sizeof (line)) ?
+ H.Flines * sizeof (line) : BUFSIZ;
+ if (read(tfile, (char *) dot, i) != i) {
+ perror(nb);
+@@ -350,13 +352,14 @@ main(argc, argv)
+ * a newline which would screw up the screen.
+ */
+ /*VARARGS2*/
++void
+ #ifndef __STDC__
+ error(str, inf)
+- char *str;
++ const char *str;
+ int inf;
+ {
+ #else
+-error(char *str, ...)
++error(const char *str, ...)
+ {
+ va_list ap;
+ #endif
+@@ -384,8 +387,9 @@ error(char *str, ...)
exit(1);
}
+void
listfiles(dirname)
- char *dirname;
+- char *dirname;
++ const char *dirname;
+ {
+ register DIR *dir;
+ #ifndef POSIX_1
+@@ -486,9 +490,11 @@ listfiles(dirname)
+ /*
+ * Enter a new file into the saved file information.
+ */
++void
+ enter(fp, fname, count)
+ struct svfile *fp;
+ char *fname;
++ int count;
+ {
+ register char *cp, *cp2;
+ register struct svfile *f, *fl;
+@@ -521,7 +527,7 @@ enter(fp, fname, count)
+ fp->sf_time = H.Time;
+ fp->sf_lines = H.Flines;
+ cp2 = fp->sf_name, cp = savedfile;
+- while (*cp2++ = *cp++);
++ while ((*cp2++ = *cp++) != 0);
+ for (cp2 = fp->sf_entry, cp = fname; *cp && cp-fname < 14;)
+ *cp2++ = *cp++;
+ *cp2++ = 0;
+@@ -531,12 +537,13 @@ enter(fp, fname, count)
+ * Do the qsort compare to sort the entries first by file name,
+ * then by modify time.
+ */
++int
+ qucmp(p1, p2)
+ struct svfile *p1, *p2;
+ {
+ register int t;
+
+- if (t = strcmp(p1->sf_name, p2->sf_name))
++ if ((t = strcmp(p1->sf_name, p2->sf_name)) != 0)
+ return(t);
+ if (p1->sf_time > p2->sf_time)
+ return(-1);
+@@ -555,8 +562,9 @@ int bestfd; /* Keep best file open so
+ * (i.e. usually /tmp) and in /usr/preserve.
+ * Want to find the newest so we search on and on.
+ */
++void
+ findtmp(dir)
+- char *dir;
++ const char *dir;
+ {
+
+ /*
+@@ -608,8 +616,9 @@ findtmp(dir)
+ * name of the file we want to unlink is relative, rather than absolute
+ * we won't be able to find it again.
+ */
++void
+ searchdir(dirname)
+- char *dirname;
++ const char *dirname;
+ {
+ #ifndef POSIX_1
+ struct direct *dirent;
+@@ -662,8 +671,9 @@ searchdir(dirname)
+ * if its really an editor temporary and of this
+ * user and the file specified.
+ */
++int
+ yeah(name)
+- char *name;
++ const char *name;
+ {
+
+ tfile = open(name, O_RDWR);
+@@ -688,9 +698,10 @@ nope:
+ return (1);
+ }
+
++int
+ preserve()
+ {
+-
++ return 0;
+ }
+
+ /*
+@@ -707,6 +718,7 @@ preserve()
+ * This only seems to happen on very heavily loaded systems, and
+ * not very often.
+ */
++void
+ scrapbad()
+ {
+ register line *ip;
+@@ -791,6 +803,7 @@ null:
+ * Aw shucks, if we only had a (void) cast.
+ */
+ #ifdef lint
++void
+ Ignorl(a)
+ long a;
{
+@@ -798,6 +811,7 @@ Ignorl(a)
+ a = a;
+ }
+
++void
+ Ignore(a)
+ char *a;
+ {
+@@ -805,13 +819,15 @@ Ignore(a)
+ a = a;
+ }
+
++void
+ Ignorf(a)
+- int (*a)();
++ void (*a)(int);
+ {
+
+ a = a;
+ }
+
++void
+ ignorl(a)
+ long a;
+ {
+@@ -824,12 +840,15 @@ int cntch, cntln, cntodd, cntnull;
+ /*
+ * Following routines stolen mercilessly from ex.
+ */
+-putfile(unused)
++void
++putfile(int unused)
+ {
+ line *a1;
+ register char *fp, *lp;
+ register int nib;
+
++ (void)unused;
++
+ a1 = addr1;
+ clrstats();
+ cntln = addr2 - a1 + 1;
+@@ -861,12 +880,14 @@ putfile(unused)
+ cntch += nib;
+ }
+
++void
+ wrerror()
+ {
+
+ syserror();
+ }
+
++void
+ clrstats()
+ {
+
+@@ -880,6 +901,7 @@ clrstats()
+ #define READ 0
+ #define WRITE 1
+
++void
+ get_line(tl)
+ line tl;
+ {
+@@ -890,7 +912,7 @@ get_line(tl)
+ bp = getblock(tl, READ);
+ nl = nleft;
+ tl &= ~OFFMSK;
+- while (*lp++ = *bp++)
++ while ((*lp++ = *bp++) != 0)
+ if (--nl == 0) {
+ bp = getblock(tl += INCRMT, READ);
+ nl = nleft;
+@@ -934,8 +956,8 @@ getblock(atl, iof)
+ return (obuff + off);
+ }
+
++void
+ #ifdef __STDC__
+-int
+ blkio(bloc b, char *buf, ssize_t (*iofcn)(int, void *, size_t))
+ #else /* !__STDC__ */
+ blkio(b, buf, iofcn)
+@@ -950,6 +972,7 @@ blkio(b, buf, iofcn)
+ syserror();
+ }
+
++void
+ syserror()
+ {
+
+@@ -964,10 +987,11 @@ syserror()
+ * allocation and stdio uses malloc.
+ */
+ #ifndef __STDC__
++void
+ xfprintf(fp, fmt, a1, a2, a3, a4, a5)
+ xFILE *fp;
+- char *fmt;
+- char *a1, *a2, *a3, *a4, *a5;
++ const char *fmt;
++ const char *a1, *a2, *a3, *a4, *a5;
+ {
+ char buf[BUFSIZ];
+
+@@ -981,17 +1005,19 @@ xfprintf(fp, fmt, a1, a2, a3, a4, a5)
+ * I do not know whether vsprintf() uses malloc() or not.
+ * So this may be fail, too.
+ */
+-xvfprintf(xFILE *fp, char *fmt, va_list ap)
++void
++xvfprintf(xFILE *fp, const char *fmt, va_list ap)
+ {
+ char buf[BUFSIZ];
+
+ if (fp != xstderr)
+ return;
+- vsprintf(buf, fmt, ap);
++ vsnprintf(buf, sizeof(buf), fmt, ap);
+ write(2, buf, strlen(buf));
+ }
+
+-xfprintf(xFILE *fp, char *fmt, ...)
++void
++xfprintf(xFILE *fp, const char *fmt, ...)
+ {
+ va_list ap;
+
diff --git a/editors/ex/patches/patch-libterm_libterm_h b/editors/ex/patches/patch-libterm_libterm_h
new file mode 100644
index 00000000000..6eb244b2516
--- /dev/null
+++ b/editors/ex/patches/patch-libterm_libterm_h
@@ -0,0 +1,23 @@
+$NetBSD: patch-libterm_libterm_h,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- use const for string constants
+- declare type of function pointer properly
+
+--- libterm/libterm.h.orig 2002-02-04 01:30:04.000000000 +0000
++++ libterm/libterm.h
+@@ -56,9 +56,9 @@
+ #endif
+ #endif
+
+-int tgetent __P((char *, char *));
+-int tgetnum __P((char *));
+-int tgetflag __P((char *));
+-char *tgetstr __P((char *, char **));
+-char *tgoto __P((char *, int, int));
+-int tputs __P((register char *, int, int (*)()));
++int tgetent __P((char *, const char *));
++int tgetnum __P((const char *));
++int tgetflag __P((const char *));
++char *tgetstr __P((const char *, char **));
++const char *tgoto __P((char *, int, int));
++void tputs __P((register const char *, int, int (*)(int)));
diff --git a/editors/ex/patches/patch-libterm_termcap_c b/editors/ex/patches/patch-libterm_termcap_c
new file mode 100644
index 00000000000..5cc467454d7
--- /dev/null
+++ b/editors/ex/patches/patch-libterm_termcap_c
@@ -0,0 +1,77 @@
+$NetBSD: patch-libterm_termcap_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare local functions static
+- avoid implicit int
+- use const for string constants
+
+--- libterm/termcap.c.orig 2004-01-03 14:17:30.000000000 +0000
++++ libterm/termcap.c
+@@ -93,6 +93,7 @@ int tgetent();
+ * against each such name. The normal : terminator after the last
+ * name (before the first field) stops us.
+ */
++static int
+ tnamatch(np)
+ char *np;
+ {
+@@ -121,6 +122,7 @@ tnamatch(np)
+ * entries to say "like an HP2621 but doesn't turn on the labels".
+ * Note that this works because of the left to right scan.
+ */
++static int
+ tnchktc()
+ {
+ register char *p, *q;
+@@ -179,8 +181,10 @@ tnchktc()
+ * from the termcap file. Parse is very rudimentary;
+ * we just notice escaped newlines.
+ */
++int
+ tgetent(bp, name)
+- char *bp, *name;
++ char *bp;
++ const char *name;
+ {
+ register char *cp;
+ register int c;
+@@ -281,8 +285,9 @@ tskip(bp)
+ * a # character. If the option is not found we return -1.
+ * Note that we handle octal numbers beginning with 0.
+ */
++int
+ tgetnum(id)
+- char *id;
++ const char *id;
+ {
+ register int i, base;
+ register char *bp = tbuf;
+@@ -314,8 +319,9 @@ tgetnum(id)
+ * of the buffer. Return 1 if we find the option, or 0 if it is
+ * not given.
+ */
++int
+ tgetflag(id)
+- char *id;
++ const char *id;
+ {
+ register char *bp = tbuf;
+
+@@ -342,7 +348,8 @@ tgetflag(id)
+ */
+ char *
+ tgetstr(id, area)
+- char *id, **area;
++ const char *id;
++ char **area;
+ {
+ register char *bp = tbuf;
+
+@@ -372,7 +379,7 @@ tdecode(str, area)
+ {
+ register char *cp;
+ register int c;
+- register char *dp;
++ register const char *dp;
+ int i;
+
+ cp = *area;
diff --git a/editors/ex/patches/patch-libterm_tgoto_c b/editors/ex/patches/patch-libterm_tgoto_c
new file mode 100644
index 00000000000..bd8bffbc045
--- /dev/null
+++ b/editors/ex/patches/patch-libterm_tgoto_c
@@ -0,0 +1,25 @@
+$NetBSD: patch-libterm_tgoto_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- use const for string constants
+- silence warnings about assignments in conditionals
+
+--- libterm/tgoto.c~ 2002-02-04 01:30:04.000000000 +0000
++++ libterm/tgoto.c
+@@ -83,7 +83,7 @@ char *BC;
+ *
+ * all other characters are ``self-inserting''.
+ */
+-char *
++const char *
+ tgoto(CM, destcol, destline)
+ char *CM;
+ int destcol, destline;
+@@ -104,7 +104,7 @@ toohard:
+ return ("OOPS");
+ }
+ added[0] = 0;
+- while (c = *cp++) {
++ while ((c = *cp++) != 0) {
+ if (c != '%') {
+ *dp++ = c;
+ continue;
diff --git a/editors/ex/patches/patch-libterm_tputs_c b/editors/ex/patches/patch-libterm_tputs_c
new file mode 100644
index 00000000000..e271e59584a
--- /dev/null
+++ b/editors/ex/patches/patch-libterm_tputs_c
@@ -0,0 +1,32 @@
+$NetBSD: patch-libterm_tputs_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- declare void functions void
+- use const for string constants
+- fix up function pointer casting mess
+- silence signed/unsigned compiler warning
+
+--- libterm/tputs.c.orig 2002-02-04 03:15:46.000000000 +0000
++++ libterm/tputs.c
+@@ -71,10 +71,11 @@ char PC;
+ * The number of affected lines is affcnt, and the routine
+ * used to output one character is outc.
+ */
++void
+ tputs(cp, affcnt, outc)
+- register char *cp;
++ register const char *cp;
+ int affcnt;
+- int (*outc)();
++ int (*outc)(int);
+ {
+ register int i = 0;
+ register int mspc10;
+@@ -121,7 +122,7 @@ tputs(cp, affcnt, outc)
+ */
+ if (i == 0)
+ return;
+- if (ospeed <= 0 || ospeed >= (sizeof tmspc10 / sizeof tmspc10[0]))
++ if (ospeed <= 0 || ospeed >= (int)(sizeof tmspc10 / sizeof tmspc10[0]))
+ return;
+
+ /*
diff --git a/editors/ex/patches/patch-printf_c b/editors/ex/patches/patch-printf_c
new file mode 100644
index 00000000000..bbddb4b5035
--- /dev/null
+++ b/editors/ex/patches/patch-printf_c
@@ -0,0 +1,205 @@
+$NetBSD: patch-printf_c,v 1.1 2012/12/28 03:03:09 dholland Exp $
+
+- use standard headers
+ (this is supposed to substitute for libc's printf, so it *must*
+ match stdio.h)
+- use own headers
+- declare local functions static
+- avoid implicit int
+- return values from non-void functions
+- use const for string constants
+- remove/replace code that intentionally uses signed overflow
+
+--- printf.c.orig 2012-12-27 21:57:52.000000000 +0000
++++ printf.c
+@@ -82,6 +82,8 @@ static char sccsid[] = "@(#)printf.c 1.1
+ /* The pwb version this is based on */
+ /* from printf.c:2.2 6/5/79 */
+
++#include <stdio.h>
++
+ #ifndef __STDC__
+ #include "varargs.h"
+ #else
+@@ -95,6 +97,8 @@ extern nl_catd catd;
+ #define catgets(a, b, c, d) (d)
+ #endif
+
++#include "ex.h"
++#include "ex_proto.h"
+ #include "config.h"
+
+ /*
+@@ -115,15 +119,13 @@ extern nl_catd catd;
+
+ static int width, sign, fill;
+
+-extern int putchar __P((int));
+-
+-char *p_dconv __P((long, char *));
+-int p_emit __P((char *, char *));
++static void p_emit __P((const char *, const char *));
+
+ #ifdef __STDC__
+ int vprintf(const char *fmt, va_list ap);
+ #endif
+
++int
+ #ifndef __STDC__
+ printf(va_alist)
+ va_dcl
+@@ -155,14 +157,17 @@ printf(const char *fmt, ...)
+ return ret;
+ }
+
++int
+ vprintf(const char *fmt, va_list ap)
+ {
+ char fcode;
+ int prec;
+ int length,mask1,nbits,n;
+ long int mask2, num;
+- register char *bptr;
+- char *ptr;
++ unsigned long unum;
++ register const char *bptr;
++ register char *vbptr;
++ const char *ptr;
+ char buf[134];
+ #endif /* __STDC__ */
+
+@@ -171,7 +176,7 @@ vprintf(const char *fmt, va_list ap)
+ while ((fcode = *fmt++)!='%') {
+ /* ordinary (non-%) character */
+ if (fcode=='\0')
+- return;
++ return 0;
+ putchar(fcode);
+ }
+ /* length modifier: -1 for h, 1 for l, 0 for none */
+@@ -288,18 +293,18 @@ vprintf(const char *fmt, va_list ap)
+ nbits = 4;
+ }
+ n = (num!=0);
+- bptr = buf + MAXOCT + 3;
++ vbptr = buf + MAXOCT + 3;
+ /* shift and mask for speed */
+ do
+ if (((int) num & mask1) < 10)
+- *--bptr = ((int) num & mask1) + 060;
++ *--vbptr = ((int) num & mask1) + 060;
+ else
+- *--bptr = ((int) num & mask1) + 0127;
+- while (num = (num >> nbits) & mask2);
++ *--vbptr = ((int) num & mask1) + 0127;
++ while ((num = (num >> nbits) & mask2) != 0);
+
+ if (fcode=='o') {
+ if (n)
+- *--bptr = '0';
++ *--vbptr = '0';
+ }
+ else
+ if (!sign && fill <= 0) {
+@@ -308,9 +313,10 @@ vprintf(const char *fmt, va_list ap)
+ width -= 2;
+ }
+ else {
+- *--bptr = fcode;
+- *--bptr = '0';
++ *--vbptr = fcode;
++ *--vbptr = '0';
+ }
++ bptr = vbptr;
+ ptr = buf + MAXOCT + 3;
+ break;
+ case 'D':
+@@ -331,14 +337,20 @@ vprintf(const char *fmt, va_list ap)
+ else
+ num = (long) n;
+ }
+- if (n = (fcode != 'u' && num < 0))
+- num = -num;
++ if ((n = (fcode != 'u' && num < 0)) != 0) {
++ /* avoid overflow on -LONG_MAX */
++ unum = ((unsigned long)-(num + 1)) + 1;
++ }
++ else {
++ unum = (unsigned long) num;
++ }
+ /* now convert to digits */
+- bptr = p_dconv(num, buf);
++ vbptr = p_dconv(unum, buf);
+ if (n)
+- *--bptr = '-';
++ *--vbptr = '-';
+ if (fill == 0)
+ fill = -1;
++ bptr = vbptr;
+ ptr = buf + MAXDIGS + 1;
+ break;
+ default:
+@@ -369,13 +381,15 @@ vprintf(const char *fmt, va_list ap)
+ */
+ char *
+ p_dconv(value, buffer)
+- long value;
++ unsigned long value;
+ char *buffer;
+ {
+ register char *bp;
+- register int svalue;
++ register unsigned int svalue;
++#if 0
+ int n;
+ long lval;
++#endif
+
+ bp = buffer;
+
+@@ -386,6 +400,7 @@ p_dconv(value, buffer)
+ return(bp);
+ }
+
++#if 0 /* original code, undefined behavior */
+ /* develop the leading digit of the value in "n" */
+ n = 0;
+ while (value < 0) {
+@@ -399,6 +414,7 @@ p_dconv(value, buffer)
+
+ /* stash it in buffer[1] to allow for a sign */
+ bp[1] = n + '0';
++#endif
+ /*
+ * Now develop the rest of the digits. Since speed counts here,
+ * we do it in two loops. The first gets "value" down until it
+@@ -417,13 +433,15 @@ p_dconv(value, buffer)
+ *--bp = (svalue % 10) + '0';
+ svalue /= 10;
+ }
+-
++
++#if 0
+ /* fill in intermediate zeroes if needed */
+ if (buffer[1] != '0') {
+ while (bp > buffer + 2)
+ *--bp = '0';
+ --bp;
+ }
++#endif
+ return(bp);
+ }
+
+@@ -439,9 +457,10 @@ p_dconv(value, buffer)
+ * any padding in right-justification (to avoid printing "-3" as
+ * "000-3" where "-0003" was intended).
+ */
++static void
+ p_emit(s, send)
+- register char *s;
+- char *send;
++ register const char *s;
++ const char *send;
+ {
+ char cfill;
+ register int alen;