diff --git a/check.pl b/check.pl index bb79844..5bb2333 100644 --- a/check.pl +++ b/check.pl @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.pl,v 1.47 2017/05/03 14:51:15 tg Exp $ +# $MirOS: src/bin/mksh/check.pl,v 1.48 2017/05/05 19:43:50 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, @@ -881,52 +881,50 @@ first_diff $char = 1; } } - return "first difference: line $lineno, char $char (wanted '" - . &format_char($ce) . "', got '" - . &format_char($cg) . "'"; + return "first difference: line $lineno, char $char (wanted " . + &format_char($ce) . ", got " . &format_char($cg); } sub format_char { - local($ch, $s); + local($ch, $s, $q); $ch = ord($_[0]); + $q = "'"; if ($is_ebcdic) { if ($ch == 0x15) { - return '\n'; + return $q . '\n' . $q; } elsif ($ch == 0x16) { - return '\b'; + return $q . '\b' . $q; } elsif ($ch == 0x05) { - return '\t'; + return $q . '\t' . $q; } elsif ($ch < 64 || $ch == 255) { return sprintf("X'%02X'", $ch); } - return chr($ch); + return sprintf("'%c' (X'%02X')", $ch, $ch); } + $s = sprintf("0x%02X (", $ch); if ($ch == 10) { - return '\n'; + return $s . $q . '\n' . $q . ')'; } elsif ($ch == 13) { - return '\r'; + return $s . $q . '\r' . $q . ')'; } elsif ($ch == 8) { - return '\b'; + return $s . $q . '\b' . $q . ')'; } elsif ($ch == 9) { - return '\t'; + return $s . $q . '\t' . $q . ')'; } elsif ($ch > 127) { - $ch -= 127; - $s = "M-"; - } else { - $s = ''; + $ch -= 128; + $s .= "M-"; } if ($ch < 32) { - $s .= '^'; - $ch += ord('@'); + return sprintf("%s^%c)", $s, $ch + ord('@')); } elsif ($ch == 127) { - return $s . "^?"; + return $s . "^?)"; } - return $s . sprintf("%c", $ch); + return sprintf("%s'%c')", $s, $ch); } sub diff --git a/check.t b/check.t index 3045159..12dbc56 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.789 2017/05/03 17:48:06 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.790 2017/05/05 19:43:50 tg Exp $ # -*- mode: sh -*- #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @@ -1356,10 +1356,10 @@ name: cd-pe description: Check package for cd -Pe need-pass: no -# the mv command fails on Cygwin +# the mv command fails on Cygwin and z/OS # Hurd aborts the testsuite (permission denied) # QNX does not find subdir to cd into -category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!nosymlink +category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!os:os390,!nosymlink file-setup: file 644 "x" mkdir noread noread/target noread/target/subdir ln -s noread link @@ -12742,13 +12742,13 @@ description: Test what the echo builtin does, and test a compatibility flag. category: !mnbsdash,!shell:ebcdic-no stdin: - "$__progname" -c 'echo -n 1=\\x7C$1; echo -e \\x2E' -- foo bar - "$__progname" -o posix -c 'echo -n 2=\\x7C$1; echo -e \\x2E' -- foo bar - "$__progname" -o sh -c 'echo -n 3=\\x7C$1; echo -e \\x2E' -- foo bar + "$__progname" -c 'echo -n 1=\\x7C$1; echo -e \\x4B' -- foo bar + "$__progname" -o posix -c 'echo -n 2=\\x7C$1; echo -e \\x4B' -- foo bar + "$__progname" -o sh -c 'echo -n 3=\\x7C$1; echo -e \\x4B' -- foo bar expected-stdout: 1=@foo. - 2=\x7Cfoo-e \x2E - 3=\x7Cfoo-e \x2E + 2=\x7Cfoo-e \x4B + 3=\x7Cfoo-e \x4B --- name: utilities-getopts-1 description: diff --git a/misc.c b/misc.c index 4ad337d..3cc9df5 100644 --- a/misc.c +++ b/misc.c @@ -32,7 +32,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.275 2017/05/03 17:48:08 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.276 2017/05/05 19:43:52 tg Exp $"); #define KSH_CHVT_FLAG #ifdef MKSH_SMALL @@ -1134,7 +1134,9 @@ gmatch_cclass(const unsigned char *pat, unsigned char sc) } } /* now do the actual range match check */ - if (lc != 0 && /* c != 0 && */ lc <= sc && sc <= c) + if (lc != 0 /* && c != 0 */ && + asciibetical(lc) <= asciibetical(sc) && + asciibetical(sc) <= asciibetical(c)) found = true; /* forced next character? */ if (subc) {