From 88a993a63af0930c8b0c39ce4ad6ce6ce2c35f00 Mon Sep 17 00:00:00 2001 From: kroimon Date: Fri, 10 Oct 2008 15:45:20 +0000 Subject: [PATCH] Add recognition for 'y' and 'n' to CUtils::GetBoolInput. Only 'yes'/'no' was possible before. This commit also fixes a possible stack overflow because of recursion. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1244 726aef4b-f618-498e-8847-2d620e286838 --- Utils.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Utils.cpp b/Utils.cpp index b9d44562..3298ded8 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -258,15 +258,15 @@ bool CUtils::GetBoolInput(const CString& sPrompt, bool *pbDefault) { sDefault = (*pbDefault) ? "yes" : "no"; } - GetInput(sPrompt, sRet, sDefault, "yes/no"); + while (true) { + GetInput(sPrompt, sRet, sDefault, "yes/no"); - if (sRet.Equals("yes")) { - return true; - } else if (sRet.Equals("no")) { - return false; + if (sRet.Equals("y") || sRet.Equals("yes")) { + return true; + } else if (sRet.Equals("n") || sRet.Equals("no")) { + return false; + } } - - return GetBoolInput(sPrompt, pbDefault); } bool CUtils::GetNumInput(const CString& sPrompt, unsigned int& uRet, unsigned int uMin, unsigned int uMax, unsigned int uDefault) {