diff --git a/histrap.c b/histrap.c
index cc11921..5b0c421 100644
--- a/histrap.c
+++ b/histrap.c
@@ -26,7 +26,7 @@
 #include <sys/file.h>
 #endif
 
-__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.114 2011/12/30 20:35:29 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.115 2011/12/30 21:00:30 tg Exp $");
 
 Trap sigtraps[NSIG + 1];
 static struct sigaction Sigact_ign;
@@ -35,7 +35,7 @@ static struct sigaction Sigact_ign;
 static int hist_count_lines(unsigned char *, int);
 static int hist_shrink(unsigned char *, int);
 static unsigned char *hist_skip_back(unsigned char *,int *,int);
-static void histload(Source *, unsigned char *, int);
+static void histload(Source *, unsigned char *, size_t);
 static void histinsert(Source *, int, const char *);
 static void writehistfile(int, char *);
 static int sprinkle(int);
@@ -539,7 +539,7 @@ findhist(int start, int fwd, const char *str, int anchored)
  * set history; this means reallocating the dataspace
  */
 void
-sethistsize(int n)
+sethistsize(mksh_ari_t n)
 {
 	if (n > 0 && n != histsize) {
 		int cursize = histptr - history;
@@ -908,7 +908,7 @@ hist_skip_back(unsigned char *base, int *bytes, int no)
  * load the history structure from the stored data
  */
 static void
-histload(Source *s, unsigned char *base, int bytes)
+histload(Source *s, unsigned char *base, size_t bytes)
 {
 	State state;
 	int lno = 0;
diff --git a/sh.h b/sh.h
index 2573cda..cdda08c 100644
--- a/sh.h
+++ b/sh.h
@@ -151,7 +151,7 @@
 #endif
 
 #ifdef EXTERN
-__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.514 2011/12/29 23:36:23 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.515 2011/12/30 21:00:30 tg Exp $");
 #endif
 #define MKSH_VERSION "R40 2011/12/29"
 
@@ -1450,9 +1450,9 @@ EXTERN char ident[IDENT+1];
 
 #define HISTORYSIZE	500	/* size of saved history */
 
-EXTERN char **history;	/* saved commands */
-EXTERN char **histptr;	/* last history item */
-EXTERN int histsize;	/* history size */
+EXTERN char **history;		/* saved commands */
+EXTERN char **histptr;		/* last history item */
+EXTERN mksh_ari_t histsize;	/* history size */
 
 /* user and system time of last j_waitjed job */
 EXTERN struct timeval j_usrtime, j_systime;
@@ -1627,7 +1627,7 @@ void histsave(int *, const char *, bool, bool);
 bool histsync(void);
 #endif
 int c_fc(const char **);
-void sethistsize(int);
+void sethistsize(mksh_ari_t);
 #if HAVE_PERSISTENT_HISTORY
 void sethistfile(const char *);
 #endif
diff --git a/var.c b/var.c
index f2bc740..2dcd815 100644
--- a/var.c
+++ b/var.c
@@ -26,7 +26,7 @@
 #include <sys/sysctl.h>
 #endif
 
-__RCSID("$MirOS: src/bin/mksh/var.c,v 1.138 2011/12/16 20:03:28 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/var.c,v 1.139 2011/12/30 21:00:32 tg Exp $");
 
 /*-
  * Variables
@@ -1220,7 +1220,7 @@ setspec(struct tbl *vp)
 		getopts_reset((int)i);
 		break;
 	case V_HISTSIZE:
-		sethistsize((int)i);
+		sethistsize(i);
 		break;
 	case V_COLUMNS:
 		if (i >= MIN_COLS)