mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-24 18:06:42 +02:00
- Changes necessary for a clean build on Fedora9.
This commit is contained in:
parent
e392b8a95e
commit
cb4f86e9f1
8 changed files with 50 additions and 40 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
@ -35,7 +36,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 +45,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");
|
||||||
|
@ -96,12 +97,12 @@ void Config::createDefault (const std::string& file)
|
||||||
fprintf (out, "curses=on\n");
|
fprintf (out, "curses=on\n");
|
||||||
fprintf (out, "color=on\n");
|
fprintf (out, "color=on\n");
|
||||||
|
|
||||||
fprintf (out, "color.overdue=red\n");
|
fprintf (out, "color.overdue=bold_red\n");
|
||||||
fprintf (out, "#color.due=on yellow\n");
|
fprintf (out, "#color.due=on_bright_yellow\n");
|
||||||
fprintf (out, "#color.pri.H=on_red\n");
|
fprintf (out, "#color.pri.H=on_red\n");
|
||||||
fprintf (out, "#color.pri.M=on_yellow\n");
|
fprintf (out, "#color.pri.M=on_yellow\n");
|
||||||
fprintf (out, "#color.pri.L=on_green\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");
|
fprintf (out, "color.tagged=yellow\n");
|
||||||
|
|
||||||
fclose (out);
|
fclose (out);
|
||||||
|
|
12
src/Date.cpp
12
src/Date.cpp
|
@ -5,6 +5,8 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "Date.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)
|
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)
|
||||||
{
|
{
|
||||||
|
@ -155,7 +157,7 @@ int Date::daysInMonth (int month, int year)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Date::monthName (int month)
|
std::string Date::monthName (int month)
|
||||||
{
|
{
|
||||||
static char* months[12] =
|
static const char* months[12] =
|
||||||
{
|
{
|
||||||
"January",
|
"January",
|
||||||
"February",
|
"February",
|
||||||
|
@ -179,7 +181,7 @@ std::string Date::monthName (int month)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Date::dayName (int dow, std::string& name)
|
void Date::dayName (int dow, std::string& name)
|
||||||
{
|
{
|
||||||
static char* days[7] =
|
static const char* days[7] =
|
||||||
{
|
{
|
||||||
"Sunday",
|
"Sunday",
|
||||||
"Monday",
|
"Monday",
|
||||||
|
@ -196,7 +198,7 @@ void Date::dayName (int dow, std::string& name)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Date::dayName (int dow)
|
std::string Date::dayName (int dow)
|
||||||
{
|
{
|
||||||
static char* days[7] =
|
static const char* days[7] =
|
||||||
{
|
{
|
||||||
"Sunday",
|
"Sunday",
|
||||||
"Monday",
|
"Monday",
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "TDB.h"
|
#include "TDB.h"
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <Table.h>
|
#include <Table.h>
|
||||||
#include <Date.h>
|
#include <Date.h>
|
||||||
#include <task.h>
|
#include <task.h>
|
||||||
|
@ -415,7 +417,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 +442,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 +464,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 +595,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 +616,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 +672,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 +716,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 +759,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 +857,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 +886,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 +909,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 +930,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
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -13,7 +14,7 @@
|
||||||
#include "T.h"
|
#include "T.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static char* colors[] =
|
static const char* colors[] =
|
||||||
{
|
{
|
||||||
"bold",
|
"bold",
|
||||||
"underline",
|
"underline",
|
||||||
|
@ -75,7 +76,7 @@ static char* colors[] =
|
||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
static char* attributes[] =
|
static const char* attributes[] =
|
||||||
{
|
{
|
||||||
"project",
|
"project",
|
||||||
"priority",
|
"priority",
|
||||||
|
@ -88,7 +89,7 @@ static char* attributes[] =
|
||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
static char* commands[] =
|
static const char* commands[] =
|
||||||
{
|
{
|
||||||
"active",
|
"active",
|
||||||
"add",
|
"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 <std::string> options;
|
std::vector <std::string> options;
|
||||||
for (int i = 0; list[i][0]; ++i)
|
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 += " '";
|
||||||
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 +166,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 +237,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 +276,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 +319,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;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Table.h"
|
#include "Table.h"
|
||||||
#include "Date.h"
|
#include "Date.h"
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
@ -1694,7 +1695,7 @@ void handleReportHistory (const TDB& tdb, T& task, Config& conf)
|
||||||
table.setColumnJustification (4, Table::right);
|
table.setColumnJustification (4, Table::right);
|
||||||
table.setColumnJustification (5, Table::right);
|
table.setColumnJustification (5, Table::right);
|
||||||
|
|
||||||
char *months[] =
|
const char *months[] =
|
||||||
{
|
{
|
||||||
"January", "February", "March", "April", "May", "June",
|
"January", "February", "March", "April", "May", "June",
|
||||||
"July", "August", "September", "October", "November", "December",
|
"July", "August", "September", "October", "November", "December",
|
||||||
|
@ -2458,7 +2459,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) +
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include "Table.h"
|
#include "Table.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "../auto.h"
|
#include "../auto.h"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue