From 8bf6cad8bce368787d058706dacb082ae4f5c426 Mon Sep 17 00:00:00 2001 From: tg Date: Sun, 2 Apr 2017 14:14:08 +0000 Subject: [PATCH] introduce the -T flag to set TEXTMODE (ASCII CR+LF newline support) --- Build.sh | 40 ++++++++++++++++++++++++++++++++++++++-- Makefile | 8 ++++---- check.t | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- mksh.1 | 32 +++++++++++++++++++++++++------- sh.h | 21 ++++++++++++++------- 5 files changed, 130 insertions(+), 24 deletions(-) diff --git a/Build.sh b/Build.sh index 7f8b8ae..e8c0314 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.710 2017/04/02 13:38:01 tg Exp $' +srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.711 2017/04/02 14:14:03 tg Exp $' #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012, 2013, 2014, 2015, 2016, 2017 @@ -495,6 +495,7 @@ check_categories= last= tfn= legacy=0 +textmode=0 for i do @@ -551,6 +552,12 @@ do :-r) r=1 ;; + :-T) + textmode=1 + ;; + :+T) + textmode=0 + ;; :-t) last=t ;; @@ -596,6 +603,13 @@ else add_cppflags -DMKSH_LEGACY_MODE fi +if test $textmode = 0; then + check_categories="$check_categories shell:textmode-no shell:binmode-yes" +else + check_categories="$check_categories shell:textmode-yes shell:binmode-no" + add_cppflags -DMKSH_WITH_TEXTMODE +fi + if test x"$srcdir" = x"."; then CPPFLAGS="-I. $CPPFLAGS" else @@ -856,6 +870,28 @@ OS/2) add_cppflags -DMKSH_UNEMPLOYED add_cppflags -DMKSH_NOPROSPECTOFWORK add_cppflags -DMKSH_NO_LIMITS + add_cppflags -DMKSH_DOSPATH + if test $textmode = 0; then + x='dis' + y='standard OS/2 tools' + else + x='en' + y='standard Unix mksh and other tools' + fi + echo >&2 " +OS/2 Note: mksh can be built with or without 'textmode'. +Without 'textmode' it will behave like a standard Unix utility, +compatible to mksh on all other platforms, using only ASCII LF +(0x0A) as line ending character. This is supported by the mksh +upstream developer. +With 'textmode', mksh will be modified to behave more like other +OS/2 utilities, supporting ASCII CR+LF (0x0D 0x0A) as line ending +at the cost of deviation from standard mksh. This is supported by +the mksh-os2 porter. + +] You are currently compiling with textmode ${x}abled, introducing +] incompatibilities with $y. +" ;; OSF1) HAVE_SIG_T=0 # incompatible @@ -2364,7 +2400,7 @@ addsrcs '!' HAVE_STRLCPY strlcpy.c addsrcs USE_PRINTF_BUILTIN printf.c test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose" -add_cppflags -DMKSH_BUILD_R=541 +add_cppflags -DMKSH_BUILD_R=549 $e $bi$me: Finished configuration testing, now producing output.$ao diff --git a/Makefile b/Makefile index a21d9a1..261b909 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -# $MirOS: src/bin/mksh/Makefile,v 1.155 2016/11/12 00:20:37 tg Exp $ +# $MirOS: src/bin/mksh/Makefile,v 1.156 2017/04/02 14:14:04 tg Exp $ #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011, 2012, 2013, 2014, 2015, 2016 +# 2011, 2012, 2013, 2014, 2015, 2016, 2017 # mirabilos # # Provided that these terms and disclaimer and all copyright notices @@ -57,7 +57,7 @@ CPPFLAGS+= -DMKSH_ASSUME_UTF8 -DMKSH_DISABLE_DEPRECATED \ -DHAVE_SETGROUPS=1 -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 \ -DHAVE_STRLCPY=1 -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \ -DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \ - -DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=541 + -DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=549 CPPFLAGS+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U} CPPFLAGS+= -I. COPTS+= -std=c89 -Wall @@ -100,7 +100,7 @@ regress: ${PROG} check.pl check.t echo export FNORD=666 >regress-dir/.mkshrc HOME=$$(realpath regress-dir) perl ${SRCDIR}/check.pl \ -s ${SRCDIR}/check.t -v -p ./${PROG} \ - -C shell:legacy-no,int:32,fastbox + -C shell:legacy-no,int:32,shell:textmode-no,shell:binmode-yes,fastbox TEST_BUILD_ENV:= TARGET_OS= CPP= TEST_BUILD_ENV+= HAVE_STRING_POOLING=0 diff --git a/check.t b/check.t index 85d58f0..8f63832 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.766 2017/03/26 00:10:21 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.767 2017/04/02 14:14:04 tg Exp $ # -*- mode: sh -*- #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @@ -36,7 +36,7 @@ description: stdin: echo $KSH_VERSION name: KSH_VERSION -category: shell:legacy-no +category: !shell:legacy-yes,!shell:textmode-yes --- expected-stdout: @(#)LEGACY KSH R54 2017/03/25 @@ -45,7 +45,25 @@ description: stdin: echo $KSH_VERSION name: KSH_VERSION-legacy -category: shell:legacy-yes +category: !shell:legacy-no,!shell:textmode-yes +--- +expected-stdout: + @(#)MIRBSD KSH R54 2017/03/25 +TEXTMODE +description: + Check version of shell. +stdin: + echo $KSH_VERSION +name: KSH_VERSION-textmode +category: !shell:legacy-yes,!shell:textmode-no +--- +expected-stdout: + @(#)LEGACY KSH R54 2017/03/25 +TEXTMODE +description: + Check version of legacy shell. +stdin: + echo $KSH_VERSION +name: KSH_VERSION-legacy-textmode +category: !shell:legacy-no,!shell:textmode-no --- name: selftest-1 description: @@ -112,7 +130,7 @@ stdin: expected-stdout: : --- -name: selftest-pathsep-os2 +name: selftest-pathsep-dospath description: Check that $PATHSEP is set correctly. category: os:os2 @@ -9423,6 +9441,7 @@ expected-stdout: name: print-crlf description: Check that CR+LF is shown and read as-is +category: shell:textmode-no stdin: cat >foo <<-'EOF' x='bar @@ -9445,6 +9464,32 @@ expected-stdout: {.5} {foo <<-'EOF' + x='bar + ' # + echo .${#x} # + if test x"$KSH_VERSION" = x""; then # + printf '<%s>' "$x" # + else # + print -nr -- "<$x>" # + fi # + EOF + echo "[$("$__progname" foo)]" + "$__progname" foo | while IFS= read -r line; do + print -r -- "{$line}" + done +expected-stdout: + [.4 + ] + {.4} + {