57 | 57 |
static void chvt(const Getopt *);
|
58 | 58 |
#endif
|
59 | 59 |
static unsigned int dollarqU(struct shf *, const unsigned char *);
|
60 | |
#ifndef MKSH_SMALL
|
61 | |
static void dollarq8(struct shf *, const unsigned char *);
|
62 | |
#else
|
63 | 60 |
#define dollarq8 dollarqU
|
64 | |
#endif
|
65 | 61 |
|
66 | 62 |
/*XXX this should go away */
|
67 | 63 |
static int make_path(const char *, const char *, char **, XString *, int *);
|
|
1490 | 1486 |
#endif
|
1491 | 1487 |
|
1492 | 1488 |
#define dollarq_Uctrl(c) !ctype(c, C_PRINT)
|
1493 | |
#ifndef MKSH_SMALL
|
1494 | |
#define dollarq_isctrlU(c) dollarq_Uctrl(c)
|
1495 | |
#else
|
1496 | 1489 |
#define dollarq_isctrlU(c) UTFMODE ? dollarq_Uctrl(c) : dollarq_isctrl8(c)
|
1497 | |
#endif
|
1498 | 1490 |
|
1499 | 1491 |
/* escape with $'...' (!MKSH_SMALL: in UTFMODE) */
|
1500 | 1492 |
static unsigned int
|
|
1508 | 1500 |
shf_putc('$', shf);
|
1509 | 1501 |
shf_putc('\'', shf);
|
1510 | 1502 |
while ((c = *s) != 0) {
|
1511 | |
if (
|
1512 | |
#ifdef MKSH_SMALL
|
1513 | |
UTFMODE &&
|
1514 | |
#endif
|
|
1503 |
if (UTFMODE &&
|
1515 | 1504 |
rtt2asc(c) >= 0xC2U && (n = utf_mbtowc(&wc,
|
1516 | 1505 |
(const char *)s)) != (size_t)-1) {
|
1517 | 1506 |
/* valid UTF-8 multibyte character > 0x7F */
|
|
1525 | 1514 |
* interlinear annotations, LTR/RTL mark,
|
1526 | 1515 |
* U+2028, U+2029, U+2066..U+206F, etc.
|
1527 | 1516 |
*/
|
1528 | |
shf_write(s, n, shf);
|
|
1517 |
shf_write((const char *)s, n, shf);
|
1529 | 1518 |
}
|
1530 | 1519 |
s += n;
|
1531 | 1520 |
continue;
|
|
1589 | 1578 |
shf_putc('\'', shf);
|
1590 | 1579 |
return (rv);
|
1591 | 1580 |
}
|
1592 | |
|
1593 | |
#ifndef MKSH_SMALL
|
1594 | |
/* escape with $'...' outside UTFMODE */
|
1595 | |
static void
|
1596 | |
dollarq8(struct shf *shf, const unsigned char *s)
|
1597 | |
{
|
1598 | |
unsigned char c;
|
1599 | |
|
1600 | |
shf_putc('$', shf);
|
1601 | |
shf_putc('\'', shf);
|
1602 | |
while ((c = *s++) != 0) {
|
1603 | |
/* single octet */
|
1604 | |
switch (c) {
|
1605 | |
/* see unbksl() in this file for comments */
|
1606 | |
case KSH_BEL:
|
1607 | |
c = 'a';
|
1608 | |
if (0)
|
1609 | |
/* FALLTHROUGH */
|
1610 | |
case '\b':
|
1611 | |
c = 'b';
|
1612 | |
if (0)
|
1613 | |
/* FALLTHROUGH */
|
1614 | |
case '\f':
|
1615 | |
c = 'f';
|
1616 | |
if (0)
|
1617 | |
/* FALLTHROUGH */
|
1618 | |
case '\n':
|
1619 | |
c = 'n';
|
1620 | |
if (0)
|
1621 | |
/* FALLTHROUGH */
|
1622 | |
case '\r':
|
1623 | |
c = 'r';
|
1624 | |
if (0)
|
1625 | |
/* FALLTHROUGH */
|
1626 | |
case '\t':
|
1627 | |
c = 't';
|
1628 | |
if (0)
|
1629 | |
/* FALLTHROUGH */
|
1630 | |
case KSH_VTAB:
|
1631 | |
c = 'v';
|
1632 | |
if (0)
|
1633 | |
/* FALLTHROUGH */
|
1634 | |
case KSH_ESC:
|
1635 | |
/* take E not e because \e is \ in *roff */
|
1636 | |
c = 'E';
|
1637 | |
/* FALLTHROUGH */
|
1638 | |
case '\\':
|
1639 | |
shf_putc('\\', shf);
|
1640 | |
|
1641 | |
if (0)
|
1642 | |
/* FALLTHROUGH */
|
1643 | |
default:
|
1644 | |
if (dollarq_isctrl8(c)) {
|
1645 | |
/* FALLTHROUGH */
|
1646 | |
case '\'':
|
1647 | |
shf_fprintf(shf, "\\%03o", c);
|
1648 | |
break;
|
1649 | |
}
|
1650 | |
|
1651 | |
shf_putc(c, shf);
|
1652 | |
break;
|
1653 | |
}
|
1654 | |
}
|
1655 | |
shf_putc('\'', shf);
|
1656 | |
}
|
1657 | |
#endif
|
1658 | 1581 |
|
1659 | 1582 |
/*
|
1660 | 1583 |
* Print things in columns and rows - func() is called to format
|