nupa_substitute(), transform while loop
This commit is contained in:
parent
ef1d896cee
commit
0aff4dfaa6
|
|
@ -1200,8 +1200,8 @@ nupa_substitute(dico_t *dico, const char *s, char *r)
|
||||||
const char *kptr = s;
|
const char *kptr = s;
|
||||||
int nnest = 1;
|
int nnest = 1;
|
||||||
|
|
||||||
do
|
for (;;) {
|
||||||
{
|
|
||||||
d = *kptr++;
|
d = *kptr++;
|
||||||
|
|
||||||
if (d == '{')
|
if (d == '{')
|
||||||
|
|
@ -1209,7 +1209,13 @@ nupa_substitute(dico_t *dico, const char *s, char *r)
|
||||||
else if (d == '}')
|
else if (d == '}')
|
||||||
nnest--;
|
nnest--;
|
||||||
|
|
||||||
} while ((nnest != 0) && (d != '\0'));
|
if (nnest == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (d == '\0') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (d == '\0') {
|
if (d == '\0') {
|
||||||
err = message(dico, "Closing \"}\" not found.\n");
|
err = message(dico, "Closing \"}\" not found.\n");
|
||||||
|
|
@ -1247,8 +1253,8 @@ nupa_substitute(dico_t *dico, const char *s, char *r)
|
||||||
const char *kptr = s;
|
const char *kptr = s;
|
||||||
int level = 1;
|
int level = 1;
|
||||||
|
|
||||||
do
|
for (;;) {
|
||||||
{
|
|
||||||
if (kptr >= s_end)
|
if (kptr >= s_end)
|
||||||
d = '\0';
|
d = '\0';
|
||||||
else
|
else
|
||||||
|
|
@ -1261,7 +1267,13 @@ nupa_substitute(dico_t *dico, const char *s, char *r)
|
||||||
else if (d == ')')
|
else if (d == ')')
|
||||||
level--;
|
level--;
|
||||||
|
|
||||||
} while ((kptr <= s_end) && !((d == ')') && (level <= 0)));
|
if (kptr > s_end) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((d == ')') && (level <= 0)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (kptr > s_end) {
|
if (kptr > s_end) {
|
||||||
err = message(dico, "Closing \")\" not found.\n");
|
err = message(dico, "Closing \")\" not found.\n");
|
||||||
|
|
@ -1275,8 +1287,8 @@ nupa_substitute(dico_t *dico, const char *s, char *r)
|
||||||
/* simple identifier may also be string? */
|
/* simple identifier may also be string? */
|
||||||
|
|
||||||
const char *kptr = s;
|
const char *kptr = s;
|
||||||
do
|
for (;;) {
|
||||||
{
|
|
||||||
if (kptr >= s_end)
|
if (kptr >= s_end)
|
||||||
d = '\0';
|
d = '\0';
|
||||||
else
|
else
|
||||||
|
|
@ -1284,7 +1296,13 @@ nupa_substitute(dico_t *dico, const char *s, char *r)
|
||||||
|
|
||||||
kptr++;
|
kptr++;
|
||||||
|
|
||||||
} while ((kptr <= s_end) && (d > ' '));
|
if (kptr > s_end) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (d <= ' ') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = evaluate_variable(dico, &qstr, s - 1, kptr - 1);
|
err = evaluate_variable(dico, &qstr, s - 1, kptr - 1);
|
||||||
s = kptr - 1;
|
s = kptr - 1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue