From b6ce7480647c549dbc2027938b628ff1b0f9165b Mon Sep 17 00:00:00 2001
From: tg <tg@mirbsd.org>
Date: Sat, 16 May 2009 18:40:09 +0000
Subject: [PATCH] =?UTF-8?q?=E2=80=A2=20remove=20=E2=80=9C#if=200=E2=80=9D?=
 =?UTF-8?q?=20and=20=E2=80=9C#ifdef=20notdef=E2=80=9D=20style=20old=20debu?=
 =?UTF-8?q?gging=20code=20=E2=80=A2=20expose=20=E2=80=9C#ifdef=20MKSH=5FMI?=
 =?UTF-8?q?DNIGHTBSD01ASH=5FCOMPAT=E2=80=9D=20just=20in=20case=20they=20de?=
 =?UTF-8?q?cide=20to=20=20=20require=20it=20and=20show=20it=20in=20the=20k?=
 =?UTF-8?q?sh=20version=20automatically=20=E2=80=A2=20sync=20the=20use=20o?=
 =?UTF-8?q?f=20non-ASCII=20characters=20over=20files=20(unification)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Build.sh  | 12 ++++++------
 check.t   | 10 +++++-----
 eval.c    | 24 +-----------------------
 exec.c    |  4 ++--
 funcs.c   |  4 ++--
 histrap.c |  4 ++--
 main.c    |  4 ++--
 misc.c    |  8 +-------
 mksh.1    |  4 ++--
 sh.h      |  9 +++++++--
 10 files changed, 30 insertions(+), 53 deletions(-)

diff --git a/Build.sh b/Build.sh
index f22bb42..2b3b5c8 100644
--- a/Build.sh
+++ b/Build.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
-srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.392 2009/05/16 16:59:31 tg Exp $'
+srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.393 2009/05/16 18:40:03 tg Stab $'
 #-
 # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009
 #	Thorsten Glaser <tg@mirbsd.org>
@@ -22,7 +22,7 @@ srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.392 2009/05/16 16:59:31 tg Exp $'
 # Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS
 # CPPFLAGS recognised:	MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NOPWNAM MKSH_NOVI
 #			MKSH_CLS_STRING MKSH_BINSHREDUCED MKSH_UNEMPLOYED
-#			MKSH_CONSERVATIVE_FDS
+#			MKSH_CONSERVATIVE_FDS MKSH_MIDNIGHTBSD01ASH_COMPAT
 
 LC_ALL=C
 export LC_ALL
@@ -453,8 +453,8 @@ $e $bi$me: Scanning for functions... please ignore any errors.$ao
 # Compiler: which one?
 #
 # notes:
-# – ICC defines __GNUC__ too
-# – GCC defines __hpux too
+# - ICC defines __GNUC__ too
+# - GCC defines __hpux too
 # - LLVM+clang defines __GNUC__ too
 # - nwcc defines __GNUC__ too
 CPP="$CC -E"
@@ -520,7 +520,7 @@ rm -f x
 echo 'int main(void) { return (0); }' >scn.c
 case $ct in
 ack)
-	# work around “the famous ACK const bug”
+	# work around "the famous ACK const bug"
 	CPPFLAGS="-Dconst= $CPPFLAGS"
 	;;
 adsp)
@@ -1167,7 +1167,7 @@ EOF
 
 ac_test setmode mknod 1 <<-'EOF'
 	#if defined(__MSVCRT__) || defined(__CYGWIN__)
-	/* force a failure: Win32 setmode() is not what we want… */
+	/* force a failure: Win32 setmode() is not what we want... */
 	int main(void) { return (thiswillneverbedefinedIhope()); }
 	#else
 	#include <unistd.h>
diff --git a/check.t b/check.t
index 38622a7..a48d758 100644
--- a/check.t
+++ b/check.t
@@ -1,25 +1,25 @@
-# $MirOS: src/bin/mksh/check.t,v 1.276 2009/05/16 16:59:32 tg Exp $
+# $MirOS: src/bin/mksh/check.t,v 1.277 2009/05/16 18:40:04 tg Exp $
 # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
 # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
 # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
 #-
-# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009
 #	Thorsten Glaser <tg@mirbsd.org>
 #
 # Provided that these terms and disclaimer and all copyright notices
 # are retained or reproduced in an accompanying document, permission
-# is granted to deal in this work without restriction, including un-
+# is granted to deal in this work without restriction, including un‐
 # limited rights to use, publicly perform, distribute, sell, modify,
 # merge, give away, or sublicence.
 #
-# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
+# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
 # the utmost extent permitted by applicable law, neither express nor
 # implied; without malicious intent or gross negligence. In no event
 # may a licensor, author or contributor be held liable for indirect,
 # direct, other damage, loss, or other issues arising in any way out
 # of dealing in the work, even if advised of the possibility of such
 # damage or existence of a defect, except proven that it results out
-# of said person's immediate fault when using the work as intended.
+# of said person’s immediate fault when using the work as intended.
 #-
 # You may also want to test IFS with the script at
 # http://www.research.att.com/~gsf/public/ifs.sh
diff --git a/eval.c b/eval.c
index afee2af..063951e 100644
--- a/eval.c
+++ b/eval.c
@@ -22,7 +22,7 @@
 
 #include "sh.h"
 
-__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.56 2009/05/16 16:59:34 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.57 2009/05/16 18:40:05 tg Exp $");
 
 #ifdef MKSH_SMALL
 #define MKSH_NOPWNAM
@@ -426,16 +426,6 @@ expand(const char *cp,	/* input word */
 						s = wdcopy(sp, ATEMP);
 						p = s + (wdscan(sp, ADELIM) - sp);
 						d = s + (wdscan(sp, CSUBST) - sp);
-#if 0
-						fprintf(stderr,
-						    "D: s=%p 〈%s〉\n"
-						    "   p=%p 〈%s〉\n"
-						    "   d=%p 〈%s〉\n",
-						    s, wdstrip(s, true, false),
-						    p, wdstrip(p, true, false),
-						    d, wdstrip(d, true, false));
-						fflush(stderr);
-#endif
 						if (p >= d)
 							goto unwind_substsyn;
 						p[-2] = EOS;
@@ -465,12 +455,6 @@ expand(const char *cp,	/* input word */
 							else
 								s++;
 						*d = '\0';
-#if 0
-						fprintf(stderr,
-						    "D: 〔%s|%s〕→〔%s〕\n",
-						    tpat0, pat, rrep);
-						fflush(stderr);
-#endif
 						afree(tpat0, ATEMP);
 
 						/* reject empty pattern */
@@ -497,12 +481,6 @@ expand(const char *cp,	/* input word */
 							tpat2 = tpat1 + 2;
 						}
  again_repl:
-#if 0
-						fprintf(stderr,
-						    "D: 「%s」 ← 〔%s|%s〕\n",
-						    s, tpat0, rrep);
-						fflush(stderr);
-#endif
 						/* this would not be necessary if gmatchx would return
 						 * the start and end values of a match found, like re*
 						 */
diff --git a/exec.c b/exec.c
index a3d4553..66411a6 100644
--- a/exec.c
+++ b/exec.c
@@ -22,7 +22,7 @@
 
 #include "sh.h"
 
-__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.55 2009/05/16 16:59:35 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.56 2009/05/16 18:40:05 tg Exp $");
 
 static int comexec(struct op *, struct tbl *volatile, const char **,
     int volatile, volatile int *);
@@ -772,7 +772,7 @@ scriptexec(struct op *tp, const char **ap)
 		    (fd == /* ECOFF_M68K */ 0x0150 || fd == 0x5001) ||
 		    (fd == /* ECOFF_SH */   0x0500 || fd == 0x0005) ||
 		    (fd == 0x7F45 && buf[2] == 'L' && buf[3] == 'F') ||
-		    (fd == /* “MZ” */ 0x4D5A) ||
+		    (fd == /* "MZ" */ 0x4D5A) ||
 		    (fd == /* gzip */ 0x1F8B))
 			errorf("%s: not executable: magic %04X", tp->str, fd);
 	}
diff --git a/funcs.c b/funcs.c
index dd360a3..c2fb424 100644
--- a/funcs.c
+++ b/funcs.c
@@ -25,7 +25,7 @@
 
 #include "sh.h"
 
-__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.106 2009/05/16 17:33:10 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.107 2009/05/16 18:40:06 tg Exp $");
 
 /* A leading = means assignments before command are kept;
  * a leading * means a POSIX special builtin;
@@ -2419,7 +2419,7 @@ c_mknod(const char **wp)
 	return (rv);
  c_mknod_usage:
 #if 0
-	/* XXX doesn’t help */
+	/* XXX doesn't help */
 	builtin_argv0 = NULL;
 #endif
 	bi_errorf("usage: mknod [-m mode] name [b | c] major minor");
diff --git a/histrap.c b/histrap.c
index ab07683..1425b0f 100644
--- a/histrap.c
+++ b/histrap.c
@@ -26,11 +26,11 @@
 #include <sys/file.h>
 #endif
 
-__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.80 2009/05/16 16:59:36 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.81 2009/05/16 18:40:06 tg Exp $");
 
 /*-
  * MirOS: This is the default mapping type, and need not be specified.
- * IRIX doesn’t have this constant.
+ * IRIX doesn't have this constant.
  */
 #ifndef MAP_FILE
 #define MAP_FILE	0
diff --git a/main.c b/main.c
index 1d660ae..9da984e 100644
--- a/main.c
+++ b/main.c
@@ -33,7 +33,7 @@
 #include <locale.h>
 #endif
 
-__RCSID("$MirOS: src/bin/mksh/main.c,v 1.126 2009/05/16 16:59:37 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/main.c,v 1.127 2009/05/16 18:40:07 tg Exp $");
 
 extern char **environ;
 
@@ -295,7 +295,7 @@ main(int argc, const char *argv[])
 		s = pushs(SSTRING, ATEMP);
 		if (!(s->start = s->str = argv[argi++]))
 			errorf("-c requires an argument");
-#if 0
+#ifdef MKSH_MIDNIGHTBSD01ASH_COMPAT
 		/* compatibility to MidnightBSD 0.1 /bin/sh (not desired) */
 		if (argv[argi] && !strcmp(argv[argi], "--"))
 			++argi;
diff --git a/misc.c b/misc.c
index 7db33ec..35ba8e4 100644
--- a/misc.c
+++ b/misc.c
@@ -29,7 +29,7 @@
 #include <grp.h>
 #endif
 
-__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.105 2009/05/16 16:59:38 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.106 2009/05/16 18:40:07 tg Exp $");
 
 #undef USE_CHVT
 #if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
@@ -518,12 +518,6 @@ gmatchx(const char *s, const char *p, bool isfile)
 	if (s == NULL || p == NULL)
 		return 0;
 
-#if 0
-	/* debugging output */
-	fprintf(stderr, "gmatchx:\n\tstring =`%s`\n\tpattern=`%s`\n", s, p);
-	fflush(stderr);
-#endif
-
 	se = s + strlen(s);
 	pe = p + strlen(p);
 	/* isfile is false iff no syntax check has been done on
diff --git a/mksh.1 b/mksh.1
index 273d57e..3726f46 100644
--- a/mksh.1
+++ b/mksh.1
@@ -1,7 +1,7 @@
-.\" $MirOS: src/bin/mksh/mksh.1,v 1.165 2009/05/16 16:59:38 tg Exp $
+.\" $MirOS: src/bin/mksh/mksh.1,v 1.166 2009/05/16 18:40:08 tg Exp $
 .\" $OpenBSD: ksh.1,v 1.128 2009/03/06 12:28:36 jmc Exp $
 .\"-
-.\" Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
 .\"	Thorsten Glaser <tg@mirbsd.org>
 .\"
 .\" Provided that these terms and disclaimer and all copyright notices
diff --git a/sh.h b/sh.h
index f5f1d75..d903e03 100644
--- a/sh.h
+++ b/sh.h
@@ -122,7 +122,7 @@
 #define __SCCSID(x)	__IDSTRING(sccsid,x)
 
 #ifdef EXTERN
-__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.297 2009/05/16 16:59:39 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.298 2009/05/16 18:40:09 tg Exp $");
 #endif
 #define MKSH_VERSION "R38 2009/05/16"
 
@@ -341,7 +341,12 @@ EXTERN uid_t ksheuid;		/* effective uid of shell */
 EXTERN int exstat;		/* exit status */
 EXTERN int subst_exstat;	/* exit status of last $(..)/`..` */
 EXTERN const char *safe_prompt; /* safe prompt if PS1 substitution fails */
-EXTERN const char initvsn[] I__("KSH_VERSION=@(#)MIRBSD KSH " MKSH_VERSION);
+EXTERN const char initvsn[] I__("KSH_VERSION=@(#)MIRBSD KSH "
+    MKSH_VERSION
+#ifdef MKSH_MIDNIGHTBSD01ASH_COMPAT
+    "MidnightBSD-0.1-ash-compat"
+#endif
+    );
 #define KSH_VERSION	(initvsn + /* "KSH_VERSION=@(#)" */ 16)
 
 /*