From 27aa8cfeef8d6b02ca5926a20624f023af68219d Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Sat, 11 Feb 2023 19:28:12 -0600 Subject: [PATCH] Fixed arguments not setting fully --- include/sorts.h | 2 +- src/sorts.cpp | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/sorts.h b/include/sorts.h index 0120176..d4734f4 100644 --- a/include/sorts.h +++ b/include/sorts.h @@ -17,7 +17,7 @@ private: public: Sorter(); std::vector newWordList; - bool defaultOnly, fileGiven, allLists, sortGiven; + bool defaultFile, defaultOnly, fileGiven, allLists, sortGiven; SortType currentType; std::string GetFilename(void); void SetFilename(std::string newName); diff --git a/src/sorts.cpp b/src/sorts.cpp index 4ee20a9..2086912 100644 --- a/src/sorts.cpp +++ b/src/sorts.cpp @@ -10,7 +10,8 @@ Sorter::Sorter() { lineCount = 0; currentType = INSERTION; - defaultOnly = 0; + defaultFile = 0; + defaultOnly = 1; fileGiven = 0; allLists = 0; sortGiven = 0; @@ -246,27 +247,25 @@ void CheckArguments(int argc, char* arguments[], Sorter* sortObj) tempStr = arguments[i]; if ((tempStr == "-a") || (tempStr == "--all")) { + sortObj->defaultOnly = 0; sortObj->allLists = 1; - return; } if ((tempStr == "-f") || (tempStr == "--filename")) { sortObj->SetFilename(arguments[i + 1]); + sortObj->defaultOnly = 0; sortObj->fileGiven = 1; - return; } if ((tempStr == "-d") || (tempStr == "--default")) { sortObj->SetFilename("test/PERM/perm15K.txt"); - sortObj->defaultOnly = 1; - return; + sortObj->defaultFile = 1; } if ((tempStr == "-s") || (tempStr == "--sort-type")) { sortObj->sortGiven = 1; tempStr = arguments[i + 1]; - std::cout << tempStr << '\n'; if (tempStr == "insertion") sortObj->currentType = INSERTION; if (tempStr == "merge") @@ -277,7 +276,7 @@ void CheckArguments(int argc, char* arguments[], Sorter* sortObj) sortObj->sortGiven = 0; } } - sortObj->SetFilename("test/PERM/perm15K.txt"); - sortObj->defaultOnly = 1; + if (sortObj->defaultOnly) + sortObj->SetFilename("test/PERM/perm15K.txt"); return; }