Fix regression with changed SUBSEP in subscript (#86)

Commit 0d8778bbbb reintroduced a
regression that was fixed in commit
97a4b7ed21. The length of SUBSEP needs to
be rechecked after calling execute(), in case SUBSEP itself has been
changed.

Co-authored-by: Tim van der Molen <tim@kariliq.nl>
This commit is contained in:
Tim van der Molen 2020-07-02 20:22:15 +02:00 committed by GitHub
parent cc19af1308
commit ee5b49bb33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

4
run.c
View File

@ -472,7 +472,7 @@ makearraystring(Node *p, const char *func)
{
char *buf;
int bufsz = recsize;
size_t blen, seplen;
size_t blen;
if ((buf = malloc(bufsz)) == NULL) {
FATAL("%s: out of memory", func);
@ -480,11 +480,11 @@ makearraystring(Node *p, const char *func)
blen = 0;
buf[blen] = '\0';
seplen = strlen(getsval(subseploc));
for (; p; p = p->nnext) {
Cell *x = execute(p); /* expr */
char *s = getsval(x);
size_t seplen = strlen(getsval(subseploc));
size_t nsub = p->nnext ? seplen : 0;
size_t slen = strlen(s);
size_t tlen = blen + slen + nsub;