Got nesting to work

This commit is contained in:
2024-02-11 18:57:54 -06:00
parent 254a644f41
commit fd07dfd962

View File

@@ -169,26 +169,40 @@ autoescapeend:
struct ncdgfile *tmp; struct ncdgfile *tmp;
struct string *buff; struct string *buff;
struct expandfile nest; struct expandfile nest;
int in_escape;
if ((buff = newstring()) == NULL) { if ((buff = newstring()) == NULL) {
goto bufferror; goto bufferror;
} }
in_escape = 0;
/* read nest data into a string */ /* read nest data into a string */
while (i < data->len) { while (i < data->len) {
int c; int c;
if (data->data[i++] != ESCAPE_CHAR) { c = data->data[i++];
appendchar(buff, data->data[i]); if (c != ESCAPE_CHAR) {
appendchar(buff, c);
continue;
}
if (in_escape) {
appendchar(buff, c);
in_escape = 0;
continue; continue;
} }
if (i >= data->len) { if (i >= data->len) {
break; break;
} }
c = data->data[i++]; c = data->data[i++];
if (c == NEST_END) { switch (c) {
case NEST_END:
goto got_nest; goto got_nest;
} default:
in_escape = 1;
case ESCAPE_CHAR:
appendchar(buff, ESCAPE_CHAR); appendchar(buff, ESCAPE_CHAR);
appendchar(buff, c); appendchar(buff, c);
break;
}
} }
fputs("Unexpected EOF in nest\n", stderr); fputs("Unexpected EOF in nest\n", stderr);
return 1; return 1;
@@ -223,7 +237,6 @@ bufferror:
default: default:
fprintf(stderr, "Error in expansion phase: Unknown escape '%c' (0x%x)\n", fprintf(stderr, "Error in expansion phase: Unknown escape '%c' (0x%x)\n",
data->data[i], data->data[i]); data->data[i], data->data[i]);
puts(data->data);
return 1; return 1;
} }
} }