Skip to content

Commit

Permalink
cleanup tty output checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancdotorg committed Nov 2, 2015
1 parent 169691f commit bf39c9a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions brainflayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ int main(int argc, char **argv) {
uint64_t ilines_last, ilines_curr, ilines_delta;
uint64_t olines;

int skipping = 0;
int skipping = 0, tty = 0;

char *line = NULL;
size_t line_sz = 0;
Expand Down Expand Up @@ -474,6 +474,8 @@ int main(int argc, char **argv) {
/* line buffer stderr */
setvbuf(stderr, NULL, _IOLBF, 0);

if (vopt && ofile == stdout && isatty(fileno(stdout))) { tty = 1; }

brainflayer_init_globals();

if (secp256k1_ec_pubkey_precomp_table(wopt, mopt) != 0) {
Expand Down Expand Up @@ -502,14 +504,14 @@ int main(int argc, char **argv) {
if (bloom) {
if (bloom_chk_hash160(bloom, hash160_uncmp.ul)) {
if (!fopt || hsearchf(ffile, &hash160_uncmp)) {
if (vopt && ofile == stdout && isatty(fileno(stdout))) fprintf(ofile, "\033[0K");
if (tty) { fprintf(ofile, "\033[0K"); }
fprintresult(ofile, &hash160_uncmp, 'u', topt, line);
++olines;
}
}
if (bloom_chk_hash160(bloom, hash160_compr.ul)) {
if (!fopt || hsearchf(ffile, &hash160_compr)) {
if (vopt && ofile == stdout && isatty(fileno(stdout))) fprintf(ofile, "\033[0K");
if (tty) { fprintf(ofile, "\033[0K"); }
fprintresult(ofile, &hash160_compr, 'c', topt, line);
++olines;
}
Expand Down

0 comments on commit bf39c9a

Please sign in to comment.