From 78ec411067277ccad8e8a2f67f841ca067770ad0 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 16 Jun 2009 13:32:11 -0400 Subject: [PATCH] Enhancements - Added text.cpp/ucFirst function to capitalize words, so that "pending" can now appear as "Pending" on the info report. This helps task pass many more test cases. --- src/report.cpp | 2 +- src/text.cpp | 11 +++++++++++ src/text.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/report.cpp b/src/report.cpp index 3fe7e8a28..6f0e560de 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -309,7 +309,7 @@ std::string handleInfo () table.addCell (row, 0, "ID"); table.addCell (row, 1, task->id); - std::string status = Task::statusToText (task->getStatus ()); + std::string status = ucFirst (Task::statusToText (task->getStatus ())); if (task->has ("parent")) status += " (Recurring)"; diff --git a/src/text.cpp b/src/text.cpp index e99361693..0e511b551 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -296,6 +296,17 @@ std::string upperCase (const std::string& input) return output; } +//////////////////////////////////////////////////////////////////////////////// +std::string ucFirst (const std::string& input) +{ + std::string output = input; + + if (output.length () > 0) + output[0] = ::toupper (output[0]); + + return output; +} + //////////////////////////////////////////////////////////////////////////////// const char* optionalBlankLine () { diff --git a/src/text.h b/src/text.h index 9ffe9c4b2..95eb718a7 100644 --- a/src/text.h +++ b/src/text.h @@ -44,6 +44,7 @@ void join (std::string&, const std::string&, const std::vector&); std::string commify (const std::string&); std::string lowerCase (const std::string&); std::string upperCase (const std::string&); +std::string ucFirst (const std::string&); const char* optionalBlankLine (); void guess (const std::string&, std::vector&, std::string&); bool digitsOnly (const std::string&);