From 5e6b256df5bb9c6aad33c6d0dff47357242648c1 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 26 May 2008 13:34:33 -0400 Subject: [PATCH] - Changes to enable a clean build under Fedora 8. --- src/Config.cpp | 4 ++-- src/Date.cpp | 5 +++-- src/T.cpp | 28 ++++++++++++++-------------- src/Table.cpp | 31 ++++++++++++++++--------------- src/parse.cpp | 18 +++++++++--------- src/task.cpp | 2 +- src/text.cpp | 6 +++--- 7 files changed, 48 insertions(+), 46 deletions(-) diff --git a/src/Config.cpp b/src/Config.cpp index d2a84e3a0..227acd749 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -35,7 +35,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 +44,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"); diff --git a/src/Date.cpp b/src/Date.cpp index 3a2cbbc0e..0a8feee34 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -5,6 +5,7 @@ //////////////////////////////////////////////////////////////////////////////// #include #include +#include #include "task.h" #include "Date.h" @@ -36,8 +37,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) { diff --git a/src/T.cpp b/src/T.cpp index 4b62ec12d..2e4a3bf2c 100644 --- a/src/T.cpp +++ b/src/T.cpp @@ -115,7 +115,7 @@ void T::addTag (const std::string& tag) //////////////////////////////////////////////////////////////////////////////// void T::addTags (const std::vector & tags) { - for (unsigned int i = 0; i < tags.size (); ++i) + for (size_t i = 0; i < tags.size (); ++i) { if (tags[i].find (' ') != std::string::npos) throw std::string ("T::addTags - tags may not contain spaces"); @@ -137,7 +137,7 @@ void T::addTags (const std::vector & tags) void T::removeTag (const std::string& tag) { std::vector copy; - for (unsigned int i = 0; i < mTags.size (); ++i) + for (size_t i = 0; i < mTags.size (); ++i) if (mTags[i] != tag) copy.push_back (mTags[i]); @@ -242,7 +242,7 @@ const std::string T::compose () const else if (mStatus == deleted) line += "X ["; // Tags - for (unsigned int i = 0; i < mTags.size (); ++i) + for (size_t i = 0; i < mTags.size (); ++i) { line += (i > 0 ? " " : ""); line += mTags[i]; @@ -297,7 +297,7 @@ const std::string T::composeCSV () // Tags line += "'"; - for (unsigned int i = 0; i < mTags.size (); ++i) + for (size_t i = 0; i < mTags.size (); ++i) { line += (i > 0 ? " " : ""); line += mTags[i]; @@ -364,13 +364,13 @@ void T::parse (const std::string& line) if (line[0] == 'X') setStatus (deleted); - unsigned int openTagBracket = line.find ("["); - unsigned int closeTagBracket = line.find ("]", openTagBracket); + size_t openTagBracket = line.find ("["); + size_t closeTagBracket = line.find ("]", openTagBracket); if (openTagBracket != std::string::npos && closeTagBracket != std::string::npos) { - unsigned int openAttrBracket = line.find ("[", closeTagBracket); - unsigned int closeAttrBracket = line.find ("]", openAttrBracket); + size_t openAttrBracket = line.find ("[", closeTagBracket); + size_t closeAttrBracket = line.find ("]", openAttrBracket); if (openAttrBracket != std::string::npos && closeAttrBracket != std::string::npos) { @@ -383,7 +383,7 @@ void T::parse (const std::string& line) openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1); std::vector pairs; split (pairs, attributes, ' '); - for (unsigned int i = 0; i < pairs.size (); ++i) + for (size_t i = 0; i < pairs.size (); ++i) { std::vector pair; split (pair, pairs[i], ':'); @@ -415,13 +415,13 @@ void T::parse (const std::string& line) : line[37] == 'X' ? deleted : pending; - unsigned int openTagBracket = line.find ("["); - unsigned int closeTagBracket = line.find ("]", openTagBracket); + size_t openTagBracket = line.find ("["); + size_t closeTagBracket = line.find ("]", openTagBracket); if (openTagBracket != std::string::npos && closeTagBracket != std::string::npos) { - unsigned int openAttrBracket = line.find ("[", closeTagBracket); - unsigned int closeAttrBracket = line.find ("]", openAttrBracket); + size_t openAttrBracket = line.find ("[", closeTagBracket); + size_t closeAttrBracket = line.find ("]", openAttrBracket); if (openAttrBracket != std::string::npos && closeAttrBracket != std::string::npos) { @@ -434,7 +434,7 @@ void T::parse (const std::string& line) openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1); std::vector pairs; split (pairs, attributes, ' '); - for (unsigned int i = 0; i < pairs.size (); ++i) + for (size_t i = 0; i < pairs.size (); ++i) { std::vector pair; split (pair, pairs[i], ':'); diff --git a/src/Table.cpp b/src/Table.cpp index f20916bd8..267139a1d 100644 --- a/src/Table.cpp +++ b/src/Table.cpp @@ -22,6 +22,7 @@ // //////////////////////////////////////////////////////////////////////////////// #include +#include #include #include #include @@ -415,7 +416,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 +441,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 +463,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 +594,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 +615,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 +671,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 +715,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 +758,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 +856,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 +885,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 +908,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 +929,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..13f0232cd 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -136,7 +136,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 +165,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 +236,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 +275,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 +318,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/task.cpp b/src/task.cpp index 10aa198d4..22cd69b18 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -2458,7 +2458,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/text.cpp b/src/text.cpp index b169d94d2..44155c684 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -76,8 +76,8 @@ void extractParagraphs (const std::string& input, std::vector& outp std::string copy = input; while (1) { - unsigned int so = copy.find ("

"); - unsigned int eo = copy.find ("

"); + size_t so = copy.find ("

"); + size_t eo = copy.find ("

"); if (so == std::string::npos && eo == std::string::npos) break; @@ -126,7 +126,7 @@ void unquoteText (std::string& text) //////////////////////////////////////////////////////////////////////////////// void extractLine (std::string& text, std::string& line, int length) { - unsigned int eol = text.find ("\n"); + size_t eol = text.find ("\n"); // Special case: found \n in first length characters. if (eol != std::string::npos && eol < (unsigned) length)