Index: bin/sh/Makefile
===================================================================
--- bin/sh/Makefile	(revision 213680)
+++ bin/sh/Makefile	(working copy)
@@ -21,7 +21,7 @@
 LFLAGS= -8	# 8-bit lex scanner for arithmetic
 CFLAGS+=-DSHELL -I. -I${.CURDIR}
 # for debug:
-# CFLAGS+= -g -DDEBUG=2
+#DEBUG_FLAGS+=	-g -DDEBUG=2
 WARNS?=	2
 WFORMAT=0
 
Index: bin/sh/expand.c
===================================================================
--- bin/sh/expand.c	(revision 213680)
+++ bin/sh/expand.c	(working copy)
@@ -43,14 +43,15 @@
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/stat.h>
+#include <dirent.h>
 #include <errno.h>
-#include <dirent.h>
-#include <unistd.h>
+#include <inttypes.h>
+#include <limits.h>
 #include <pwd.h>
+#include <stdio.h>
 #include <stdlib.h>
-#include <limits.h>
-#include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 
 /*
  * Routines to expand arguments to commands.  We have to deal with
@@ -497,9 +498,9 @@
 		exitstatus = waitforjob(in.jp, (int *)NULL);
 	if (quoted == 0)
 		recordregion(startloc, dest - stackblock(), 0);
-	TRACE(("evalbackq: size=%d: \"%.*s\"\n",
-		(dest - stackblock()) - startloc,
-		(dest - stackblock()) - startloc,
+	TRACE(("expbackq: size=%td: \"%.*s\"\n",
+		((dest - stackblock()) - startloc),
+		(int) ((dest - stackblock()) - startloc),
 		stackblock() + startloc));
 	expdest = dest;
 	INTON;
Index: bin/sh/jobs.c
===================================================================
--- bin/sh/jobs.c	(revision 213680)
+++ bin/sh/jobs.c	(working copy)
@@ -38,18 +38,18 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <sys/ioctl.h>
+#include <sys/param.h>
+#include <sys/resource.h>
+#include <sys/stddef.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <errno.h>
 #include <fcntl.h>
+#include <paths.h>
 #include <signal.h>
-#include <errno.h>
-#include <paths.h>
+#include <stdlib.h>
 #include <unistd.h>
-#include <stdlib.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <paths.h>
-#include <sys/ioctl.h>
 
 #include "shell.h"
 #if JOBS
@@ -680,8 +680,8 @@
 		jp->ps = &jp->ps0;
 	}
 	INTON;
-	TRACE(("makejob(%p, %d) returns %%%d\n", (void *)node, nprocs,
-	    jp - jobtab + 1));
+	TRACE(("makejob(%p, %d) returns %%%td\n", (void *)node, nprocs,
+	    (ptrdiff_t) (jp - jobtab + 1)));
 	return jp;
 }
 
@@ -766,7 +766,7 @@
 	pid_t pid;
 	pid_t pgrp;
 
-	TRACE(("forkshell(%%%d, %p, %d) called\n", jp - jobtab, (void *)n,
+	TRACE(("forkshell(%%%td, %p, %d) called\n", (ptrdiff_t) (jp - jobtab), (void *)n,
 	    mode));
 	INTOFF;
 	if (mode == FORK_BG)
@@ -903,7 +903,7 @@
 	int st;
 
 	INTOFF;
-	TRACE(("waitforjob(%%%d) called\n", jp - jobtab + 1));
+	TRACE(("waitforjob(%%%td) called\n", (ptrdiff_t)(jp - jobtab + 1)));
 	while (jp->state == 0)
 		if (dowait(1, jp) == -1)
 			dotrap();
@@ -1004,7 +1004,7 @@
 			if (stopped) {		/* stopped or done */
 				int state = done? JOBDONE : JOBSTOPPED;
 				if (jp->state != state) {
-					TRACE(("Job %d: changing state from %d to %d\n", jp - jobtab + 1, jp->state, state));
+					TRACE(("Job %td: changing state from %d to %d\n", (ptrdiff_t)(jp - jobtab + 1), jp->state, state));
 					jp->state = state;
 					if (jp != job) {
 						if (done && !jp->remembered &&
