diff options
Diffstat (limited to '3rdparty/lzma/CPP/7zip/UI/Console/UserInputUtils.cpp')
-rw-r--r-- | 3rdparty/lzma/CPP/7zip/UI/Console/UserInputUtils.cpp | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/3rdparty/lzma/CPP/7zip/UI/Console/UserInputUtils.cpp b/3rdparty/lzma/CPP/7zip/UI/Console/UserInputUtils.cpp index 754680090bc..c7f830ff999 100644 --- a/3rdparty/lzma/CPP/7zip/UI/Console/UserInputUtils.cpp +++ b/3rdparty/lzma/CPP/7zip/UI/Console/UserInputUtils.cpp @@ -2,19 +2,19 @@ #include "StdAfx.h" -#include "Common/StdInStream.h" -#include "Common/StringConvert.h" +#include "../../../Common/StdInStream.h" +#include "../../../Common/StringConvert.h" #include "UserInputUtils.h" -static const char kYes = 'Y'; -static const char kNo = 'N'; -static const char kYesAll = 'A'; -static const char kNoAll = 'S'; -static const char kAutoRenameAll = 'U'; -static const char kQuit = 'Q'; +static const char kYes = 'y'; +static const char kNo = 'n'; +static const char kYesAll = 'a'; +static const char kNoAll = 's'; +static const char kAutoRenameAll = 'u'; +static const char kQuit = 'q'; -static const char *kFirstQuestionMessage = "?\n"; +static const char *kFirstQuestionMessage = "? "; static const char *kHelpQuestionMessage = "(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? "; @@ -22,33 +22,26 @@ static const char *kHelpQuestionMessage = NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream) { - (*outStream) << kFirstQuestionMessage; + if (outStream) + *outStream << kFirstQuestionMessage; for (;;) { - (*outStream) << kHelpQuestionMessage; - outStream->Flush(); + if (outStream) + { + *outStream << kHelpQuestionMessage; + outStream->Flush(); + } AString scannedString = g_StdIn.ScanStringUntilNewLine(); scannedString.Trim(); if (!scannedString.IsEmpty()) - switch( - ::MyCharUpper( - #ifdef UNDER_CE - (wchar_t) - #endif - scannedString[0])) + switch (::MyCharLower_Ascii(scannedString[0])) { - case kYes: - return NUserAnswerMode::kYes; - case kNo: - return NUserAnswerMode::kNo; - case kYesAll: - return NUserAnswerMode::kYesAll; - case kNoAll: - return NUserAnswerMode::kNoAll; - case kAutoRenameAll: - return NUserAnswerMode::kAutoRenameAll; - case kQuit: - return NUserAnswerMode::kQuit; + case kYes: return NUserAnswerMode::kYes; + case kNo: return NUserAnswerMode::kNo; + case kYesAll: return NUserAnswerMode::kYesAll; + case kNoAll: return NUserAnswerMode::kNoAll; + case kAutoRenameAll: return NUserAnswerMode::kAutoRenameAll; + case kQuit: return NUserAnswerMode::kQuit; } } } @@ -61,14 +54,18 @@ NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream) UString GetPassword(CStdOutStream *outStream) { - (*outStream) << "\nEnter password" + if (outStream) + { + *outStream << "\nEnter password" #ifdef MY_DISABLE_ECHO " (will not be echoed)" #endif ":"; - outStream->Flush(); + outStream->Flush(); + } #ifdef MY_DISABLE_ECHO + HANDLE console = GetStdHandle(STD_INPUT_HANDLE); bool wasChanged = false; DWORD mode = 0; @@ -78,10 +75,16 @@ UString GetPassword(CStdOutStream *outStream) UString res = g_StdIn.ScanUStringUntilNewLine(); if (wasChanged) SetConsoleMode(console, mode); - (*outStream) << "\n"; - outStream->Flush(); + if (outStream) + { + *outStream << endl; + outStream->Flush(); + } return res; + #else + return g_StdIn.ScanUStringUntilNewLine(); + #endif } |