goto keeps us from evaluating the loop condition twice in immediate succession

(and shaves off an indentation level)
This commit is contained in:
tg 2016-11-11 19:09:44 +00:00
parent 1c07e75fc0
commit d4b81df050
1 changed files with 53 additions and 51 deletions

20
funcs.c
View File

@ -38,7 +38,7 @@
#endif #endif
#endif #endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.309 2016/11/11 19:02:26 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.310 2016/11/11 19:09:44 tg Exp $");
#if HAVE_KILLPG #if HAVE_KILLPG
/* /*
@ -433,14 +433,15 @@ c_print(const char **wp)
Xinit(xs, xp, 128, ATEMP); Xinit(xs, xp, 128, ATEMP);
while (*wp != NULL) { if (*wp == NULL)
goto print_no_arg;
print_read_arg:
if (po.chars) { if (po.chars) {
while (*wp != NULL) { while (*wp != NULL) {
s = *wp++; s = *wp++;
if (*s == '\0') if (*s == '\0')
break; break;
if (!evaluate(s, &po.wc, if (!evaluate(s, &po.wc, KSH_RETURN_ERROR, true))
KSH_RETURN_ERROR, true))
return (1); return (1);
Xcheck(xs, xp); Xcheck(xs, xp);
if (UTFMODE) { if (UTFMODE) {
@ -461,7 +462,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 unbksl */ /* rejected by generic function */
switch ((c = *s++)) { switch ((c = *s++)) {
case 'c': case 'c':
po.nl = false; po.nl = false;
@ -475,9 +476,8 @@ c_print(const char **wp)
Xput(xs, xp, '\\'); Xput(xs, xp, '\\');
} }
} else if ((unsigned int)c > 0xFF) { } else if ((unsigned int)c > 0xFF) {
/* unbksl returned Unicode */ /* generic function returned Unicode */
po.ts[utf_wctomb(po.ts, po.ts[utf_wctomb(po.ts, c - 0x100)] = 0;
c - 0x100)] = 0;
c = 0; c = 0;
do { do {
Xput(xs, xp, po.ts[c]); Xput(xs, xp, po.ts[c]);
@ -488,9 +488,11 @@ 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;
} }
print_no_arg:
if (po.nl) if (po.nl)
Xput(xs, xp, '\n'); Xput(xs, xp, '\n');