From cb4f86e9f1bc9f15f9755aea0fb97fcc565d599e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 26 May 2008 20:58:41 -0400 Subject: [PATCH] - Changes necessary for a clean build on Fedora9. --- src/Config.cpp | 11 ++++++----- src/Date.cpp | 12 +++++++----- src/TDB.cpp | 1 + src/Table.cpp | 32 +++++++++++++++++--------------- src/parse.cpp | 27 ++++++++++++++------------- src/rules.cpp | 1 + src/task.cpp | 5 +++-- src/util.cpp | 1 + 8 files changed, 50 insertions(+), 40 deletions(-) diff --git a/src/Config.cpp b/src/Config.cpp index d2a84e3a0..8f87ee75c 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "task.h" #include "Config.h" @@ -35,7 +36,7 @@ bool Config::load (const std::string& file) while (getline (in, line)) { // Remove comments. - unsigned int pound = line.find ("#"); + size_type pound = line.find ("#"); if (pound != std::string::npos) line = line.substr (0, pound); @@ -44,7 +45,7 @@ bool Config::load (const std::string& file) // Skip empty lines. if (line.length () > 0) { - unsigned int equal = line.find ("="); + size_type equal = line.find ("="); if (equal != std::string::npos) { std::string key = trim (line.substr (0, equal), " \t"); @@ -96,12 +97,12 @@ void Config::createDefault (const std::string& file) fprintf (out, "curses=on\n"); fprintf (out, "color=on\n"); - fprintf (out, "color.overdue=red\n"); - fprintf (out, "#color.due=on yellow\n"); + fprintf (out, "color.overdue=bold_red\n"); + fprintf (out, "#color.due=on_bright_yellow\n"); fprintf (out, "#color.pri.H=on_red\n"); fprintf (out, "#color.pri.M=on_yellow\n"); fprintf (out, "#color.pri.L=on_green\n"); - fprintf (out, "color.active=cyan\n"); + fprintf (out, "color.active=bold_cyan\n"); fprintf (out, "color.tagged=yellow\n"); fclose (out); diff --git a/src/Date.cpp b/src/Date.cpp index 3a2cbbc0e..0e12c96cd 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -5,6 +5,8 @@ //////////////////////////////////////////////////////////////////////////////// #include #include +#include +#include #include "task.h" #include "Date.h" @@ -36,8 +38,8 @@ Date::Date (const int m, const int d, const int y) //////////////////////////////////////////////////////////////////////////////// Date::Date (const std::string& mdy) { - unsigned int firstSlash = mdy.find ("/"); - unsigned int secondSlash = mdy.find ("/", firstSlash + 1); + size_t firstSlash = mdy.find ("/"); + size_t secondSlash = mdy.find ("/", firstSlash + 1); if (firstSlash != std::string::npos && secondSlash != std::string::npos) { @@ -155,7 +157,7 @@ int Date::daysInMonth (int month, int year) //////////////////////////////////////////////////////////////////////////////// std::string Date::monthName (int month) { - static char* months[12] = + static const char* months[12] = { "January", "February", @@ -179,7 +181,7 @@ std::string Date::monthName (int month) //////////////////////////////////////////////////////////////////////////////// void Date::dayName (int dow, std::string& name) { - static char* days[7] = + static const char* days[7] = { "Sunday", "Monday", @@ -196,7 +198,7 @@ void Date::dayName (int dow, std::string& name) //////////////////////////////////////////////////////////////////////////////// std::string Date::dayName (int dow) { - static char* days[7] = + static const char* days[7] = { "Sunday", "Monday", diff --git a/src/TDB.cpp b/src/TDB.cpp index 071b4f101..b2efec264 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "task.h" #include "TDB.h" diff --git a/src/Table.cpp b/src/Table.cpp index f20916bd8..703e3bd8a 100644 --- a/src/Table.cpp +++ b/src/Table.cpp @@ -22,6 +22,8 @@ // //////////////////////////////////////////////////////////////////////////////// #include +#include +#include #include #include #include @@ -415,7 +417,7 @@ void Table::calculateColumnWidths () std::vector ideal = mMaxDataWidth; int width = 0; int countFlexible = 0; - for (unsigned int c = 0; c < mColumns.size (); ++c) + for (size_t c = 0; c < mColumns.size (); ++c) { if (mSpecifiedWidth[c] == flexible) ++countFlexible; @@ -440,7 +442,7 @@ void Table::calculateColumnWidths () { ideal = mMaxDataWidth; width = 0; - for (unsigned int c = 0; c < mColumns.size (); ++c) + for (size_t c = 0; c < mColumns.size (); ++c) { if (mSpecifiedWidth[c] > 0) ideal[c] = mSpecifiedWidth[c]; @@ -462,7 +464,7 @@ void Table::calculateColumnWidths () int remainder = available % countFlexible; int lastFlexible = mColumns.size () - 1; - for (unsigned int c = 0; c < mColumns.size (); ++c) + for (size_t c = 0; c < mColumns.size (); ++c) { if (mSpecifiedWidth[c] == flexible) { @@ -593,7 +595,7 @@ void Table::formatCell ( std::string postJust; std::vector chunks; wrapText (chunks, data, width); - for (unsigned int chunk = 0; chunk < chunks.size (); ++chunk) + for (size_t chunk = 0; chunk < chunks.size (); ++chunk) { // Place the data within the available space - justify. int gap = width - chunks[chunk].length (); @@ -614,7 +616,7 @@ void Table::formatCell ( for (int i = 0; i < gap / 2; ++i) preJust += " "; - for (unsigned int i = 0; i < gap - preJust.length (); ++i) + for (size_t i = 0; i < gap - preJust.length (); ++i) postJust += " "; } @@ -670,7 +672,7 @@ const std::string Table::formatCell ( for (int i = 0; i < gap / 2; ++i) preJust += " "; - for (unsigned int i = 0; i < gap - preJust.length (); ++i) + for (size_t i = 0; i < gap - preJust.length (); ++i) postJust += " "; } @@ -714,7 +716,7 @@ void Table::optimize (std::string& output) */ // \s\n -> \n - unsigned int i = 0; + size_t i = 0; while ((i = output.find (" \n")) != std::string::npos) { output = output.substr (0, i) + @@ -757,7 +759,7 @@ void Table::sort (std::vector & order) while (r + gap < (int) order.size ()) { bool keepScanning = true; - for (unsigned int c = 0; keepScanning && c < mSortColumns.size (); ++c) + for (size_t c = 0; keepScanning && c < mSortColumns.size (); ++c) { keepScanning = false; @@ -855,8 +857,8 @@ void Table::sort (std::vector & order) //////////////////////////////////////////////////////////////////////////////// void Table::clean (std::string& value) { - unsigned int start = 0; - unsigned int pos; + size_t start = 0; + size_t pos; while ((pos = value.find ('\t', start)) != std::string::npos) { value.replace (pos, 1, " "); @@ -884,7 +886,7 @@ const std::string Table::render () // Print column headers in column order. std::string output; - for (unsigned int col = 0; col < mColumns.size (); ++col) + for (size_t col = 0; col < mColumns.size (); ++col) output += formatHeader ( col, mCalculatedWidth[col], @@ -907,8 +909,8 @@ const std::string Table::render () std::vector > columns; std::vector blanks; - unsigned int maxHeight = 0; - for (unsigned int col = 0; col < mColumns.size (); ++col) + size_t maxHeight = 0; + for (size_t col = 0; col < mColumns.size (); ++col) { std::vector lines; std::string blank; @@ -928,9 +930,9 @@ const std::string Table::render () if (maxHeight) { - for (unsigned int lines = 0; lines < maxHeight; ++lines) + for (size_t lines = 0; lines < maxHeight; ++lines) { - for (unsigned int col = 0; col < mColumns.size (); ++col) + for (size_t col = 0; col < mColumns.size (); ++col) if (lines < columns[col].size ()) output += columns[col][lines]; else diff --git a/src/parse.cpp b/src/parse.cpp index 4e200bd9c..ca239f514 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -4,6 +4,7 @@ // //////////////////////////////////////////////////////////////////////////////// #include +#include #include #include #include @@ -13,7 +14,7 @@ #include "T.h" //////////////////////////////////////////////////////////////////////////////// -static char* colors[] = +static const char* colors[] = { "bold", "underline", @@ -75,7 +76,7 @@ static char* colors[] = "", }; -static char* attributes[] = +static const char* attributes[] = { "project", "priority", @@ -88,7 +89,7 @@ static char* attributes[] = "", }; -static char* commands[] = +static const char* commands[] = { "active", "add", @@ -115,7 +116,7 @@ static char* commands[] = "", }; -void guess (const std::string& type, char** list, std::string& candidate) +void guess (const std::string& type, const char** list, std::string& candidate) { std::vector options; for (int i = 0; list[i][0]; ++i) @@ -136,7 +137,7 @@ void guess (const std::string& type, char** list, std::string& candidate) error += " '"; error += candidate; error += "' - could be either of "; - for (unsigned int i = 0; i < matches.size (); ++i) + for (size_t i = 0; i < matches.size (); ++i) { if (i) error += ", "; @@ -165,8 +166,8 @@ static bool isCommand (const std::string& candidate) //////////////////////////////////////////////////////////////////////////////// bool validDate (std::string& date) { - unsigned int firstSlash = date.find ("/"); - unsigned int secondSlash = date.find ("/", firstSlash + 1); + size_t firstSlash = date.find ("/"); + size_t secondSlash = date.find ("/", firstSlash + 1); if (firstSlash != std::string::npos && secondSlash != std::string::npos) { @@ -236,7 +237,7 @@ static bool validAttribute (std::string& name, std::string& value) //////////////////////////////////////////////////////////////////////////////// static bool validId (const std::string& input) { - for (unsigned int i = 0; i < input.length (); ++i) + for (size_t i = 0; i < input.length (); ++i) if (!::isdigit (input[i])) return false; @@ -275,13 +276,13 @@ static bool validSubstitution ( std::string& from, std::string& to) { - unsigned int first = input.find ('/'); + size_t first = input.find ('/'); if (first != std::string::npos) { - unsigned int second = input.find ('/', first + 1); + size_t second = input.find ('/', first + 1); if (second != std::string::npos) { - unsigned int third = input.find ('/', second + 1); + size_t third = input.find ('/', second + 1); if (third != std::string::npos) { if (first == 0 && @@ -318,10 +319,10 @@ void parse ( command = ""; std::string descCandidate = ""; - for (unsigned int i = 0; i < args.size (); ++i) + for (size_t i = 0; i < args.size (); ++i) { std::string arg (args[i]); - unsigned int colon; // Pointer to colon in argument. + size_t colon; // Pointer to colon in argument. std::string from; std::string to; diff --git a/src/rules.cpp b/src/rules.cpp index bd14f7fbd..b297acb93 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -4,6 +4,7 @@ // //////////////////////////////////////////////////////////////////////////////// #include +#include #include "Config.h" #include "Table.h" #include "Date.h" diff --git a/src/task.cpp b/src/task.cpp index 10aa198d4..12bdf31dd 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -1694,7 +1695,7 @@ void handleReportHistory (const TDB& tdb, T& task, Config& conf) table.setColumnJustification (4, Table::right); table.setColumnJustification (5, Table::right); - char *months[] = + const char *months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", @@ -2458,7 +2459,7 @@ void handleModify (const TDB& tdb, T& task, Config& conf) if (from != "") { std::string description = original.getDescription (); - unsigned int pattern = description.find (from); + size_t pattern = description.find (from); if (pattern != std::string::npos) { description = description.substr (0, pattern) + diff --git a/src/util.cpp b/src/util.cpp index ff2a4686d..0d5271ba3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "Table.h" #include "task.h" #include "../auto.h"