Please review changes against upstream code using SCM,
see the Vcs-* tags in debian/control for its location.

--- mksh-52c.orig/check.t
+++ mksh-52c/check.t
@@ -1,4 +1,4 @@
-# $MirOS: src/bin/mksh/check.t,v 1.728 2016/03/05 15:39:36 tg Exp $
+# $MirOS: src/bin/mksh/check.t,v 1.729 2016/04/09 13:55:09 tg Exp $
 # -*- mode: sh -*-
 #-
 # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@@ -30,7 +30,7 @@
 # (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
 
 expected-stdout:
-	@(#)MIRBSD KSH R52 2016/03/04
+	@(#)MIRBSD KSH R52 2016/04/09
 description:
 	Check version of shell.
 stdin:
@@ -39,7 +39,7 @@ name: KSH_VERSION
 category: shell:legacy-no
 ---
 expected-stdout:
-	@(#)LEGACY KSH R52 2016/03/04
+	@(#)LEGACY KSH R52 2016/04/09
 description:
 	Check version of legacy shell.
 stdin:
@@ -3173,6 +3173,37 @@ expected-stdout:
 expected-stderr-pattern:
 	/(.*can't unlink HISTFILE.*\n)?X*$/
 ---
+name: history-multiline
+description:
+	Check correct multiline history, Debian #783978
+need-ctty: yes
+arguments: !-i!
+env-setup: !ENV=./Env!
+file-setup: file 644 "Env"
+	PS1=X
+	PS2=Y
+stdin:
+	for i in A B C
+	do
+	   print $i
+	   print $i
+	done
+	fc -l
+expected-stdout:
+	A
+	A
+	B
+	B
+	C
+	C
+	1	for i in A B C
+		do
+		   print $i
+		   print $i
+		done
+expected-stderr-pattern:
+	/^XYYYYXX$/
+---
 name: history-e-minus-1
 description:
 	Check if more recent command is executed
--- mksh-52c.orig/exec.c
+++ mksh-52c/exec.c
@@ -23,7 +23,7 @@
 
 #include "sh.h"
 
-__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.172 2016/03/01 18:30:04 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.173 2016/04/09 16:41:07 tg Exp $");
 
 #ifndef MKSH_DEFAULT_EXECSHELL
 #define MKSH_DEFAULT_EXECSHELL	MKSH_UNIXROOT "/bin/sh"
@@ -1084,7 +1084,7 @@ define(const char *name, struct op *t)
 	}
 
 	if (tp->flag & ALLOC) {
-		tp->flag &= ~(ISSET|ALLOC);
+		tp->flag &= ~(ISSET|ALLOC|FKSH);
 		tfree(tp->val.t, tp->areap);
 	}
 
--- mksh-52c.orig/lex.c
+++ mksh-52c/lex.c
@@ -23,7 +23,7 @@
 
 #include "sh.h"
 
-__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.222 2016/03/01 19:22:31 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.223 2016/04/09 13:55:11 tg Exp $");
 
 /*
  * states while lexing word
@@ -1350,7 +1350,8 @@ getsc_line(Source *s)
 		alarm(ksh_tmout);
 	}
 	if (interactive) {
-		histsave(&s->line, NULL, HIST_FLUSH, true);
+		if (cur_prompt == PS1)
+			histsave(&s->line, NULL, HIST_FLUSH, true);
 		change_winsz();
 	}
 #ifndef MKSH_NO_CMDLINE_EDITING
--- mksh-52c.orig/mksh.1
+++ mksh-52c/mksh.1
@@ -1,4 +1,4 @@
-.\" $MirOS: src/bin/mksh/mksh.1,v 1.392 2016/03/04 18:28:41 tg Exp $
+.\" $MirOS: src/bin/mksh/mksh.1,v 1.393 2016/03/06 21:01:28 tg Exp $
 .\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
 .\"-
 .\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
@@ -76,7 +76,7 @@
 .\" with -mandoc, it might implement .Mx itself, but we want to
 .\" use our own definition. And .Dd must come *first*, always.
 .\"
-.Dd $Mdocdate: March 4 2016 $
+.Dd $Mdocdate: March 6 2016 $
 .\"
 .\" Check which macro package we use, and do other -mdoc setup.
 .\"
@@ -3097,7 +3097,7 @@ The specified editing command is bound t
 .Ar string ,
 which should consist of a control character
 optionally preceded by one of the two prefix characters
-and optionally succeded by a tilde character.
+and optionally succeeded by a tilde character.
 Future input of the
 .Ar string
 will cause the editing command to be immediately invoked.
@@ -3903,7 +3903,7 @@ then leading whitespace will be removed
 You might want to use
 .Ic while IFS= read \-r foo; do ...; done
 for pristine I/O.
-Similarily, when using the
+Similarly, when using the
 .Fl a
 option, use of the
 .Fl r
--- mksh-52c.orig/sh.h
+++ mksh-52c/sh.h
@@ -175,9 +175,9 @@
 #endif
 
 #ifdef EXTERN
-__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.768 2016/03/04 18:28:42 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.769 2016/04/09 13:55:12 tg Exp $");
 #endif
-#define MKSH_VERSION "R52 2016/03/04"
+#define MKSH_VERSION "R52 2016/04/09"
 
 /* arithmetic types: C implementation */
 #if !HAVE_CAN_INTTYPES
