refactor c_print into a loop
This commit is contained in:
parent
4e855b1be2
commit
4ed09871a9
21
funcs.c
21
funcs.c
@ -38,7 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.307 2016/11/11 18:44:31 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.308 2016/11/11 18:50:09 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@ -433,9 +433,11 @@ c_print(const char **wp)
|
|||||||
|
|
||||||
Xinit(xs, xp, 128, ATEMP);
|
Xinit(xs, xp, 128, ATEMP);
|
||||||
|
|
||||||
if (*wp != NULL && po.chars) {
|
while (*wp != NULL) {
|
||||||
|
if (po.chars) {
|
||||||
do {
|
do {
|
||||||
if (!evaluate(*wp, &po.wc, KSH_RETURN_ERROR, true))
|
if (!evaluate(*wp, &po.wc,
|
||||||
|
KSH_RETURN_ERROR, true))
|
||||||
return (1);
|
return (1);
|
||||||
Xcheck(xs, xp);
|
Xcheck(xs, xp);
|
||||||
if (UTFMODE) {
|
if (UTFMODE) {
|
||||||
@ -447,8 +449,7 @@ c_print(const char **wp)
|
|||||||
} else
|
} else
|
||||||
Xput(xs, xp, po.wc & 0xFF);
|
Xput(xs, xp, po.wc & 0xFF);
|
||||||
} while (*++wp);
|
} while (*++wp);
|
||||||
} else if (*wp != NULL) {
|
} else {
|
||||||
print_read_arg:
|
|
||||||
s = *wp;
|
s = *wp;
|
||||||
while ((c = *s++) != '\0') {
|
while ((c = *s++) != '\0') {
|
||||||
Xcheck(xs, xp);
|
Xcheck(xs, xp);
|
||||||
@ -457,7 +458,7 @@ c_print(const char **wp)
|
|||||||
c = unbksl(false, s_get, s_put);
|
c = unbksl(false, s_get, s_put);
|
||||||
s = s_ptr;
|
s = s_ptr;
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
/* rejected by generic function */
|
/* rejected by generic unbksl */
|
||||||
switch ((c = *s++)) {
|
switch ((c = *s++)) {
|
||||||
case 'c':
|
case 'c':
|
||||||
po.nl = false;
|
po.nl = false;
|
||||||
@ -471,8 +472,9 @@ c_print(const char **wp)
|
|||||||
Xput(xs, xp, '\\');
|
Xput(xs, xp, '\\');
|
||||||
}
|
}
|
||||||
} else if ((unsigned int)c > 0xFF) {
|
} else if ((unsigned int)c > 0xFF) {
|
||||||
/* generic function returned Unicode */
|
/* unbksl returned Unicode */
|
||||||
po.ts[utf_wctomb(po.ts, c - 0x100)] = 0;
|
po.ts[utf_wctomb(po.ts,
|
||||||
|
c - 0x100)] = 0;
|
||||||
c = 0;
|
c = 0;
|
||||||
do {
|
do {
|
||||||
Xput(xs, xp, po.ts[c]);
|
Xput(xs, xp, po.ts[c]);
|
||||||
@ -482,9 +484,8 @@ c_print(const char **wp)
|
|||||||
}
|
}
|
||||||
Xput(xs, xp, c);
|
Xput(xs, xp, c);
|
||||||
}
|
}
|
||||||
if (*++wp != NULL) {
|
if (*++wp != NULL)
|
||||||
Xput(xs, xp, ' ');
|
Xput(xs, xp, ' ');
|
||||||
goto print_read_arg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (po.nl)
|
if (po.nl)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user