Portability - Haiku R1/alpha1
- Added necessary include files and edits in order to build task on Haiku R1/alpha1.
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include "Context.h"
|
#include "Context.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
|||||||
29
src/Date.cpp
29
src/Date.cpp
@@ -29,6 +29,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include "Date.h"
|
#include "Date.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@@ -82,14 +83,14 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
|
|||||||
// Single or double digit.
|
// Single or double digit.
|
||||||
case 'm':
|
case 'm':
|
||||||
if (i >= mdy.length () ||
|
if (i >= mdy.length () ||
|
||||||
! ::isdigit (mdy[i]))
|
! isdigit (mdy[i]))
|
||||||
{
|
{
|
||||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i + 1 < mdy.length () &&
|
if (i + 1 < mdy.length () &&
|
||||||
(mdy[i + 0] == '0' || mdy[i + 0] == '1') &&
|
(mdy[i + 0] == '0' || mdy[i + 0] == '1') &&
|
||||||
::isdigit (mdy[i + 1]))
|
isdigit (mdy[i + 1]))
|
||||||
{
|
{
|
||||||
month = ::atoi (mdy.substr (i, 2).c_str ());
|
month = ::atoi (mdy.substr (i, 2).c_str ());
|
||||||
i += 2;
|
i += 2;
|
||||||
@@ -103,14 +104,14 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
|
|||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
if (i >= mdy.length () ||
|
if (i >= mdy.length () ||
|
||||||
! ::isdigit (mdy[i]))
|
! isdigit (mdy[i]))
|
||||||
{
|
{
|
||||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i + 1 < mdy.length () &&
|
if (i + 1 < mdy.length () &&
|
||||||
(mdy[i + 0] == '0' || mdy[i + 0] == '1' || mdy[i + 0] == '2' || mdy[i + 0] == '3') &&
|
(mdy[i + 0] == '0' || mdy[i + 0] == '1' || mdy[i + 0] == '2' || mdy[i + 0] == '3') &&
|
||||||
::isdigit (mdy[i + 1]))
|
isdigit (mdy[i + 1]))
|
||||||
{
|
{
|
||||||
day = ::atoi (mdy.substr (i, 2).c_str ());
|
day = ::atoi (mdy.substr (i, 2).c_str ());
|
||||||
i += 2;
|
i += 2;
|
||||||
@@ -125,8 +126,8 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
|
|||||||
// Double digit.
|
// Double digit.
|
||||||
case 'y':
|
case 'y':
|
||||||
if (i + 1 >= mdy.length () ||
|
if (i + 1 >= mdy.length () ||
|
||||||
! ::isdigit (mdy[i + 0]) ||
|
! isdigit (mdy[i + 0]) ||
|
||||||
! ::isdigit (mdy[i + 1]))
|
! isdigit (mdy[i + 1]))
|
||||||
{
|
{
|
||||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||||
}
|
}
|
||||||
@@ -137,8 +138,8 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
|
|||||||
|
|
||||||
case 'M':
|
case 'M':
|
||||||
if (i + 1 >= mdy.length () ||
|
if (i + 1 >= mdy.length () ||
|
||||||
! ::isdigit (mdy[i + 0]) ||
|
! isdigit (mdy[i + 0]) ||
|
||||||
! ::isdigit (mdy[i + 1]))
|
! isdigit (mdy[i + 1]))
|
||||||
{
|
{
|
||||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||||
}
|
}
|
||||||
@@ -149,8 +150,8 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
|
|||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
if (i + 1 >= mdy.length () ||
|
if (i + 1 >= mdy.length () ||
|
||||||
! ::isdigit (mdy[i + 0]) ||
|
! isdigit (mdy[i + 0]) ||
|
||||||
! ::isdigit (mdy[i + 1]))
|
! isdigit (mdy[i + 1]))
|
||||||
{
|
{
|
||||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||||
}
|
}
|
||||||
@@ -162,10 +163,10 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
|
|||||||
// Quadruple digit.
|
// Quadruple digit.
|
||||||
case 'Y':
|
case 'Y':
|
||||||
if (i + 3 >= mdy.length () ||
|
if (i + 3 >= mdy.length () ||
|
||||||
! ::isdigit (mdy[i + 0]) ||
|
! isdigit (mdy[i + 0]) ||
|
||||||
! ::isdigit (mdy[i + 1]) ||
|
! isdigit (mdy[i + 1]) ||
|
||||||
! ::isdigit (mdy[i + 2]) ||
|
! isdigit (mdy[i + 2]) ||
|
||||||
! ::isdigit (mdy[i + 3]))
|
! isdigit (mdy[i + 3]))
|
||||||
{
|
{
|
||||||
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
throw std::string ("\"") + mdy + "\" is not a valid date.";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ bool Nibbler::getInt (int& result)
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (i < mInput.length () && ::isdigit (mInput[i]))
|
while (i < mInput.length () && isdigit (mInput[i]))
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
if (i > mCursor)
|
if (i > mCursor)
|
||||||
@@ -260,7 +260,7 @@ bool Nibbler::getInt (int& result)
|
|||||||
bool Nibbler::getUnsignedInt (int& result)
|
bool Nibbler::getUnsignedInt (int& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = mCursor;
|
std::string::size_type i = mCursor;
|
||||||
while (i < mInput.length () && ::isdigit (mInput[i]))
|
while (i < mInput.length () && isdigit (mInput[i]))
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
if (i > mCursor)
|
if (i > mCursor)
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ bool Sequence::validId (const std::string& input) const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t 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;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -876,7 +876,7 @@ void Table::sort (std::vector <int>& order)
|
|||||||
if (gap > 1)
|
if (gap > 1)
|
||||||
{
|
{
|
||||||
gap = (int) ((float)gap / 1.3);
|
gap = (int) ((float)gap / 1.3);
|
||||||
if (gap == 10 or gap == 9)
|
if (gap == 10 || gap == 9)
|
||||||
gap = 11;
|
gap = 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Timer::~Timer ()
|
|||||||
<< mDescription
|
<< mDescription
|
||||||
<< " "
|
<< " "
|
||||||
<< std::setprecision (6)
|
<< std::setprecision (6)
|
||||||
<< std::fixed
|
// << std::fixed
|
||||||
<< ((end.tv_sec - mStart.tv_sec) + ((end.tv_usec - mStart.tv_usec )
|
<< ((end.tv_sec - mStart.tv_sec) + ((end.tv_usec - mStart.tv_usec )
|
||||||
/ 1000000.0))
|
/ 1000000.0))
|
||||||
<< " sec";
|
<< " sec";
|
||||||
|
|||||||
@@ -106,16 +106,16 @@ static fileType determineFileType (const std::vector <std::string>& lines)
|
|||||||
{
|
{
|
||||||
if ( lines[i][0] == 'x' &&
|
if ( lines[i][0] == 'x' &&
|
||||||
lines[i][1] == ' ' &&
|
lines[i][1] == ' ' &&
|
||||||
::isdigit (lines[i][2]) &&
|
isdigit (lines[i][2]) &&
|
||||||
::isdigit (lines[i][3]) &&
|
isdigit (lines[i][3]) &&
|
||||||
::isdigit (lines[i][4]) &&
|
isdigit (lines[i][4]) &&
|
||||||
::isdigit (lines[i][5]) &&
|
isdigit (lines[i][5]) &&
|
||||||
lines[i][6] == '-' &&
|
lines[i][6] == '-' &&
|
||||||
::isdigit (lines[i][7]) &&
|
isdigit (lines[i][7]) &&
|
||||||
::isdigit (lines[i][8]) &&
|
isdigit (lines[i][8]) &&
|
||||||
lines[i][9] == '-' &&
|
lines[i][9] == '-' &&
|
||||||
::isdigit (lines[i][10]) &&
|
isdigit (lines[i][10]) &&
|
||||||
::isdigit (lines[i][11]))
|
isdigit (lines[i][11]))
|
||||||
return todo_sh_2_0;
|
return todo_sh_2_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,13 +126,13 @@ static fileType determineFileType (const std::vector <std::string>& lines)
|
|||||||
// +project
|
// +project
|
||||||
if (words[w].length () > 1 &&
|
if (words[w].length () > 1 &&
|
||||||
words[w][0] == '+' &&
|
words[w][0] == '+' &&
|
||||||
::isalnum (words[w][1]))
|
isalnum (words[w][1]))
|
||||||
return todo_sh_2_0;
|
return todo_sh_2_0;
|
||||||
|
|
||||||
// @context
|
// @context
|
||||||
if (words[w].length () > 1 &&
|
if (words[w].length () > 1 &&
|
||||||
words[w][0] == '@' &&
|
words[w][0] == '@' &&
|
||||||
::isalnum (words[w][1]))
|
isalnum (words[w][1]))
|
||||||
return todo_sh_2_0;
|
return todo_sh_2_0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1400,9 +1400,9 @@ std::string renderMonths (
|
|||||||
row = 0;
|
row = 0;
|
||||||
|
|
||||||
// Loop through days in month and add to table.
|
// Loop through days in month and add to table.
|
||||||
for (int d = 1; d <= daysInMonth.at (mpl); ++d)
|
for (int d = 1; d <= daysInMonth[mpl]; ++d)
|
||||||
{
|
{
|
||||||
Date temp (months.at (mpl), d, years.at (mpl));
|
Date temp (months[mpl], d, years[mpl]);
|
||||||
int dow = temp.dayOfWeek ();
|
int dow = temp.dayOfWeek ();
|
||||||
int woy = temp.weekOfYear (weekStart);
|
int woy = temp.weekOfYear (weekStart);
|
||||||
|
|
||||||
@@ -1420,9 +1420,9 @@ std::string renderMonths (
|
|||||||
table.addCell (row, thisCol, d);
|
table.addCell (row, thisCol, d);
|
||||||
|
|
||||||
if ((context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) &&
|
if ((context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) &&
|
||||||
today.day () == d &&
|
today.day () == d &&
|
||||||
today.month () == months.at (mpl) &&
|
today.month () == months[mpl] &&
|
||||||
today.year () == years.at (mpl))
|
today.year () == years[mpl])
|
||||||
table.setCellFg (row, thisCol, Text::cyan);
|
table.setCellFg (row, thisCol, Text::cyan);
|
||||||
|
|
||||||
foreach (task, all)
|
foreach (task, all)
|
||||||
@@ -1434,8 +1434,8 @@ std::string renderMonths (
|
|||||||
|
|
||||||
if ((context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) &&
|
if ((context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) &&
|
||||||
due.day () == d &&
|
due.day () == d &&
|
||||||
due.month () == months.at (mpl) &&
|
due.month () == months[mpl] &&
|
||||||
due.year () == years.at (mpl))
|
due.year () == years[mpl])
|
||||||
{
|
{
|
||||||
table.setCellFg (row, thisCol, Text::black);
|
table.setCellFg (row, thisCol, Text::black);
|
||||||
table.setCellBg (row, thisCol, due < today ? Text::on_red : Text::on_yellow);
|
table.setCellBg (row, thisCol, due < today ? Text::on_red : Text::on_yellow);
|
||||||
@@ -1447,7 +1447,7 @@ std::string renderMonths (
|
|||||||
int eow = 6;
|
int eow = 6;
|
||||||
if (weekStart == 1)
|
if (weekStart == 1)
|
||||||
eow = 0;
|
eow = 0;
|
||||||
if (dow == eow && d < daysInMonth.at (mpl))
|
if (dow == eow && d < daysInMonth[mpl])
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
24
src/text.cpp
24
src/text.cpp
@@ -209,7 +209,7 @@ std::string commify (const std::string& data)
|
|||||||
int i;
|
int i;
|
||||||
for (int i = 0; i < (int) data.length (); ++i)
|
for (int i = 0; i < (int) data.length (); ++i)
|
||||||
{
|
{
|
||||||
if (::isdigit (data[i]))
|
if (isdigit (data[i]))
|
||||||
end = i;
|
end = i;
|
||||||
|
|
||||||
if (data[i] == '.')
|
if (data[i] == '.')
|
||||||
@@ -227,11 +227,11 @@ std::string commify (const std::string& data)
|
|||||||
int consecutiveDigits = 0;
|
int consecutiveDigits = 0;
|
||||||
for (; i >= 0; --i)
|
for (; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (::isdigit (data[i]))
|
if (isdigit (data[i]))
|
||||||
{
|
{
|
||||||
result += data[i];
|
result += data[i];
|
||||||
|
|
||||||
if (++consecutiveDigits == 3 && i && ::isdigit (data[i - 1]))
|
if (++consecutiveDigits == 3 && i && isdigit (data[i - 1]))
|
||||||
{
|
{
|
||||||
result += ',';
|
result += ',';
|
||||||
consecutiveDigits = 0;
|
consecutiveDigits = 0;
|
||||||
@@ -251,11 +251,11 @@ std::string commify (const std::string& data)
|
|||||||
int consecutiveDigits = 0;
|
int consecutiveDigits = 0;
|
||||||
for (; i >= 0; --i)
|
for (; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (::isdigit (data[i]))
|
if (isdigit (data[i]))
|
||||||
{
|
{
|
||||||
result += data[i];
|
result += data[i];
|
||||||
|
|
||||||
if (++consecutiveDigits == 3 && i && ::isdigit (data[i - 1]))
|
if (++consecutiveDigits == 3 && i && isdigit (data[i - 1]))
|
||||||
{
|
{
|
||||||
result += ',';
|
result += ',';
|
||||||
consecutiveDigits = 0;
|
consecutiveDigits = 0;
|
||||||
@@ -279,8 +279,8 @@ std::string lowerCase (const std::string& input)
|
|||||||
{
|
{
|
||||||
std::string output = input;
|
std::string output = input;
|
||||||
for (int i = 0; i < (int) input.length (); ++i)
|
for (int i = 0; i < (int) input.length (); ++i)
|
||||||
if (::isupper (input[i]))
|
if (isupper (input[i]))
|
||||||
output[i] = ::tolower (input[i]);
|
output[i] = tolower (input[i]);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@@ -290,8 +290,8 @@ std::string upperCase (const std::string& input)
|
|||||||
{
|
{
|
||||||
std::string output = input;
|
std::string output = input;
|
||||||
for (int i = 0; i < (int) input.length (); ++i)
|
for (int i = 0; i < (int) input.length (); ++i)
|
||||||
if (::islower (input[i]))
|
if (islower (input[i]))
|
||||||
output[i] = ::toupper (input[i]);
|
output[i] = toupper (input[i]);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@@ -302,7 +302,7 @@ std::string ucFirst (const std::string& input)
|
|||||||
std::string output = input;
|
std::string output = input;
|
||||||
|
|
||||||
if (output.length () > 0)
|
if (output.length () > 0)
|
||||||
output[0] = ::toupper (output[0]);
|
output[0] = toupper (output[0]);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@@ -352,7 +352,7 @@ void guess (
|
|||||||
bool digitsOnly (const std::string& input)
|
bool digitsOnly (const std::string& input)
|
||||||
{
|
{
|
||||||
for (size_t 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;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -362,7 +362,7 @@ bool digitsOnly (const std::string& input)
|
|||||||
bool noSpaces (const std::string& input)
|
bool noSpaces (const std::string& input)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < input.length (); ++i)
|
for (size_t i = 0; i < input.length (); ++i)
|
||||||
if (::isspace (input[i]))
|
if (isspace (input[i]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user