commit 16f61cdc3d12286ae6a5a95f0e78f1059daccbb4 from: Alexander Arkhipov date: Wed Aug 24 16:39:02 2022 UTC cleanup commit - a7dad3e298db784b5848eeb5d56e4ee96cba9ba0 commit + 16f61cdc3d12286ae6a5a95f0e78f1059daccbb4 blob - 1b564d4809888720bd0184e50e26b6011e208434 blob + bfd563736b80a559ce68a081a491d846871b1f57 --- gpass.c +++ gpass.c @@ -32,8 +32,8 @@ gen(void) { rewind(dictfp); char c; - int left = plen, cur = 1, sought = RANDLINE; - for (;;) { + for (int left = plen, cur = 1, sought = RANDLINE; left; + cur += (c == '\n' || c == EOF)) { c = getc(dictfp); if (cur == sought) { for (; c != '\n' && c != EOF; c = getc(dictfp)) @@ -45,10 +45,8 @@ gen(void) rewind(dictfp); cur = 0; } - } else - break; + } } - cur += (c == '\n' || c == EOF || c == '\0'); } putchar('\n'); }