add print -A for R53
This commit is contained in:
parent
aa9fa0ebfe
commit
54a8067fd2
12
check.t
12
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.742 2016/07/25 20:36:24 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.743 2016/07/25 20:38:00 tg Exp $
|
||||
# -*- mode: sh -*-
|
||||
#-
|
||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
@ -9130,6 +9130,16 @@ stdin:
|
||||
expected-stdout-pattern:
|
||||
/^4 3 2 <> <\0>$/
|
||||
---
|
||||
name: print-array
|
||||
description:
|
||||
Check that print -A works as expected
|
||||
stdin:
|
||||
print -An 0x20AC 0xC3 0xBC 8#101
|
||||
set -U
|
||||
print -A 0x20AC 0xC3 0xBC 8#102
|
||||
expected-stdout:
|
||||
¬Ã¼A€Ã¼B
|
||||
---
|
||||
name: print-escapes
|
||||
description:
|
||||
Check backslash expansion by the print builtin
|
||||
|
29
funcs.c
29
funcs.c
@ -38,7 +38,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.300 2016/07/25 00:04:42 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.301 2016/07/25 20:38:02 tg Exp $");
|
||||
|
||||
#if HAVE_KILLPG
|
||||
/*
|
||||
@ -288,6 +288,9 @@ c_print(const char **wp)
|
||||
bool po_nl = true, po_exp = true;
|
||||
/* print to history instead of file descriptor / stdout */
|
||||
bool po_hist = false;
|
||||
/* print characters */
|
||||
bool po_char = false;
|
||||
char ts[4];
|
||||
|
||||
if (wp[0][0] == 'e') {
|
||||
/* "echo" builtin */
|
||||
@ -352,13 +355,16 @@ c_print(const char **wp)
|
||||
}
|
||||
} else {
|
||||
/* "print" builtin */
|
||||
const char *opts = "npRrsu,";
|
||||
const char *opts = "AnpRrsu,";
|
||||
const char *emsg;
|
||||
/* print a "--" argument */
|
||||
bool po_pminusminus = false;
|
||||
|
||||
while ((c = ksh_getopt(wp, &builtin_opt, opts)) != -1)
|
||||
switch (c) {
|
||||
case 'A':
|
||||
po_char = true;
|
||||
break;
|
||||
case 'e':
|
||||
po_exp = true;
|
||||
break;
|
||||
@ -407,7 +413,22 @@ c_print(const char **wp)
|
||||
|
||||
Xinit(xs, xp, 128, ATEMP);
|
||||
|
||||
if (*wp != NULL) {
|
||||
if (*wp != NULL && po_char) {
|
||||
mksh_ari_t wc;
|
||||
|
||||
do {
|
||||
if (!evaluate(*wp, &wc, KSH_RETURN_ERROR, true))
|
||||
return (1);
|
||||
if (UTFMODE) {
|
||||
ts[utf_wctomb(ts, wc)] = 0;
|
||||
c = 0;
|
||||
do {
|
||||
Xput(xs, xp, ts[c]);
|
||||
} while (ts[++c]);
|
||||
} else
|
||||
Xput(xs, xp, wc & 0xFF);
|
||||
} while (*++wp);
|
||||
} else if (*wp != NULL) {
|
||||
print_read_arg:
|
||||
s = *wp;
|
||||
while ((c = *s++) != '\0') {
|
||||
@ -432,8 +453,6 @@ c_print(const char **wp)
|
||||
}
|
||||
} else if ((unsigned int)c > 0xFF) {
|
||||
/* generic function returned Unicode */
|
||||
char ts[4];
|
||||
|
||||
ts[utf_wctomb(ts, c - 0x100)] = 0;
|
||||
c = 0;
|
||||
do {
|
||||
|
10
mksh.1
10
mksh.1
@ -1,4 +1,4 @@
|
||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.401 2016/07/24 23:11:51 tg Exp $
|
||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.402 2016/07/25 20:38:04 tg Exp $
|
||||
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
|
||||
.\"-
|
||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||
@ -76,7 +76,7 @@
|
||||
.\" with -mandoc, it might implement .Mx itself, but we want to
|
||||
.\" use our own definition. And .Dd must come *first*, always.
|
||||
.\"
|
||||
.Dd $Mdocdate: July 24 2016 $
|
||||
.Dd $Mdocdate: July 25 2016 $
|
||||
.\"
|
||||
.\" Check which macro package we use, and do other -mdoc setup.
|
||||
.\"
|
||||
@ -3714,7 +3714,7 @@ however, distributors may have added this as builtin as a speed hack.
|
||||
.Pp
|
||||
.It Xo
|
||||
.Ic print
|
||||
.Oo Fl nprsu Ns Oo Ar n Oc \*(Ba
|
||||
.Oo Fl Anprsu Ns Oo Ar n Oc \*(Ba
|
||||
.Fl R Op Fl en Oc
|
||||
.Op Ar argument ...
|
||||
.Xc
|
||||
@ -3750,6 +3750,10 @@ and the
|
||||
option prints to the co-process (see
|
||||
.Sx Co-processes
|
||||
above).
|
||||
The
|
||||
.Fl A
|
||||
option prints the character corresponding to each
|
||||
.Ar argument Ns 's value .
|
||||
.Pp
|
||||
The
|
||||
.Fl R
|
||||
|
Loading…
x
Reference in New Issue
Block a user