From: Yann Collet Date: Tue, 29 Dec 2015 10:57:15 +0000 (+0100) Subject: fix confirmation prompt X-Git-Tag: v0.4.6~2^2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1450f721d4524568dd39cab6f67620fbf724749;p=thirdparty%2Fzstd.git fix confirmation prompt --- diff --git a/programs/fileio.c b/programs/fileio.c index 3867301a9..0d49af2b9 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -225,7 +225,6 @@ static int FIO_getFiles(FILE** fileOutPtr, FILE** fileInPtr, if (*fileOutPtr != 0) { /* prompt for overwrite authorization */ - int ch = 'N'; fclose(*fileOutPtr); DISPLAY("Warning : %s already exists \n", dstFileName); if ((g_displayLevel <= 1) || (*fileInPtr == stdin)) @@ -235,11 +234,14 @@ static int FIO_getFiles(FILE** fileOutPtr, FILE** fileInPtr, return 1; } DISPLAY("Overwrite ? (y/N) : "); - while((ch = getchar()) != '\n' && ch != EOF); /* flush integrated */ - if ((ch!='Y') && (ch!='y')) { - DISPLAY("No. Operation aborted : %s already exists \n", dstFileName); - return 1; + int ch = getchar(); + if ((ch!='Y') && (ch!='y')) + { + DISPLAY("No. Operation aborted : %s already exists \n", dstFileName); + return 1; + } + while ((ch!=EOF) && (ch!='\n')) ch = getchar(); /* flush rest of input line */ } } }