From 6cdb0d4b950d9a5d65d85729156b4e9a57891fa9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 6 Dec 2016 07:32:19 -0500 Subject: [PATCH] util: Removed confirm --- src/commands/CmdDelete.cpp | 2 +- src/commands/CmdModify.cpp | 2 +- src/commands/CmdPrepend.cpp | 2 +- src/commands/CmdPurge.cpp | 2 +- src/util.cpp | 31 ------------------------------- src/util.h | 1 - 6 files changed, 4 insertions(+), 36 deletions(-) diff --git a/src/commands/CmdDelete.cpp b/src/commands/CmdDelete.cpp index 0bfc1c8ae..d2af38623 100644 --- a/src/commands/CmdDelete.cpp +++ b/src/commands/CmdDelete.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/commands/CmdModify.cpp b/src/commands/CmdModify.cpp index 352939479..e65b200bb 100644 --- a/src/commands/CmdModify.cpp +++ b/src/commands/CmdModify.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include extern Context context; diff --git a/src/commands/CmdPrepend.cpp b/src/commands/CmdPrepend.cpp index 87162c33b..835899da6 100644 --- a/src/commands/CmdPrepend.cpp +++ b/src/commands/CmdPrepend.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/commands/CmdPurge.cpp b/src/commands/CmdPurge.cpp index 146754617..4a38c2b69 100644 --- a/src/commands/CmdPurge.cpp +++ b/src/commands/CmdPurge.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include extern Context context; diff --git a/src/util.cpp b/src/util.cpp index 2ba0ffd27..50fc940cd 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -69,37 +69,6 @@ static void signal_handler (int s) } } -//////////////////////////////////////////////////////////////////////////////// -// Uses std::getline, because std::cin eats leading whitespace, and that means -// that if a newline is entered, std::cin eats it and never returns from the -// "std::cin >> answer;" line, but it does display the newline. This way, with -// std::getline, the newline can be detected, and the prompt re-written. -bool confirm (const std::string& question) -{ - std::vector options {STRING_UTIL_CONFIRM_YES, - STRING_UTIL_CONFIRM_NO}; - std::vector matches; - - signal (SIGINT, signal_handler); - - do - { - std::cout << question - << STRING_UTIL_CONFIRM_YN; - - std::string answer {""}; - std::getline (std::cin, answer); - context.debug ("STDIN '" + answer + '\''); - answer = std::cin.eof () ? STRING_UTIL_CONFIRM_NO : Lexer::lowerCase (Lexer::trim (answer)); - - autoComplete (answer, options, matches, 1); // Hard-coded 1. - } - while (! std::cin.eof () && matches.size () != 1); - - signal (SIGINT, SIG_DFL); - return matches.size () == 1 && matches[0] == STRING_UTIL_CONFIRM_YES ? true : false; -} - //////////////////////////////////////////////////////////////////////////////// // 0 = no // 1 = yes diff --git a/src/util.h b/src/util.h index cc500723c..404c0a1b9 100644 --- a/src/util.h +++ b/src/util.h @@ -40,7 +40,6 @@ #include // util.cpp -bool confirm (const std::string&); int confirm4 (const std::string&); #ifndef HAVE_UUID_UNPARSE_LOWER