From 5f0916e82693f7a0132365cdadbcf62e90cb71ed Mon Sep 17 00:00:00 2001 From: Cameron Santos Date: Wed, 24 Sep 2025 11:49:12 -0700 Subject: [PATCH] fix: terminate immediately on 'nothing' (Fixes ChicoState/autovalidate#1) --- main.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index d9884f9..5611ef9 100644 --- a/main.cpp +++ b/main.cpp @@ -18,19 +18,22 @@ int main(){ int pick; srand(time(0)); - pick = rand() % VALIDATION.size(); + cout << "What are you listening to?\n"; - getline(cin,input); - transform(input.begin(), input.end(), input.begin(), [](unsigned char c){ return std::tolower(c); }); + if (!getline(cin, input)) return 0; + + if (input == "nothing") return 0; + + pick = rand() % VALIDATION.size(); cout << VALIDATION[pick] << "! Let's listen to more\n"; - do{ + while (true) { cout << "What's next?\n"; - getline(cin,input); - transform(input.begin(), input.end(), input.begin(), [](unsigned char c){ return std::tolower(c); }); + if (!getline(cin, input)) break; + if (input == "nothing") break; pick = rand() % VALIDATION.size(); cout << VALIDATION[pick] << "!\n"; - }while( input != "nothing" ); + } return 0; -} \ No newline at end of file +}