X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/agedu/blobdiff_plain/522edd92f2bbef89ccd1dd0a3e874516fb47e2ef..0089cdbb132d9486413c0c1a5fa2fba7571e8dae:/agedu.c?ds=inline diff --git a/agedu.c b/agedu.c index f823121..9ff6bb8 100644 --- a/agedu.c +++ b/agedu.c @@ -949,7 +949,9 @@ int main(int argc, char **argv) ctx->progress = progress; { struct winsize ws; - if (progress && ioctl(2, TIOCGWINSZ, &ws) == 0) + if (progress && + ioctl(2, TIOCGWINSZ, &ws) == 0 && + ws.ws_col > 0) ctx->progwidth = ws.ws_col - 1; else ctx->progwidth = 79; @@ -1088,6 +1090,9 @@ int main(int argc, char **argv) int i; if (totalsize - indexbuild_realsize(ib) < delta) { + const void *oldfile = mappedfile; + ptrdiff_t diff; + /* * Unmap the file, grow it, and remap it. */ @@ -1113,6 +1118,14 @@ int main(int argc, char **argv) indexbuild_rebase(ib, mappedfile); triewalk_rebase(tw, mappedfile); + diff = (const unsigned char *)mappedfile - + (const unsigned char *)oldfile; + if (prevtf) + prevtf = (const struct trie_file *) + (((const unsigned char *)prevtf) + diff); + if (tf) + tf = (const struct trie_file *) + (((const unsigned char *)tf) + diff); } /*