diff --git a/src/scrut.c b/src/scrut.c index cb84f33..5e41def 100644 --- a/src/scrut.c +++ b/src/scrut.c @@ -48,8 +48,9 @@ int main(int argc, char *argv[]) { else { sel[p - args] = c; } } - /* straighten out selections */ - for (size_t i = 0, p = sel; i < (sizeof sel) / (sizeof *sel); ++i) { + /* straighten out selections; permute out nulls */ + p = sel; + for (size_t i = 0; i < (sizeof sel) / (sizeof *sel); ++i) { if (sel[i] != '\0') { *p = sel[i]; if (&sel[i] != p++) { sel[i] = '\0'; }