diff --git a/Build.sh b/Build.sh index 014e7bd..865179f 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.717 2017/04/28 00:27:48 tg Exp $' +srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.718 2017/04/28 02:24:53 tg Exp $' #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012, 2013, 2014, 2015, 2016, 2017 @@ -53,6 +53,17 @@ alll=qwertyuiopasdfghjklzxcvbnm alln=0123456789 alls=______________________________________________________________ +case `echo a | tr '\201' X` in +X) + ebcdic=true + lfcr='\n\r' + ;; +*) + ebcdic=false + lfcr='\012\015' + ;; +esac + genopt_die() { if test -n "$1"; then echo >&2 "E: $*" @@ -425,7 +436,7 @@ ac_header() { na=0 fi hf=$1; shift - hv=`echo "$hf" | tr -d '\012\015' | tr -c $alll$allu$alln $alls` + hv=`echo "$hf" | tr -d "$lfcr" | tr -c $alll$allu$alln $alls` echo "/* NeXTstep bug workaround */" >x for i do @@ -905,6 +916,13 @@ the mksh-os2 porter. ] incompatibilities with $y. " ;; +OS/390) + add_cppflags -DMKSH_ASSUME_UTF8=0; HAVE_ISSET_MKSH_ASSUME_UTF8=1 + : "${SIZE=: size}" + add_cppflags -DMKSH_FOR_Z_OS + add_cppflags -D_ALL_SOURCE + oswarn='; EBCDIC support is incomplete' + ;; OSF1) HAVE_SIG_T=0 # incompatible add_cppflags -D_OSF_SOURCE @@ -1403,8 +1421,16 @@ watcom) DOWARN=-Wc,-we ;; xlc) - save_NOWARN=-qflag=i:e - DOWARN=-qflag=i:i + case $TARGET_OS in + OS/390) + save_NOWARN=-qflag=e + DOWARN=-qflag=i + ;; + *) + save_NOWARN=-qflag=i:e + DOWARN=-qflag=i:i + ;; + esac ;; *) test x"$save_NOWARN" = x"" && save_NOWARN=-Wno-error @@ -1574,10 +1600,24 @@ tendra) ac_flags 1 extansi -Xa ;; xlc) - ac_flags 1 rodata "-qro -qroconst -qroptr" - ac_flags 1 rtcheck -qcheck=all - #ac_flags 1 rtchkc -qextchk # reported broken - ac_flags 1 wformat "-qformat=all -qformat=nozln" + case $TARGET_OS in + OS/390) + # On IBM z/OS, the following are warnings by default: + # CCN3296: #include file not found. + # CCN3944: Attribute "__foo__" is not supported and is ignored. + # CCN3963: The attribute "foo" is not a valid variable attribute and is ignored. + ac_flags 1 halton '-qhaltonmsg=CCN3296 -qhaltonmsg=CCN3944 -qhaltonmsg=CCN3963' + # CCN3290: Unknown macro name FOO on #undef directive. + # CCN4108: The use of keyword '__attribute__' is non-portable. + ac_flags 1 supprss '-qsuppress=CCN3290 -qsuppress=CCN4108' + ;; + *) + ac_flags 1 rodata '-qro -qroconst -qroptr' + ac_flags 1 rtcheck -qcheck=all + #ac_flags 1 rtchkc -qextchk # reported broken + ac_flags 1 wformat '-qformat=all -qformat=nozln' + ;; + esac #ac_flags 1 wp64 -qwarn64 # too verbose for now ;; esac @@ -2658,7 +2698,7 @@ MKSH_A4PB force use of arc4random_pushb MKSH_ASSUME_UTF8 (0=disabled, 1=enabled; default: unset) MKSH_BINSHPOSIX if */sh or */-sh, enable set -o posix MKSH_BINSHREDUCED if */sh or */-sh, enable set -o sh -MKSH_CLS_STRING "\033[;H\033[J" +MKSH_CLS_STRING KSH_ESC_STRING "[;H" KSH_ESC_STRING "[J" MKSH_DEFAULT_EXECSHELL "/bin/sh" (do not change) MKSH_DEFAULT_PROFILEDIR "/etc" (do not change) MKSH_DEFAULT_TMPDIR "/tmp" (do not change) diff --git a/check.t b/check.t index bd7f483..9cdb11d 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.779 2017/04/28 00:38:25 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.780 2017/04/28 02:24:54 tg Exp $ # -*- mode: sh -*- #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @@ -1373,7 +1373,7 @@ file-setup: file 644 "x" cd -P$1 subdir echo 2=$?,${PWD#$bwd/} cd $bwd - chmod 755 renamed + chmod 755 noread renamed 2>/dev/null rm -rf noread link renamed stdin: export TSHELL="$__progname" diff --git a/edit.c b/edit.c index d0dc00a..bfedaef 100644 --- a/edit.c +++ b/edit.c @@ -28,16 +28,16 @@ #ifndef MKSH_NO_CMDLINE_EDITING -__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.330 2017/04/28 00:49:32 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.331 2017/04/28 02:24:56 tg Exp $"); /* * in later versions we might use libtermcap for this, but since external * dependencies are problematic, this has not yet been decided on; another - * good string is "\033c" except on hardware terminals like the DEC VT420 - * which do a full power cycle then... + * good string is KSH_ESC_STRING "c" except on hardware terminals like the + * DEC VT420 which do a full power cycle then... */ #ifndef MKSH_CLS_STRING -#define MKSH_CLS_STRING "\033[;H\033[J" +#define MKSH_CLS_STRING KSH_ESC_STRING "[;H" KSH_ESC_STRING "[J" #endif /* tty driver characters we are interested in */ @@ -2087,7 +2087,7 @@ x_clrtoeol(int lastch, bool line_was_cleared) int col; if (lastch == ' ' && !line_was_cleared && x_term_mode == 1) { - shf_puts("\033[K", shl_out); + shf_puts(KSH_ESC_STRING "[K", shl_out); line_was_cleared = true; } if (lastch == ' ' && line_was_cleared) diff --git a/misc.c b/misc.c index d94a820..a21a31a 100644 --- a/misc.c +++ b/misc.c @@ -5,6 +5,8 @@ * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, * 2011, 2012, 2013, 2014, 2015, 2016, 2017 * mirabilos + * Copyright (c) 2015 + * Daniel Richard G. * * Provided that these terms and disclaimer and all copyright notices * are retained or reproduced in an accompanying document, permission @@ -30,7 +32,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.265 2017/04/28 00:49:33 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.266 2017/04/28 02:24:57 tg Exp $"); #define KSH_CHVT_FLAG #ifdef MKSH_SMALL @@ -1170,11 +1172,11 @@ print_value_quoted(struct shf *shf, const char *s) c = 't'; if (0) /* FALLTHROUGH */ - case 11: + case KSH_VTAB: c = 'v'; if (0) /* FALLTHROUGH */ - case '\033': + case KSH_ESC: /* take E not e because \e is \ in *roff */ c = 'E'; /* FALLTHROUGH */ @@ -1184,7 +1186,12 @@ print_value_quoted(struct shf *shf, const char *s) if (0) /* FALLTHROUGH */ default: - if (c < 32 || c > 0x7E) { +#ifdef MKSH_EBCDIC + if (c < 64 || c == 0xFF) +#else + if (c < 32 || c > 0x7E) +#endif + { /* FALLTHROUGH */ case '\'': shf_fprintf(shf, "\\%03o", c); @@ -2148,7 +2155,7 @@ unbksl(bool cstyle, int (*fg)(void), void (*fp)(int)) break; case 'E': case 'e': - wc = 033; + wc = KSH_ESC; break; case 'f': wc = '\f'; @@ -2163,8 +2170,7 @@ unbksl(bool cstyle, int (*fg)(void), void (*fp)(int)) wc = '\t'; break; case 'v': - /* assume ASCII here as well */ - wc = 11; + wc = KSH_VTAB; break; case '1': case '2': diff --git a/sh.h b/sh.h index 7f9c452..3f680a3 100644 --- a/sh.h +++ b/sh.h @@ -175,7 +175,7 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.822 2017/04/28 01:15:51 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.823 2017/04/28 02:24:58 tg Exp $"); #endif #define MKSH_VERSION "R55 2017/04/27" @@ -257,6 +257,21 @@ typedef MKSH_TYPEDEF_SSIZE_T ssize_t; #ifndef MKSH_INCLUDES_ONLY +/* EBCDIC fun */ + +#if defined(MKSH_FOR_Z_OS) && defined(__MVS__) && defined(__IBMC__) && defined(__CHARSET_LIB) +# if !__CHARSET_LIB && !defined(MKSH_EBCDIC) +# error "Please compile with Build.sh -E for EBCDIC!" +# endif +# if __CHARSET_LIB && defined(MKSH_EBCDIC) +# error "Please compile without -E argument to Build.sh for ASCII!" +# endif +# if __CHARSET_LIB && !defined(_ENHANCED_ASCII_EXT) + /* go all-out on ASCII */ +# define _ENHANCED_ASCII_EXT 0xFFFFFFFF +# endif +#endif + /* extra types */ /* getrusage does not exist on OS/2 kLIBC */ @@ -349,6 +364,8 @@ struct rusage { #define ksh_NSIG (_SIGMAX + 1) #elif defined(NSIG_MAX) #define ksh_NSIG (NSIG_MAX) +#elif defined(MKSH_FOR_Z_OS) +#define ksh_NSIG 40 #else # error Please have your platform define NSIG. #endif @@ -489,6 +506,9 @@ extern int __cdecl setegid(gid_t); #ifdef MKSH_EBCDIC #define KSH_BEL '\a' +#define KSH_ESC 047 +#define KSH_ESC_STRING "\047" +#define KSH_VTAB '\v' #else /* * According to the comments in pdksh, \007 seems to be more portable @@ -496,6 +516,9 @@ extern int __cdecl setegid(gid_t); * sequence if ASCII can be assumed. */ #define KSH_BEL 7 +#define KSH_ESC 033 +#define KSH_ESC_STRING "\033" +#define KSH_VTAB 11 #endif