- Changes to enable a clean build under Fedora 8.

This commit is contained in:
Paul Beckingham 2008-05-26 13:34:33 -04:00
parent e392b8a95e
commit 5e6b256df5
7 changed files with 48 additions and 46 deletions

View file

@ -35,7 +35,7 @@ bool Config::load (const std::string& file)
while (getline (in, line)) while (getline (in, line))
{ {
// Remove comments. // Remove comments.
unsigned int pound = line.find ("#"); size_type pound = line.find ("#");
if (pound != std::string::npos) if (pound != std::string::npos)
line = line.substr (0, pound); line = line.substr (0, pound);
@ -44,7 +44,7 @@ bool Config::load (const std::string& file)
// Skip empty lines. // Skip empty lines.
if (line.length () > 0) if (line.length () > 0)
{ {
unsigned int equal = line.find ("="); size_type equal = line.find ("=");
if (equal != std::string::npos) if (equal != std::string::npos)
{ {
std::string key = trim (line.substr (0, equal), " \t"); std::string key = trim (line.substr (0, equal), " \t");

View file

@ -5,6 +5,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <iostream> #include <iostream>
#include <time.h> #include <time.h>
#include <assert.h>
#include "task.h" #include "task.h"
#include "Date.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) Date::Date (const std::string& mdy)
{ {
unsigned int firstSlash = mdy.find ("/"); size_t firstSlash = mdy.find ("/");
unsigned int secondSlash = mdy.find ("/", firstSlash + 1); size_t secondSlash = mdy.find ("/", firstSlash + 1);
if (firstSlash != std::string::npos && if (firstSlash != std::string::npos &&
secondSlash != std::string::npos) secondSlash != std::string::npos)
{ {

View file

@ -115,7 +115,7 @@ void T::addTag (const std::string& tag)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::addTags (const std::vector <std::string>& tags) void T::addTags (const std::vector <std::string>& 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) if (tags[i].find (' ') != std::string::npos)
throw std::string ("T::addTags - tags may not contain spaces"); throw std::string ("T::addTags - tags may not contain spaces");
@ -137,7 +137,7 @@ void T::addTags (const std::vector <std::string>& tags)
void T::removeTag (const std::string& tag) void T::removeTag (const std::string& tag)
{ {
std::vector <std::string> copy; std::vector <std::string> copy;
for (unsigned int i = 0; i < mTags.size (); ++i) for (size_t i = 0; i < mTags.size (); ++i)
if (mTags[i] != tag) if (mTags[i] != tag)
copy.push_back (mTags[i]); copy.push_back (mTags[i]);
@ -242,7 +242,7 @@ const std::string T::compose () const
else if (mStatus == deleted) line += "X ["; else if (mStatus == deleted) line += "X [";
// Tags // Tags
for (unsigned int i = 0; i < mTags.size (); ++i) for (size_t i = 0; i < mTags.size (); ++i)
{ {
line += (i > 0 ? " " : ""); line += (i > 0 ? " " : "");
line += mTags[i]; line += mTags[i];
@ -297,7 +297,7 @@ const std::string T::composeCSV ()
// Tags // Tags
line += "'"; line += "'";
for (unsigned int i = 0; i < mTags.size (); ++i) for (size_t i = 0; i < mTags.size (); ++i)
{ {
line += (i > 0 ? " " : ""); line += (i > 0 ? " " : "");
line += mTags[i]; line += mTags[i];
@ -364,13 +364,13 @@ void T::parse (const std::string& line)
if (line[0] == 'X') if (line[0] == 'X')
setStatus (deleted); setStatus (deleted);
unsigned int openTagBracket = line.find ("["); size_t openTagBracket = line.find ("[");
unsigned int closeTagBracket = line.find ("]", openTagBracket); size_t closeTagBracket = line.find ("]", openTagBracket);
if (openTagBracket != std::string::npos && if (openTagBracket != std::string::npos &&
closeTagBracket != std::string::npos) closeTagBracket != std::string::npos)
{ {
unsigned int openAttrBracket = line.find ("[", closeTagBracket); size_t openAttrBracket = line.find ("[", closeTagBracket);
unsigned int closeAttrBracket = line.find ("]", openAttrBracket); size_t closeAttrBracket = line.find ("]", openAttrBracket);
if (openAttrBracket != std::string::npos && if (openAttrBracket != std::string::npos &&
closeAttrBracket != std::string::npos) closeAttrBracket != std::string::npos)
{ {
@ -383,7 +383,7 @@ void T::parse (const std::string& line)
openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1); openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1);
std::vector <std::string> pairs; std::vector <std::string> pairs;
split (pairs, attributes, ' '); split (pairs, attributes, ' ');
for (unsigned int i = 0; i < pairs.size (); ++i) for (size_t i = 0; i < pairs.size (); ++i)
{ {
std::vector <std::string> pair; std::vector <std::string> pair;
split (pair, pairs[i], ':'); split (pair, pairs[i], ':');
@ -415,13 +415,13 @@ void T::parse (const std::string& line)
: line[37] == 'X' ? deleted : line[37] == 'X' ? deleted
: pending; : pending;
unsigned int openTagBracket = line.find ("["); size_t openTagBracket = line.find ("[");
unsigned int closeTagBracket = line.find ("]", openTagBracket); size_t closeTagBracket = line.find ("]", openTagBracket);
if (openTagBracket != std::string::npos && if (openTagBracket != std::string::npos &&
closeTagBracket != std::string::npos) closeTagBracket != std::string::npos)
{ {
unsigned int openAttrBracket = line.find ("[", closeTagBracket); size_t openAttrBracket = line.find ("[", closeTagBracket);
unsigned int closeAttrBracket = line.find ("]", openAttrBracket); size_t closeAttrBracket = line.find ("]", openAttrBracket);
if (openAttrBracket != std::string::npos && if (openAttrBracket != std::string::npos &&
closeAttrBracket != std::string::npos) closeAttrBracket != std::string::npos)
{ {
@ -434,7 +434,7 @@ void T::parse (const std::string& line)
openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1); openAttrBracket + 1, closeAttrBracket - openAttrBracket - 1);
std::vector <std::string> pairs; std::vector <std::string> pairs;
split (pairs, attributes, ' '); split (pairs, attributes, ' ');
for (unsigned int i = 0; i < pairs.size (); ++i) for (size_t i = 0; i < pairs.size (); ++i)
{ {
std::vector <std::string> pair; std::vector <std::string> pair;
split (pair, pairs[i], ':'); split (pair, pairs[i], ':');

View file

@ -22,6 +22,7 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <iostream> #include <iostream>
#include <assert.h>
#include <Table.h> #include <Table.h>
#include <Date.h> #include <Date.h>
#include <task.h> #include <task.h>
@ -415,7 +416,7 @@ void Table::calculateColumnWidths ()
std::vector <int> ideal = mMaxDataWidth; std::vector <int> ideal = mMaxDataWidth;
int width = 0; int width = 0;
int countFlexible = 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) if (mSpecifiedWidth[c] == flexible)
++countFlexible; ++countFlexible;
@ -440,7 +441,7 @@ void Table::calculateColumnWidths ()
{ {
ideal = mMaxDataWidth; ideal = mMaxDataWidth;
width = 0; width = 0;
for (unsigned int c = 0; c < mColumns.size (); ++c) for (size_t c = 0; c < mColumns.size (); ++c)
{ {
if (mSpecifiedWidth[c] > 0) if (mSpecifiedWidth[c] > 0)
ideal[c] = mSpecifiedWidth[c]; ideal[c] = mSpecifiedWidth[c];
@ -462,7 +463,7 @@ void Table::calculateColumnWidths ()
int remainder = available % countFlexible; int remainder = available % countFlexible;
int lastFlexible = mColumns.size () - 1; 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) if (mSpecifiedWidth[c] == flexible)
{ {
@ -593,7 +594,7 @@ void Table::formatCell (
std::string postJust; std::string postJust;
std::vector <std::string> chunks; std::vector <std::string> chunks;
wrapText (chunks, data, width); 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. // Place the data within the available space - justify.
int gap = width - chunks[chunk].length (); int gap = width - chunks[chunk].length ();
@ -614,7 +615,7 @@ void Table::formatCell (
for (int i = 0; i < gap / 2; ++i) for (int i = 0; i < gap / 2; ++i)
preJust += " "; preJust += " ";
for (unsigned int i = 0; i < gap - preJust.length (); ++i) for (size_t i = 0; i < gap - preJust.length (); ++i)
postJust += " "; postJust += " ";
} }
@ -670,7 +671,7 @@ const std::string Table::formatCell (
for (int i = 0; i < gap / 2; ++i) for (int i = 0; i < gap / 2; ++i)
preJust += " "; preJust += " ";
for (unsigned int i = 0; i < gap - preJust.length (); ++i) for (size_t i = 0; i < gap - preJust.length (); ++i)
postJust += " "; postJust += " ";
} }
@ -714,7 +715,7 @@ void Table::optimize (std::string& output)
*/ */
// \s\n -> \n // \s\n -> \n
unsigned int i = 0; size_t i = 0;
while ((i = output.find (" \n")) != std::string::npos) while ((i = output.find (" \n")) != std::string::npos)
{ {
output = output.substr (0, i) + output = output.substr (0, i) +
@ -757,7 +758,7 @@ void Table::sort (std::vector <int>& order)
while (r + gap < (int) order.size ()) while (r + gap < (int) order.size ())
{ {
bool keepScanning = true; 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; keepScanning = false;
@ -855,8 +856,8 @@ void Table::sort (std::vector <int>& order)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Table::clean (std::string& value) void Table::clean (std::string& value)
{ {
unsigned int start = 0; size_t start = 0;
unsigned int pos; size_t pos;
while ((pos = value.find ('\t', start)) != std::string::npos) while ((pos = value.find ('\t', start)) != std::string::npos)
{ {
value.replace (pos, 1, " "); value.replace (pos, 1, " ");
@ -884,7 +885,7 @@ const std::string Table::render ()
// Print column headers in column order. // Print column headers in column order.
std::string output; std::string output;
for (unsigned int col = 0; col < mColumns.size (); ++col) for (size_t col = 0; col < mColumns.size (); ++col)
output += formatHeader ( output += formatHeader (
col, col,
mCalculatedWidth[col], mCalculatedWidth[col],
@ -907,8 +908,8 @@ const std::string Table::render ()
std::vector <std::vector <std::string> > columns; std::vector <std::vector <std::string> > columns;
std::vector <std::string> blanks; std::vector <std::string> blanks;
unsigned int maxHeight = 0; size_t maxHeight = 0;
for (unsigned int col = 0; col < mColumns.size (); ++col) for (size_t col = 0; col < mColumns.size (); ++col)
{ {
std::vector <std::string> lines; std::vector <std::string> lines;
std::string blank; std::string blank;
@ -928,9 +929,9 @@ const std::string Table::render ()
if (maxHeight) 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 ()) if (lines < columns[col].size ())
output += columns[col][lines]; output += columns[col][lines];
else else

View file

@ -136,7 +136,7 @@ void guess (const std::string& type, char** list, std::string& candidate)
error += " '"; error += " '";
error += candidate; error += candidate;
error += "' - could be either of "; 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) if (i)
error += ", "; error += ", ";
@ -165,8 +165,8 @@ static bool isCommand (const std::string& candidate)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool validDate (std::string& date) bool validDate (std::string& date)
{ {
unsigned int firstSlash = date.find ("/"); size_t firstSlash = date.find ("/");
unsigned int secondSlash = date.find ("/", firstSlash + 1); size_t secondSlash = date.find ("/", firstSlash + 1);
if (firstSlash != std::string::npos && if (firstSlash != std::string::npos &&
secondSlash != 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) 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])) if (!::isdigit (input[i]))
return false; return false;
@ -275,13 +275,13 @@ static bool validSubstitution (
std::string& from, std::string& from,
std::string& to) std::string& to)
{ {
unsigned int first = input.find ('/'); size_t first = input.find ('/');
if (first != std::string::npos) if (first != std::string::npos)
{ {
unsigned int second = input.find ('/', first + 1); size_t second = input.find ('/', first + 1);
if (second != std::string::npos) 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 (third != std::string::npos)
{ {
if (first == 0 && if (first == 0 &&
@ -318,10 +318,10 @@ void parse (
command = ""; command = "";
std::string descCandidate = ""; 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]); 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 from;
std::string to; std::string to;

View file

@ -2458,7 +2458,7 @@ void handleModify (const TDB& tdb, T& task, Config& conf)
if (from != "") if (from != "")
{ {
std::string description = original.getDescription (); std::string description = original.getDescription ();
unsigned int pattern = description.find (from); size_t pattern = description.find (from);
if (pattern != std::string::npos) if (pattern != std::string::npos)
{ {
description = description.substr (0, pattern) + description = description.substr (0, pattern) +

View file

@ -76,8 +76,8 @@ void extractParagraphs (const std::string& input, std::vector<std::string>& outp
std::string copy = input; std::string copy = input;
while (1) while (1)
{ {
unsigned int so = copy.find ("<p>"); size_t so = copy.find ("<p>");
unsigned int eo = copy.find ("</p>"); size_t eo = copy.find ("</p>");
if (so == std::string::npos && eo == std::string::npos) if (so == std::string::npos && eo == std::string::npos)
break; break;
@ -126,7 +126,7 @@ void unquoteText (std::string& text)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void extractLine (std::string& text, std::string& line, int length) 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. // Special case: found \n in first length characters.
if (eol != std::string::npos && eol < (unsigned) length) if (eol != std::string::npos && eol < (unsigned) length)