From d8bd19e23e58137db35e1b6611f6580144ef39f0 Mon Sep 17 00:00:00 2001 From: tg Date: Wed, 3 May 2017 13:00:10 +0000 Subject: [PATCH] handle EBCDIC in the testsuite runner (error display) - move categories for that to test.sh, simplifying it - $ebcdic in Build.sh is now for the target, not the buildhost --- Build.sh | 23 ++++++++++++----------- check.pl | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Build.sh b/Build.sh index ad27301..8ec759e 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.721 2017/05/01 20:03:25 tg Exp $' +srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.722 2017/05/03 13:00:09 tg Exp $' #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012, 2013, 2014, 2015, 2016, 2017 @@ -55,11 +55,10 @@ alls=______________________________________________________________ case `echo a | tr '\201' X` in X) - ebcdic=true + # EBCDIC build system lfcr='\n\r' ;; *) - ebcdic=false lfcr='\012\015' ;; esac @@ -507,7 +506,7 @@ last= tfn= legacy=0 textmode=0 -ebcdic=0 +ebcdic=false for i do @@ -532,7 +531,7 @@ do last=c ;; :-E) - ebcdic=1 + ebcdic=true ;; :-G) echo "$me: Do not call me with '-G'!" >&2 @@ -618,10 +617,7 @@ else add_cppflags -DMKSH_LEGACY_MODE fi -if test $ebcdic = 0; then - check_categories="$check_categories shell:ebcdic-no shell:ascii-yes" -else - check_categories="$check_categories shell:ebcdic-yes shell:ascii-no" +if $ebcdic; then add_cppflags -DMKSH_EBCDIC fi @@ -2456,13 +2452,18 @@ cat >test.sh <<-EOF done shift \$((OPTIND - 1)) set -A args -- '$srcdir/check.pl' -p "\$pflag" - x= + if $ebcdic; then + args[\${#args[*]}]=-E + x=shell:ebcdic-yes,shell:ascii-no + else + x=shell:ebcdic-no,shell:ascii-yes + fi for y in "\${check_categories[@]}"; do x=\$x,\$y done if [[ -n \$x ]]; then args[\${#args[*]}]=-C - args[\${#args[*]}]=\${x#,} + args[\${#args[*]}]=\$x fi if (( usee )); then args[\${#args[*]}]=-e diff --git a/check.pl b/check.pl index 7a2e780..d59279c 100644 --- a/check.pl +++ b/check.pl @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.pl,v 1.45 2017/05/01 19:43:23 tg Exp $ +# $MirOS: src/bin/mksh/check.pl,v 1.46 2017/05/03 13:00:10 tg Exp $ # $OpenBSD: th,v 1.1 2013/12/02 20:39:44 millert Exp $ #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, @@ -247,7 +247,7 @@ $nxpassed = 0; %known_tests = (); -if (!getopts('C:e:Pp:s:T:t:U:v')) { +if (!getopts('C:Ee:Pp:s:T:t:U:v')) { print STDERR $Usage; exit 1; } @@ -256,6 +256,7 @@ die "$prog: no program specified (use -p)\n" if !defined $opt_p; die "$prog: no test set specified (use -s)\n" if !defined $opt_s; $test_prog = $opt_p; $verbose = defined $opt_v && $opt_v; +$is_ebcdic = defined $opt_E && $opt_E; $test_set = $opt_s; $temp_base = $opt_T || "/tmp"; $utflocale = $opt_U || (($os eq "hpux") ? "en_US.utf8" : "en_US.UTF-8"); @@ -883,6 +884,20 @@ format_char local($ch, $s); $ch = ord($_[0]); + + if ($is_ebcdic) { + if ($ch == 0x15) { + return '\n'; + } elsif ($ch == 0x16) { + return '\b'; + } elsif ($ch == 0x05) { + return '\t'; + } elsif ($ch < 64 || $ch == 255) { + return sprintf("X'%02X'", $ch); + } + return chr($ch); + } + if ($ch == 10) { return '\n'; } elsif ($ch == 13) {