diff options
author | João Abecasis <joao@abecasis.name> | 2009-10-07 08:04:33 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-10-07 10:44:42 (GMT) |
commit | 95ec7681b70933ce61ef198ed60a375b7393a395 (patch) | |
tree | 2f539c5a0ac0a3ce176e556f3936eb6f7825a7b8 /tools/porting/src | |
parent | d8e68a95c43d0eef4ac0ebc31c7dd0e6c487e3b2 (diff) | |
download | Qt-95ec7681b70933ce61ef198ed60a375b7393a395.zip Qt-95ec7681b70933ce61ef198ed60a375b7393a395.tar.gz Qt-95ec7681b70933ce61ef198ed60a375b7393a395.tar.bz2 |
Check the result of scanf
Fixes a warning with GCC.
Reviewed-by: Markus Goetz
Diffstat (limited to 'tools/porting/src')
-rw-r--r-- | tools/porting/src/filewriter.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tools/porting/src/filewriter.cpp b/tools/porting/src/filewriter.cpp index ee8debb..99bd6e7 100644 --- a/tools/porting/src/filewriter.cpp +++ b/tools/porting/src/filewriter.cpp @@ -44,6 +44,7 @@ #include <QFileInfo> #include <QDir> #include <ctype.h> +#include <errno.h> QT_BEGIN_NAMESPACE @@ -106,11 +107,18 @@ FileWriter::WriteResult FileWriter::writeFile(QString filePath, QByteArray conte char answer = 0; while (answer != 'y' && answer != 'n' && answer != 'a') { #if defined(Q_OS_WIN) && defined(_MSC_VER) && _MSC_VER >= 1400 - scanf_s("%c", &answer); + int result = scanf_s("%c", &answer); #else - scanf("%c", &answer); + int result = scanf("%c", &answer); #endif - answer = tolower(answer); + if (1 == result) + answer = tolower(answer); + else if (EOF == result) { + if (EINTR == errno || EILSEQ == errno) + continue; + + answer = 'n'; + } } if(answer == 'n') |