oksh-noxz

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

commit: 5b00926ae0455d1796c135ce5879299652ad3713
parent: f72d80ea2d6029aa8af0a6e338a5c108c3f4db35
author: Brian Callahan <bcallah@openbsd.org>
date:   Tue, 2 Jan 2018 21:36:45 -0500
Update to latest code.
MCVS/Entries86++++++++++----------
MGNUmakefile3+
MMakefile5+-
MREADME.md2+-
Mc_ksh.c5+-
Medit.c10+--
Memacs.c8+-
Meval.c11+--
Mexpand.h6+-
Mhistory.c4+-
Mlex.c8+-
Mlex.h4+-
Mmisc.c76++++++++---------
Mpath.c4+-
Msh.18+-
Mtree.c20+++--
Mvar.c6+-
Mvi.c4+-
18 files changed, 141 insertions(+), 129 deletions(-)
diff --git a/CVS/Entries b/CVS/Entries
@@ -1,46 +1,46 @@
-/CONTRIBUTORS/1.10/Wed Dec 27 20:31:53 2017//
-/LEGAL/1.2/Wed Dec 27 20:31:53 2017//
-/Makefile/1.35/Wed Dec 27 20:32:20 2017//
-/NOTES/1.14/Wed Dec 27 20:31:53 2017//
-/PROJECTS/1.8/Wed Dec 27 20:31:53 2017//
-/README/1.16/Wed Dec 27 20:32:20 2017//
-/alloc.c/1.18/Wed Dec 27 20:32:20 2017//
-/c_ksh.c/1.52/Wed Dec 27 20:32:20 2017//
-/c_sh.c/1.62/Wed Dec 27 20:32:20 2017//
-/c_test.c/1.24/Wed Dec 27 20:32:20 2017//
-/c_test.h/1.4/Wed Dec 27 20:31:53 2017//
-/c_ulimit.c/1.24/Wed Dec 27 20:31:53 2017//
-/config.h/1.16/Wed Dec 27 20:31:53 2017//
-/edit.c/1.58/Wed Dec 27 20:32:20 2017//
-/edit.h/1.11/Wed Dec 27 20:31:53 2017//
-/emacs.c/1.77/Result of merge//
-/eval.c/1.54/Wed Dec 27 20:31:53 2017//
-/exec.c/1.70/Wed Dec 27 20:32:20 2017//
-/expand.h/1.12/Wed Dec 27 20:31:53 2017//
-/expr.c/1.32/Wed Dec 27 20:31:53 2017//
-/history.c/1.75/Result of merge//
-/io.c/1.35/Wed Dec 27 20:31:53 2017//
-/jobs.c/1.55/Wed Dec 27 20:31:53 2017//
-/ksh.1/1.197/Wed Dec 27 20:32:20 2017//
-/lex.c/1.74/Wed Dec 27 20:32:20 2017//
-/lex.h/1.17/Wed Dec 27 20:32:20 2017//
-/mail.c/1.22/Wed Dec 27 20:31:53 2017//
 /main.c/1.85/Result of merge//
-/misc.c/1.61/Wed Dec 27 20:32:21 2017//
-/path.c/1.19/Wed Dec 27 20:31:53 2017//
-/sh.1/1.145/Wed Dec 27 20:32:21 2017//
 /sh.h/1.66/Result of merge//
-/shf.c/1.31/Wed Dec 27 20:31:53 2017//
-/shf.h/1.8/Wed Dec 27 20:31:53 2017//
-/syn.c/1.38/Wed Dec 27 20:31:53 2017//
-/table.c/1.24/Wed Dec 27 20:32:21 2017//
-/table.h/1.13/Wed Dec 27 20:32:21 2017//
-/trap.c/1.30/Wed Dec 27 20:31:53 2017//
-/tree.c/1.27/Wed Dec 27 20:31:53 2017//
-/tree.h/1.12/Wed Dec 27 20:31:53 2017//
-/tty.c/1.16/Wed Dec 27 20:31:53 2017//
-/tty.h/1.6/Wed Dec 27 20:31:53 2017//
-/var.c/1.60/Wed Dec 27 20:32:21 2017//
-/version.c/1.12/Wed Dec 27 20:31:53 2017//
-/vi.c/1.50/Wed Dec 27 20:32:21 2017//
+/CONTRIBUTORS/1.10/Wed Jan  3 02:30:53 2018//
+/LEGAL/1.2/Wed Jan  3 02:30:53 2018//
+/Makefile/1.36/Wed Jan  3 02:31:13 2018//
+/NOTES/1.14/Wed Jan  3 02:30:53 2018//
+/PROJECTS/1.8/Wed Jan  3 02:30:53 2018//
+/README/1.16/Wed Jan  3 02:31:13 2018//
+/alloc.c/1.18/Wed Jan  3 02:30:53 2018//
+/c_ksh.c/1.53/Wed Jan  3 02:31:13 2018//
+/c_sh.c/1.62/Wed Jan  3 02:30:53 2018//
+/c_test.c/1.24/Wed Jan  3 02:30:53 2018//
+/c_test.h/1.4/Wed Jan  3 02:30:53 2018//
+/c_ulimit.c/1.24/Wed Jan  3 02:30:53 2018//
+/config.h/1.16/Wed Jan  3 02:30:53 2018//
+/edit.c/1.59/Wed Jan  3 02:31:13 2018//
+/edit.h/1.11/Wed Jan  3 02:30:53 2018//
+/emacs.c/1.78/Result of merge//
+/eval.c/1.55/Wed Jan  3 02:31:13 2018//
+/exec.c/1.70/Wed Jan  3 02:30:53 2018//
+/expand.h/1.13/Wed Jan  3 02:31:13 2018//
+/expr.c/1.32/Wed Jan  3 02:30:53 2018//
+/history.c/1.76/Result of merge//
+/io.c/1.35/Wed Jan  3 02:30:53 2018//
+/jobs.c/1.55/Wed Jan  3 02:30:53 2018//
+/ksh.1/1.197/Wed Jan  3 02:30:53 2018//
+/lex.c/1.75/Wed Jan  3 02:31:14 2018//
+/lex.h/1.18/Wed Jan  3 02:31:14 2018//
+/mail.c/1.22/Wed Jan  3 02:30:53 2018//
+/misc.c/1.62/Wed Jan  3 02:31:14 2018//
+/path.c/1.20/Wed Jan  3 02:31:14 2018//
+/sh.1/1.146/Wed Jan  3 02:31:14 2018//
+/shf.c/1.31/Wed Jan  3 02:30:54 2018//
+/shf.h/1.8/Wed Jan  3 02:30:54 2018//
+/syn.c/1.38/Wed Jan  3 02:30:54 2018//
+/table.c/1.24/Wed Jan  3 02:30:54 2018//
+/table.h/1.13/Wed Jan  3 02:30:54 2018//
+/trap.c/1.30/Wed Jan  3 02:30:54 2018//
+/tree.c/1.28/Wed Jan  3 02:31:14 2018//
+/tree.h/1.12/Wed Jan  3 02:30:54 2018//
+/tty.c/1.16/Wed Jan  3 02:30:54 2018//
+/tty.h/1.6/Wed Jan  3 02:30:54 2018//
+/var.c/1.61/Wed Jan  3 02:31:14 2018//
+/version.c/1.12/Wed Jan  3 02:30:54 2018//
+/vi.c/1.51/Wed Jan  3 02:31:14 2018//
 D
diff --git a/GNUmakefile b/GNUmakefile
@@ -26,6 +26,7 @@ OBJS +=	portable/common/reallocarray.o portable/linux/setmode.o \
 	portable/linux/signame.o portable/linux/strlcat.o \
 	portable/linux/strlcpy.o portable/common/strtonum.o \
 	portable/linux/unvis.o portable/linux/vis.o
+CFLAGS += -D_GNU_SOURCE
 else ifeq ($(UNAME_S),FreeBSD)
 GROUP =	bin
 OBJS +=	portable/common/reallocarray.o portable/common/vis.o
@@ -39,6 +40,7 @@ else ifeq ($(UNAME_S),Darwin)
 GROUP =	bin
 OBJS += portable/common/reallocarray.o portable/common/strtonum.o \
 	portable/common/vis.o
+CFLAGS += -D_GNU_SOURCE
 else ifeq ($(UNAME_S),OpenBSD)
 GROUP =	bin
 else ifeq ($(findstring CYGWIN,$(UNAME_S)),CYGWIN)
@@ -46,6 +48,7 @@ OBJS +=	portable/common/reallocarray.o portable/linux/setmode.o \
 	portable/linux/signame.o portable/linux/strlcat.o \
 	portable/linux/strlcpy.o portable/common/strtonum.o \
 	portable/linux/unvis.o portable/linux/vis.o
+CFLAGS += -D_GNU_SOURCE
 endif
 
 #
diff --git a/Makefile b/Makefile
@@ -1,4 +1,4 @@
-#	$OpenBSD: Makefile,v 1.35 2017/12/27 13:02:57 millert Exp $
+#	$OpenBSD: Makefile,v 1.36 2018/01/01 19:45:56 millert Exp $
 
 PROG=	ksh
 SRCS=	alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c eval.c \
@@ -6,7 +6,8 @@ SRCS=	alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c eval.c \
 	misc.c path.c shf.c syn.c table.c trap.c tree.c tty.c var.c \
 	version.c vi.c
 
-DEFS=	-Wall -Wshadow -DEMACS -DVI
+WARNINGS=yes
+DEFS=	-DEMACS -DVI
 CFLAGS+=${DEFS} -I. -I${.CURDIR} -I${.CURDIR}/../../lib/libc/gen
 MAN=	ksh.1 sh.1
 
diff --git a/README.md b/README.md
@@ -33,4 +33,4 @@ The rest are BSD or ISC licensed.
 
 Get a tarball
 -------------
-http://devio.us/~bcallah/oksh/oksh-20171109.tar.gz
+http://devio.us/~bcallah/oksh/oksh-20180102.tar.gz
diff --git a/c_ksh.c b/c_ksh.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: c_ksh.c,v 1.52 2017/12/27 13:02:57 millert Exp $	*/
+/*	$OpenBSD: c_ksh.c,v 1.53 2018/01/01 19:45:56 millert Exp $	*/
 
 /*
  * built-in Korn commands: c_*
@@ -1194,7 +1194,8 @@ c_kill(char **wp)
 				ki.num_width++;
 
 			for (i = 0; i < NSIG; i++) {
-				w = sigtraps[i].name ? strlen(sigtraps[i].name) :
+				w = sigtraps[i].name ?
+				    (int)strlen(sigtraps[i].name) :
 				    ki.num_width;
 				if (w > ki.name_width)
 					ki.name_width = w;
diff --git a/edit.c b/edit.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: edit.c,v 1.58 2017/12/27 13:02:57 millert Exp $	*/
+/*	$OpenBSD: edit.c,v 1.59 2018/01/01 19:45:56 millert Exp $	*/
 
 /*
  * Command line editing - common code
@@ -224,13 +224,13 @@ set_editmode(const char *ed)
 #endif
 	};
 	char *rcp;
-	int i;
+	unsigned int ele;
 
 	if ((rcp = strrchr(ed, '/')))
 		ed = ++rcp;
-	for (i = 0; i < NELEM(edit_flags); i++)
-		if (strstr(ed, sh_options[(int) edit_flags[i]].name)) {
-			change_flag(edit_flags[i], OF_SPECIAL, 1);
+	for (ele = 0; ele < NELEM(edit_flags); ele++)
+		if (strstr(ed, sh_options[(int) edit_flags[ele]].name)) {
+			change_flag(edit_flags[ele], OF_SPECIAL, 1);
 			return;
 		}
 }
diff --git a/emacs.c b/emacs.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: emacs.c,v 1.77 2017/12/27 13:02:57 millert Exp $	*/
+/*	$OpenBSD: emacs.c,v 1.78 2018/01/01 19:45:56 millert Exp $	*/
 
 /*
  *  Emacs-like command line editing and history
@@ -1253,7 +1253,7 @@ static char *
 kb_decode(const char *s)
 {
 	static char		l[LINE + 1];
-	int			i, at = 0;
+	unsigned int		i, at = 0;
 
 	l[0] = '\0';
 	for (i = 0; i < strlen(s); i++) {
@@ -1296,7 +1296,7 @@ kb_del(struct kb_entry *k)
 static struct kb_entry *
 kb_add_string(void *func, void *args, char *str)
 {
-	int			i, count;
+	unsigned int		i, count;
 	struct kb_entry		*k;
 	struct x_ftab		*xf = NULL;
 
@@ -1366,7 +1366,7 @@ x_bind(const char *a1, const char *a2,
 	int macro,		/* bind -m */
 	int list)		/* bind -l */
 {
-	int			i;
+	unsigned int		i;
 	struct kb_entry		*k, *kb;
 	char			in[LINE + 1];
 
diff --git a/eval.c b/eval.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: eval.c,v 1.54 2017/08/27 00:29:04 nayden Exp $	*/
+/*	$OpenBSD: eval.c,v 1.55 2018/01/01 19:45:56 millert Exp $	*/
 
 /*
  * Expansion - quoting, separation, substitution, globbing
@@ -1114,10 +1114,11 @@ debunk(char *dp, const char *sp, size_t dlen)
 	char *d, *s;
 
 	if ((s = strchr(sp, MAGIC))) {
-		if (s - sp >= dlen)
+		size_t slen = s - sp;
+		if (slen >= dlen)
 			return dp;
-		memcpy(dp, sp, s - sp);
-		for (d = dp + (s - sp); *s && (d - dp < dlen); s++)
+		memcpy(dp, sp, slen);
+		for (d = dp + slen; *s && (d < dp + dlen); s++)
 			if (!ISMAGIC(*s) || !(*++s & 0x80) ||
 			    !strchr("*+?@! ", *s & 0x7f))
 				*d++ = *s;
@@ -1125,7 +1126,7 @@ debunk(char *dp, const char *sp, size_t dlen)
 				/* extended pattern operators: *+?@! */
 				if ((*s & 0x7f) != ' ')
 					*d++ = *s & 0x7f;
-				if (d - dp < dlen)
+				if (d < dp + dlen)
 					*d++ = '(';
 			}
 		*d = '\0';
diff --git a/expand.h b/expand.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: expand.h,v 1.12 2015/11/08 17:52:43 mmcc Exp $	*/
+/*	$OpenBSD: expand.h,v 1.13 2018/01/01 19:45:56 millert Exp $	*/
 
 /*
  * Expanding strings
@@ -46,7 +46,7 @@ typedef char * XStringP;
 
 /* check if there are at least n bytes left */
 #define	XcheckN(xs, xp, n) do { \
-		    int more = ((xp) + (n)) - (xs).end; \
+		    size_t more = ((xp) + (n)) - (xs).end; \
 		    if (more > 0) \
 			xp = Xcheck_grow_(&xs, xp, more); \
 		} while (0)
@@ -68,7 +68,7 @@ typedef char * XStringP;
 #define	Xsavepos(xs, xp) ((xp) - (xs).beg)
 #define	Xrestpos(xs, xp, n) ((xs).beg + (n))
 
-char *	Xcheck_grow_(XString *xsp, char *xp, int more);
+char *	Xcheck_grow_(XString *xsp, char *xp, size_t more);
 
 /*
  * expandable vector of generic pointers
diff --git a/history.c b/history.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: history.c,v 1.75 2017/11/21 17:57:41 tb Exp $	*/
+/*	$OpenBSD: history.c,v 1.76 2018/01/01 19:45:56 millert Exp $	*/
 
 /*
  * command history
@@ -549,7 +549,7 @@ sethistcontrol(const char *str)
 void
 sethistsize(int n)
 {
-	if (n > 0 && n != histsize) {
+	if (n > 0 && (uint32_t)n != histsize) {
 		int offset = histptr - history;
 
 		/* save most recent history */
diff --git a/lex.c b/lex.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: lex.c,v 1.74 2017/12/27 13:02:57 millert Exp $	*/
+/*	$OpenBSD: lex.c,v 1.75 2018/01/01 19:45:56 millert Exp $	*/
 
 /*
  * lexical analysis and source input
@@ -98,9 +98,9 @@ YYSTYPE	yylval;		/* result from yylex */
 struct ioword *heres[HERES], **herep;
 char	ident[IDENT+1];
 
-char  **history;	/* saved commands */
-char  **histptr;	/* last history item */
-int	histsize;	/* history size */
+char   **history;	/* saved commands */
+char   **histptr;	/* last history item */
+uint32_t histsize;	/* history size */
 
 /* optimized getsc_bn() */
 #define getsc()		(*source->str != '\0' && *source->str != '\\' \
diff --git a/lex.h b/lex.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: lex.h,v 1.17 2017/12/07 01:54:33 tb Exp $	*/
+/*	$OpenBSD: lex.h,v 1.18 2018/01/01 19:45:56 millert Exp $	*/
 
 /*
  * Source input, lexer and parser
@@ -110,7 +110,7 @@ extern char	ident[IDENT+1];
 
 extern char   **history;	/* saved commands */
 extern char   **histptr;	/* last history item */
-extern int	histsize;	/* history size */
+extern uint32_t	histsize;	/* history size */
 
 #endif /* HISTORY */
 
diff --git a/misc.c b/misc.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: misc.c,v 1.61 2017/12/27 13:02:57 millert Exp $	*/
+/*	$OpenBSD: misc.c,v 1.62 2018/01/01 19:45:56 millert Exp $	*/
 
 /*
  * Miscellaneous functions
@@ -105,7 +105,7 @@ str_nsave(const char *s, int n, Area *ap)
 
 /* called from expand.h:XcheckN() to grow buffer */
 char *
-Xcheck_grow_(XString *xsp, char *xp, int more)
+Xcheck_grow_(XString *xsp, char *xp, size_t more)
 {
 	char *old_beg = xsp->beg;
 
@@ -181,11 +181,11 @@ const struct option sh_options[] = {
 int
 option(const char *n)
 {
-	int i;
+	unsigned int ele;
 
-	for (i = 0; i < NELEM(sh_options); i++)
-		if (sh_options[i].name && strcmp(sh_options[i].name, n) == 0)
-			return i;
+	for (ele = 0; ele < NELEM(sh_options); ele++)
+		if (sh_options[ele].name && strcmp(sh_options[ele].name, n) == 0)
+			return ele;
 
 	return -1;
 }
@@ -216,20 +216,21 @@ options_fmt_entry(void *arg, int i, char *buf, int buflen)
 static void
 printoptions(int verbose)
 {
-	int i;
+	unsigned int ele;
 
 	if (verbose) {
 		struct options_info oi;
-		int n, len;
+		unsigned int n;
+		int len;
 
 		/* verbose version */
 		shprintf("Current option settings\n");
 
-		for (i = n = oi.opt_width = 0; i < NELEM(sh_options); i++) {
-			if (sh_options[i].name) {
-				len = strlen(sh_options[i].name);
-				oi.opts[n].name = sh_options[i].name;
-				oi.opts[n++].flag = i;
+		for (ele = n = oi.opt_width = 0; ele < NELEM(sh_options); ele++) {
+			if (sh_options[ele].name) {
+				len = strlen(sh_options[ele].name);
+				oi.opts[n].name = sh_options[ele].name;
+				oi.opts[n++].flag = ele;
 				if (len > oi.opt_width)
 					oi.opt_width = len;
 			}
@@ -239,11 +240,11 @@ printoptions(int verbose)
 	} else {
 		/* short version ala ksh93 */
 		shprintf("set");
-		for (i = 0; i < NELEM(sh_options); i++) {
-			if (sh_options[i].name)
+		for (ele = 0; ele < NELEM(sh_options); ele++) {
+			if (sh_options[ele].name)
 				shprintf(" %co %s",
-					 Flag(i) ? '-' : '+',
-					 sh_options[i].name);
+					 Flag(ele) ? '-' : '+',
+					 sh_options[ele].name);
 		}
 		shprintf("\n");
 	}
@@ -252,13 +253,13 @@ printoptions(int verbose)
 char *
 getoptions(void)
 {
-	int i;
+	unsigned int ele;
 	char m[(int) FNFLAGS + 1];
 	char *cp = m;
 
-	for (i = 0; i < NELEM(sh_options); i++)
-		if (sh_options[i].c && Flag(i))
-			*cp++ = sh_options[i].c;
+	for (ele = 0; ele < NELEM(sh_options); ele++)
+		if (sh_options[ele].c && Flag(ele))
+			*cp++ = sh_options[ele].c;
 	*cp = 0;
 	return str_save(m, ATEMP);
 }
@@ -333,7 +334,8 @@ parse_args(char **argv,
 	char *opts;
 	char *array = NULL;
 	Getopt go;
-	int i, optc, set, sortargs = 0, arrayset = 0;
+	int i, optc, sortargs = 0, arrayset = 0;
+	unsigned int ele;
 
 	/* First call?  Build option strings... */
 	if (cmd_opts[0] == '\0') {
@@ -345,12 +347,12 @@ parse_args(char **argv,
 		/* see set_opts[] declaration */
 		strlcpy(set_opts, "A:o;s", sizeof set_opts);
 		q = set_opts + strlen(set_opts);
-		for (i = 0; i < NELEM(sh_options); i++) {
-			if (sh_options[i].c) {
-				if (sh_options[i].flags & OF_CMDLINE)
-					*p++ = sh_options[i].c;
-				if (sh_options[i].flags & OF_SET)
-					*q++ = sh_options[i].c;
+		for (ele = 0; ele < NELEM(sh_options); ele++) {
+			if (sh_options[ele].c) {
+				if (sh_options[ele].flags & OF_CMDLINE)
+					*p++ = sh_options[ele].c;
+				if (sh_options[ele].flags & OF_SET)
+					*q++ = sh_options[ele].c;
 			}
 		}
 		*p = '\0';
@@ -369,7 +371,7 @@ parse_args(char **argv,
 		opts = set_opts;
 	ksh_getopt_reset(&go, GF_ERROR|GF_PLUSOPT);
 	while ((optc = ksh_getopt(argv, &go, opts)) != -1) {
-		set = (go.info & GI_PLUS) ? 0 : 1;
+		int set = (go.info & GI_PLUS) ? 0 : 1;
 		switch (optc) {
 		case 'A':
 			arrayset = set ? 1 : -1;
@@ -388,14 +390,14 @@ parse_args(char **argv,
 				break;
 			}
 			i = option(go.optarg);
-			if (i >= 0 && set == Flag(i))
+			if (i != -1 && set == Flag(i))
 				/* Don't check the context if the flag
 				 * isn't changing - makes "set -o interactive"
 				 * work if you're already interactive.  Needed
 				 * if the output of "set +o" is to be used.
 				 */
 				;
-			else if (i >= 0 && (sh_options[i].flags & what))
+			else if (i != -1 && (sh_options[i].flags & what))
 				change_flag((enum sh_flag) i, what, set);
 			else {
 				bi_errorf("%s: bad option", go.optarg);
@@ -412,14 +414,14 @@ parse_args(char **argv,
 				sortargs = 1;
 				break;
 			}
-			for (i = 0; i < NELEM(sh_options); i++)
-				if (optc == sh_options[i].c &&
-				    (what & sh_options[i].flags)) {
-					change_flag((enum sh_flag) i, what,
+			for (ele = 0; ele < NELEM(sh_options); ele++)
+				if (optc == sh_options[ele].c &&
+				    (what & sh_options[ele].flags)) {
+					change_flag((enum sh_flag) ele, what,
 					    set);
 					break;
 				}
-			if (i == NELEM(sh_options)) {
+			if (ele == NELEM(sh_options)) {
 				internal_errorf(1, "parse_args: `%c'", optc);
 				return -1; /* not reached */
 			}
@@ -508,7 +510,7 @@ gmatch(const char *s, const char *p, int isfile)
 	 * the pattern.  If check fails, just to a strcmp().
 	 */
 	if (!isfile && !has_globbing(p, pe)) {
-		int len = pe - p + 1;
+		size_t len = pe - p + 1;
 		char tbuf[64];
 		char *t = len <= sizeof(tbuf) ? tbuf :
 		    alloc(len, ATEMP);
diff --git a/path.c b/path.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: path.c,v 1.19 2017/09/03 11:52:01 jca Exp $	*/
+/*	$OpenBSD: path.c,v 1.20 2018/01/01 19:45:56 millert Exp $	*/
 
 #include <sys/stat.h>
 
@@ -228,7 +228,7 @@ do_phys_path(XString *xsp, char *xp, const char *path)
 			p++;
 		if (!*p)
 			break;
-		len = (q = strchr(p, '/')) ? q - p : strlen(p);
+		len = (q = strchr(p, '/')) ? (size_t)(q - p) : strlen(p);
 		if (len == 1 && p[0] == '.')
 			continue;
 		if (len == 2 && p[0] == '.' && p[1] == '.') {
diff --git a/sh.1 b/sh.1
@@ -1,4 +1,4 @@
-.\"	$OpenBSD: sh.1,v 1.145 2017/12/15 20:51:28 jmc Exp $
+.\"	$OpenBSD: sh.1,v 1.146 2017/12/30 07:32:09 jmc Exp $
 .\"
 .\" Copyright (c) 2015 Jason McIntyre <jmc@openbsd.org>
 .\"
@@ -14,7 +14,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd $Mdocdate: December 15 2017 $
+.Dd $Mdocdate: December 30 2017 $
 .Dt SH 1
 .Os
 .Sh NAME
@@ -1165,7 +1165,7 @@ if the user wants to indicate to the shell not to interpret them as such.
 The following characters need quoting if their literal meaning is desired:
 .Bd -literal -offset indent
 | & ; < > ( ) $ \` \e " \(aq <space> <tab> <newline>
-* ?  [ # ~ = %
+* ? [ # ~ = %
 .Ed
 .Pp
 A backslash
@@ -1190,7 +1190,7 @@ A backslash
 .Pq \e
 within double quotes retains its special meaning,
 but only when followed by a backquote, dollar sign,
-double quote, or another backslash.
+double quote, newline, or another backslash.
 An at sign
 .Pq @
 within double quotes has a special meaning
diff --git a/tree.c b/tree.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: tree.c,v 1.27 2015/11/01 15:38:53 mmcc Exp $	*/
+/*	$OpenBSD: tree.c,v 1.28 2018/01/01 19:45:56 millert Exp $	*/
 
 /*
  * command tree climbing
@@ -390,6 +390,15 @@ vfptreef(struct shf *shf, int indent, const char *fmt, va_list va)
 			case 'c':
 				tputc(va_arg(va, int), shf);
 				break;
+			case 'd': /* decimal */
+				n = va_arg(va, int);
+				neg = n < 0;
+				p = ulton(neg ? -n : n, 10);
+				if (neg)
+					*--p = '-';
+				while (*p)
+					tputc(*p++, shf);
+				break;
 			case 's':
 				p = va_arg(va, char *);
 				while (*p)
@@ -399,13 +408,8 @@ vfptreef(struct shf *shf, int indent, const char *fmt, va_list va)
 				p = va_arg(va, char *);
 				tputS(p, shf);
 				break;
-			case 'd': case 'u': /* decimal */
-				n = (c == 'd') ? va_arg(va, int) :
-				    va_arg(va, unsigned int);
-				neg = c=='d' && n<0;
-				p = ulton((neg) ? -n : n, 10);
-				if (neg)
-					*--p = '-';
+			case 'u': /* unsigned decimal */
+				p = ulton(va_arg(va, unsigned int), 10);
 				while (*p)
 					tputc(*p++, shf);
 				break;
diff --git a/var.c b/var.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: var.c,v 1.60 2017/12/27 13:02:57 millert Exp $	*/
+/*	$OpenBSD: var.c,v 1.61 2018/01/01 19:45:56 millert Exp $	*/
 
 #include <sys/stat.h>
 
@@ -306,7 +306,7 @@ str_val(struct tbl *vp)
 		    "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" :
 		    "0123456789abcdefghijklmnopqrstuvwxyz";
 		unsigned long n;
-		int base;
+		unsigned int base;
 
 		s = strbuf + sizeof(strbuf);
 		if (vp->flag & INT_U)
@@ -997,7 +997,7 @@ setspec(struct tbl *vp)
 		break;
 	case V_HISTSIZE:
 		vp->flag &= ~SPECIAL;
-		sethistsize((int) intval(vp));
+		sethistsize(intval(vp));
 		vp->flag |= SPECIAL;
 		break;
 	case V_HISTFILE:
diff --git a/vi.c b/vi.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: vi.c,v 1.50 2017/11/27 04:23:50 tb Exp $	*/
+/*	$OpenBSD: vi.c,v 1.51 2018/01/01 19:45:56 millert Exp $	*/
 
 /*
  *	vi command editing
@@ -238,7 +238,7 @@ x_vi(char *buf, size_t len)
 
 	x_putc('\r'); x_putc('\n'); x_flush();
 
-	if (c == -1 || len <= es->linelen)
+	if (c == -1 || len <= (size_t)es->linelen)
 		return -1;
 
 	if (es->cbuf != buf)