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

104
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,64 +433,66 @@ c_print(const char **wp)
Xinit(xs, xp, 128, ATEMP); Xinit(xs, xp, 128, ATEMP);
while (*wp != NULL) { if (*wp == NULL)
if (po.chars) { goto print_no_arg;
while (*wp != NULL) { print_read_arg:
s = *wp++; if (po.chars) {
if (*s == '\0') while (*wp != NULL) {
break; s = *wp++;
if (!evaluate(s, &po.wc, if (*s == '\0')
KSH_RETURN_ERROR, true)) break;
return (1); if (!evaluate(s, &po.wc, KSH_RETURN_ERROR, true))
Xcheck(xs, xp); return (1);
if (UTFMODE) { Xcheck(xs, xp);
po.ts[utf_wctomb(po.ts, po.wc)] = 0; if (UTFMODE) {
po.ts[utf_wctomb(po.ts, po.wc)] = 0;
c = 0;
do {
Xput(xs, xp, po.ts[c]);
} while (po.ts[++c]);
} else
Xput(xs, xp, po.wc & 0xFF);
}
} else {
s = *wp++;
while ((c = *s++) != '\0') {
Xcheck(xs, xp);
if (po.exp && c == '\\') {
s_ptr = s;
c = unbksl(false, s_get, s_put);
s = s_ptr;
if (c == -1) {
/* rejected by generic function */
switch ((c = *s++)) {
case 'c':
po.nl = false;
/* AT&T brain damage */
continue;
case '\0':
--s;
c = '\\';
break;
default:
Xput(xs, xp, '\\');
}
} else if ((unsigned int)c > 0xFF) {
/* generic function returned Unicode */
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]);
} while (po.ts[++c]); } while (po.ts[++c]);
} else continue;
Xput(xs, xp, po.wc & 0xFF);
}
} else {
s = *wp++;
while ((c = *s++) != '\0') {
Xcheck(xs, xp);
if (po.exp && c == '\\') {
s_ptr = s;
c = unbksl(false, s_get, s_put);
s = s_ptr;
if (c == -1) {
/* rejected by generic unbksl */
switch ((c = *s++)) {
case 'c':
po.nl = false;
/* AT&T brain damage */
continue;
case '\0':
--s;
c = '\\';
break;
default:
Xput(xs, xp, '\\');
}
} else if ((unsigned int)c > 0xFF) {
/* unbksl returned Unicode */
po.ts[utf_wctomb(po.ts,
c - 0x100)] = 0;
c = 0;
do {
Xput(xs, xp, po.ts[c]);
} while (po.ts[++c]);
continue;
}
} }
Xput(xs, xp, c);
} }
Xput(xs, xp, c);
} }
if (*wp != NULL)
Xput(xs, xp, ' ');
} }
if (*wp != NULL) {
Xput(xs, xp, ' ');
goto print_read_arg;
}
print_no_arg:
if (po.nl) if (po.nl)
Xput(xs, xp, '\n'); Xput(xs, xp, '\n');