align with C standard (optional C style); document differences to C style
for print builtin (align with ksh93 ipv GNU bash)
This commit is contained in:
parent
7806fe510a
commit
c8eb13a13f
4
funcs.c
4
funcs.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.131 2009/09/19 15:16:02 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.132 2009/09/19 19:08:46 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@ -604,7 +604,7 @@ c_print(const char **wp)
|
|||||||
while ((c = *s++) != '\0') {
|
while ((c = *s++) != '\0') {
|
||||||
Xcheck(xs, xp);
|
Xcheck(xs, xp);
|
||||||
if ((flags & PO_EXPAND) && c == '\\') {
|
if ((flags & PO_EXPAND) && c == '\\') {
|
||||||
if ((c = unbksl(&s)) == -1) {
|
if ((c = unbksl(&s, false)) == -1) {
|
||||||
/* rejected by generic function */
|
/* rejected by generic function */
|
||||||
switch ((c = *s++)) {
|
switch ((c = *s++)) {
|
||||||
case 'c':
|
case 'c':
|
||||||
|
31
misc.c
31
misc.c
@ -29,7 +29,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.119 2009/09/19 15:16:03 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.120 2009/09/19 19:08:47 tg Exp $");
|
||||||
|
|
||||||
#undef USE_CHVT
|
#undef USE_CHVT
|
||||||
/* XXX conditions correct? */
|
/* XXX conditions correct? */
|
||||||
@ -1456,7 +1456,7 @@ getrusage(int what, struct rusage *ru)
|
|||||||
* unprocessed character (unchanged if rv=-1)
|
* unprocessed character (unchanged if rv=-1)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
unbksl(const char **sp)
|
unbksl(const char **sp, bool cstyle)
|
||||||
{
|
{
|
||||||
int wc, i;
|
int wc, i;
|
||||||
const char *cp = (*sp);
|
const char *cp = (*sp);
|
||||||
@ -1490,7 +1490,21 @@ unbksl(const char **sp)
|
|||||||
/* assume ASCII here as well */
|
/* assume ASCII here as well */
|
||||||
wc = 11;
|
wc = 11;
|
||||||
break;
|
break;
|
||||||
|
case '1':
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
case '8':
|
||||||
|
case '9':
|
||||||
|
if (!cstyle)
|
||||||
|
return (-1);
|
||||||
|
/* FALLTHROUGH */
|
||||||
case '0':
|
case '0':
|
||||||
|
if (cstyle)
|
||||||
|
--cp;
|
||||||
/*
|
/*
|
||||||
* look for an octal number with up to three
|
* look for an octal number with up to three
|
||||||
* digits, not counting the leading zero;
|
* digits, not counting the leading zero;
|
||||||
@ -1510,12 +1524,13 @@ unbksl(const char **sp)
|
|||||||
if (0)
|
if (0)
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case 'x':
|
case 'x':
|
||||||
i = 2;
|
i = cstyle ? -1 : 2;
|
||||||
/*
|
/*
|
||||||
* x: look for a hexadecimal number with up to
|
* x: look for a hexadecimal number with up to
|
||||||
* two digits; convert to raw octet
|
* two (C style: arbitrary) digits; convert
|
||||||
* u: look for a hexadecimal number with up to
|
* to raw octet (C style: Unicode)
|
||||||
* four (U: eight) digits; convert to Unicode
|
* u/U: look for a hexadecimal number with up to
|
||||||
|
* four (U: eight) digits; convert to Unicode
|
||||||
*/
|
*/
|
||||||
wc = 0;
|
wc = 0;
|
||||||
while (i--) {
|
while (i--) {
|
||||||
@ -1531,7 +1546,7 @@ unbksl(const char **sp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (**sp != 'x')
|
if (cstyle || **sp != 'x')
|
||||||
/* Unicode marker */
|
/* Unicode marker */
|
||||||
wc += 0x100;
|
wc += 0x100;
|
||||||
break;
|
break;
|
||||||
|
10
mksh.1
10
mksh.1
@ -1,4 +1,4 @@
|
|||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.186 2009/09/19 18:36:58 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.187 2009/09/19 19:08:47 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.129 2009/05/28 06:09:06 jmc Exp $
|
.\" $OpenBSD: ksh.1,v 1.129 2009/05/28 06:09:06 jmc Exp $
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
||||||
@ -884,6 +884,11 @@ In places where backslashes are expanded, certain C and
|
|||||||
or GNU
|
or GNU
|
||||||
.Nm bash
|
.Nm bash
|
||||||
style escapes are translated.
|
style escapes are translated.
|
||||||
|
Explicitly excluded are
|
||||||
|
.Ql \e" ,
|
||||||
|
.Ql \e' ,
|
||||||
|
and
|
||||||
|
.Ql \e? .
|
||||||
These include
|
These include
|
||||||
.Ql \ea ,
|
.Ql \ea ,
|
||||||
.Ql \eb ,
|
.Ql \eb ,
|
||||||
@ -3308,6 +3313,9 @@ above, as well as
|
|||||||
which is equivalent to using the
|
which is equivalent to using the
|
||||||
.Fl n
|
.Fl n
|
||||||
option.
|
option.
|
||||||
|
Contrary to C escapes, the backslash is retained if followed by an
|
||||||
|
unsupported escape character; octal sequences must be preceded by a
|
||||||
|
.Sq 0 .
|
||||||
.Ql \e
|
.Ql \e
|
||||||
expansion may be inhibited with the
|
expansion may be inhibited with the
|
||||||
.Fl r
|
.Fl r
|
||||||
|
4
sh.h
4
sh.h
@ -134,7 +134,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.341 2009/09/19 15:16:05 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.342 2009/09/19 19:08:48 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R39 2009/09/07"
|
#define MKSH_VERSION "R39 2009/09/07"
|
||||||
|
|
||||||
@ -1587,7 +1587,7 @@ void set_current_wd(char *);
|
|||||||
char *strdup_(const char *, Area *);
|
char *strdup_(const char *, Area *);
|
||||||
char *strndup_(const char *, size_t, Area *);
|
char *strndup_(const char *, size_t, Area *);
|
||||||
#endif
|
#endif
|
||||||
int unbksl(const char **);
|
int unbksl(const char **, bool);
|
||||||
/* shf.c */
|
/* shf.c */
|
||||||
struct shf *shf_open(const char *, int, int, int);
|
struct shf *shf_open(const char *, int, int, int);
|
||||||
struct shf *shf_fdopen(int, int, struct shf *);
|
struct shf *shf_fdopen(int, int, struct shf *);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user