some more small EBCDIC fixes

This commit is contained in:
tg 2017-05-05 19:43:52 +00:00
parent 01b0c107b5
commit 6dc1ab0379
3 changed files with 31 additions and 31 deletions

View File

@ -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 $ # $OpenBSD: th,v 1.1 2013/12/02 20:39:44 millert Exp $
#- #-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011,
@ -881,52 +881,50 @@ first_diff
$char = 1; $char = 1;
} }
} }
return "first difference: line $lineno, char $char (wanted '" return "first difference: line $lineno, char $char (wanted " .
. &format_char($ce) . "', got '" &format_char($ce) . ", got " . &format_char($cg);
. &format_char($cg) . "'";
} }
sub sub
format_char format_char
{ {
local($ch, $s); local($ch, $s, $q);
$ch = ord($_[0]); $ch = ord($_[0]);
$q = "'";
if ($is_ebcdic) { if ($is_ebcdic) {
if ($ch == 0x15) { if ($ch == 0x15) {
return '\n'; return $q . '\n' . $q;
} elsif ($ch == 0x16) { } elsif ($ch == 0x16) {
return '\b'; return $q . '\b' . $q;
} elsif ($ch == 0x05) { } elsif ($ch == 0x05) {
return '\t'; return $q . '\t' . $q;
} elsif ($ch < 64 || $ch == 255) { } elsif ($ch < 64 || $ch == 255) {
return sprintf("X'%02X'", $ch); return sprintf("X'%02X'", $ch);
} }
return chr($ch); return sprintf("'%c' (X'%02X')", $ch, $ch);
} }
$s = sprintf("0x%02X (", $ch);
if ($ch == 10) { if ($ch == 10) {
return '\n'; return $s . $q . '\n' . $q . ')';
} elsif ($ch == 13) { } elsif ($ch == 13) {
return '\r'; return $s . $q . '\r' . $q . ')';
} elsif ($ch == 8) { } elsif ($ch == 8) {
return '\b'; return $s . $q . '\b' . $q . ')';
} elsif ($ch == 9) { } elsif ($ch == 9) {
return '\t'; return $s . $q . '\t' . $q . ')';
} elsif ($ch > 127) { } elsif ($ch > 127) {
$ch -= 127; $ch -= 128;
$s = "M-"; $s .= "M-";
} else {
$s = '';
} }
if ($ch < 32) { if ($ch < 32) {
$s .= '^'; return sprintf("%s^%c)", $s, $ch + ord('@'));
$ch += ord('@');
} elsif ($ch == 127) { } elsif ($ch == 127) {
return $s . "^?"; return $s . "^?)";
} }
return $s . sprintf("%c", $ch); return sprintf("%s'%c')", $s, $ch);
} }
sub sub

16
check.t
View File

@ -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 -*- # -*- mode: sh -*-
#- #-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -1356,10 +1356,10 @@ name: cd-pe
description: description:
Check package for cd -Pe Check package for cd -Pe
need-pass: no need-pass: no
# the mv command fails on Cygwin # the mv command fails on Cygwin and z/OS
# Hurd aborts the testsuite (permission denied) # Hurd aborts the testsuite (permission denied)
# QNX does not find subdir to cd into # 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" file-setup: file 644 "x"
mkdir noread noread/target noread/target/subdir mkdir noread noread/target noread/target/subdir
ln -s noread link ln -s noread link
@ -12742,13 +12742,13 @@ description:
Test what the echo builtin does, and test a compatibility flag. Test what the echo builtin does, and test a compatibility flag.
category: !mnbsdash,!shell:ebcdic-no category: !mnbsdash,!shell:ebcdic-no
stdin: stdin:
"$__progname" -c 'echo -n 1=\\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 \\x2E' -- 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 \\x2E' -- foo bar "$__progname" -o sh -c 'echo -n 3=\\x7C$1; echo -e \\x4B' -- foo bar
expected-stdout: expected-stdout:
1=@foo. 1=@foo.
2=\x7Cfoo-e \x2E 2=\x7Cfoo-e \x4B
3=\x7Cfoo-e \x2E 3=\x7Cfoo-e \x4B
--- ---
name: utilities-getopts-1 name: utilities-getopts-1
description: description:

6
misc.c
View File

@ -32,7 +32,7 @@
#include <grp.h> #include <grp.h>
#endif #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 #define KSH_CHVT_FLAG
#ifdef MKSH_SMALL #ifdef MKSH_SMALL
@ -1134,7 +1134,9 @@ gmatch_cclass(const unsigned char *pat, unsigned char sc)
} }
} }
/* now do the actual range match check */ /* 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; found = true;
/* forced next character? */ /* forced next character? */
if (subc) { if (subc) {