Code Cleanup

- Removed unnecessary use of the scope resolution operator.
This commit is contained in:
Paul Beckingham 2009-11-17 22:34:28 -05:00
parent 3214dc5d37
commit fbb217538e
18 changed files with 75 additions and 75 deletions

View file

@ -562,20 +562,20 @@ bool Att::match (const Att& other) const
if (which == "duration")
{
Duration literal (mValue);
Duration variable ((time_t)::atoi (other.mValue.c_str ()));
Duration variable ((time_t)atoi (other.mValue.c_str ()));
if (!(variable < literal))
return false;
}
else if (which == "date")
{
Date literal (mValue.c_str (), context.config.get ("dateformat", "m/d/Y"));
Date variable ((time_t)::atoi (other.mValue.c_str ()));
Date variable ((time_t)atoi (other.mValue.c_str ()));
if (other.mValue == "" || ! (variable < literal))
return false;
}
else if (which == "number")
{
if (::atoi (mValue.c_str ()) >= ::atoi (other.mValue.c_str ()))
if (atoi (mValue.c_str ()) >= atoi (other.mValue.c_str ()))
return false;
}
else if (which == "text")
@ -592,20 +592,20 @@ bool Att::match (const Att& other) const
if (which == "duration")
{
Duration literal (mValue);
Duration variable ((time_t)::atoi (other.mValue.c_str ()));
Duration variable ((time_t)atoi (other.mValue.c_str ()));
if (! (variable > literal))
return false;
}
else if (which == "date")
{
Date literal (mValue.c_str (), context.config.get ("dateformat", "m/d/Y"));
Date variable ((time_t)::atoi (other.mValue.c_str ()));
Date variable ((time_t)atoi (other.mValue.c_str ()));
if (! (variable > literal))
return false;
}
else if (which == "number")
{
if (::atoi (mValue.c_str ()) <= ::atoi (other.mValue.c_str ()))
if (atoi (mValue.c_str ()) <= atoi (other.mValue.c_str ()))
return false;
}
else if (which == "text")
@ -678,7 +678,7 @@ void Att::value (const std::string& value)
////////////////////////////////////////////////////////////////////////////////
int Att::value_int () const
{
return ::atoi (mValue.c_str ());
return atoi (mValue.c_str ());
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -150,7 +150,7 @@ Color::Color (const std::string& spec)
else if (word.substr (0, 4) == "grey" ||
word.substr (0, 4) == "gray")
{
index = ::atoi (word.substr (4, std::string::npos).c_str ());
index = atoi (word.substr (4, std::string::npos).c_str ());
if (index < 0 || index > 23)
throw std::string ("The color '") + *it + "' is not recognized.";
@ -171,14 +171,14 @@ Color::Color (const std::string& spec)
// rgbRGB, where 0 <= R,G,B <= 5.
else if (word.substr (0, 3) == "rgb")
{
index = ::atoi (word.substr (3, std::string::npos).c_str ());
index = atoi (word.substr (3, std::string::npos).c_str ());
if (word.length () != 6 ||
index < 0 || index > 555)
throw std::string ("The color '") + *it + "' is not recognized.";
int r = ::atoi (word.substr (3, 1).c_str ());
int g = ::atoi (word.substr (4, 1).c_str ());
int b = ::atoi (word.substr (5, 1).c_str ());
int r = atoi (word.substr (3, 1).c_str ());
int g = atoi (word.substr (4, 1).c_str ());
int b = atoi (word.substr (5, 1).c_str ());
if (r < 0 || r > 5 ||
g < 0 || g > 5 ||
b < 0 || b > 5)
@ -202,7 +202,7 @@ Color::Color (const std::string& spec)
// colorN, where 0 <= N <= 255.
else if (word.substr (0, 5) == "color")
{
index = ::atoi (word.substr (5, std::string::npos).c_str ());
index = atoi (word.substr (5, std::string::npos).c_str ());
if (index < 0 || index > 255)
throw std::string ("The color '") + *it + "' is not recognized.";

View file

@ -392,7 +392,7 @@ bool Config::get (const std::string& key, const bool default_value)
int Config::get (const std::string& key, const int default_value)
{
if ((*this).find (key) != (*this).end ())
return ::atoi ((*this)[key].c_str ());
return atoi ((*this)[key].c_str ());
return default_value;
}
@ -401,7 +401,7 @@ int Config::get (const std::string& key, const int default_value)
double Config::get (const std::string& key, const double default_value)
{
if ((*this).find (key) != (*this).end ())
return ::atof ((*this)[key].c_str ());
return atof ((*this)[key].c_str ());
return default_value;
}

View file

@ -92,12 +92,12 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
(mdy[i + 0] == '0' || mdy[i + 0] == '1') &&
isdigit (mdy[i + 1]))
{
month = ::atoi (mdy.substr (i, 2).c_str ());
month = atoi (mdy.substr (i, 2).c_str ());
i += 2;
}
else
{
month = ::atoi (mdy.substr (i, 1).c_str ());
month = atoi (mdy.substr (i, 1).c_str ());
++i;
}
break;
@ -113,12 +113,12 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
(mdy[i + 0] == '0' || mdy[i + 0] == '1' || mdy[i + 0] == '2' || mdy[i + 0] == '3') &&
isdigit (mdy[i + 1]))
{
day = ::atoi (mdy.substr (i, 2).c_str ());
day = atoi (mdy.substr (i, 2).c_str ());
i += 2;
}
else
{
day = ::atoi (mdy.substr (i, 1).c_str ());
day = atoi (mdy.substr (i, 1).c_str ());
++i;
}
break;
@ -132,7 +132,7 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
throw std::string ("\"") + mdy + "\" is not a valid date.";
}
year = ::atoi (mdy.substr (i, 2).c_str ()) + 2000;
year = atoi (mdy.substr (i, 2).c_str ()) + 2000;
i += 2;
break;
@ -144,7 +144,7 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
throw std::string ("\"") + mdy + "\" is not a valid date.";
}
month = ::atoi (mdy.substr (i, 2).c_str ());
month = atoi (mdy.substr (i, 2).c_str ());
i += 2;
break;
@ -156,7 +156,7 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
throw std::string ("\"") + mdy + "\" is not a valid date.";
}
day = ::atoi (mdy.substr (i, 2).c_str ());
day = atoi (mdy.substr (i, 2).c_str ());
i += 2;
break;
@ -171,7 +171,7 @@ Date::Date (const std::string& mdy, const std::string& format /* = "m/d/Y" */)
throw std::string ("\"") + mdy + "\" is not a valid date.";
}
year = ::atoi (mdy.substr (i, 4).c_str ());
year = atoi (mdy.substr (i, 4).c_str ());
i += 4;
break;
@ -404,7 +404,7 @@ int Date::weekOfYear (int weekStart) const
throw std::string ("The 'weekstart' configuration variable may "
"only contain 'Sunday' or 'Monday'.");
int weekNumber = ::atoi (weekStr);
int weekNumber = atoi (weekStr);
if (weekStart == 0)
weekNumber += 1;
@ -554,7 +554,7 @@ bool Date::isEpoch (const std::string& input)
if (digitsOnly (input) &&
input.length () > 8)
{
mT = (time_t) ::atoi (input.c_str ());
mT = (time_t) atoi (input.c_str ());
return true;
}
@ -670,12 +670,12 @@ bool Date::isRelativeDate (const std::string& input)
if (isdigit (input[1]))
{
number = ::atoi (input.substr (0, 2).c_str ());
number = atoi (input.substr (0, 2).c_str ());
ordinal = lowerCase (input.substr (2, std::string::npos));
}
else
{
number = ::atoi (input.substr (0, 2).c_str ());
number = atoi (input.substr (0, 2).c_str ());
ordinal = lowerCase (input.substr (1, std::string::npos));
}

View file

@ -178,7 +178,7 @@ void Duration::parse (const std::string& input)
if (! isdigit (lower_input[i]) &&
i == length - 1)
{
int number = ::atoi (lower_input.substr (0, i).c_str ());
int number = atoi (lower_input.substr (0, i).c_str ());
switch (lower_input[length - 1])
{

View file

@ -326,7 +326,7 @@ Grid::Cell::operator int () const
case CELL_INT: return mInt;
case CELL_FLOAT: return (int) mFloat;
case CELL_DOUBLE: return (int) mDouble;
case CELL_STRING: return ::atoi (mString.c_str ());
case CELL_STRING: return atoi (mString.c_str ());
}
return 0;
@ -341,7 +341,7 @@ Grid::Cell::operator float () const
case CELL_INT: return (float) mInt;
case CELL_FLOAT: return mFloat;
case CELL_DOUBLE: return (float) mDouble;
case CELL_STRING: return (float) ::atof (mString.c_str ());
case CELL_STRING: return (float) atof (mString.c_str ());
}
return 0.0;
@ -356,7 +356,7 @@ Grid::Cell::operator double () const
case CELL_INT: return (double) mInt;
case CELL_FLOAT: return (double) mFloat;
case CELL_DOUBLE: return mDouble;
case CELL_STRING: return (double) ::atof (mString.c_str ());
case CELL_STRING: return (double) atof (mString.c_str ());
}
return 0.0;

View file

@ -248,7 +248,7 @@ bool Nibbler::getInt (int& result)
if (i > mCursor)
{
result = ::atoi (mInput.substr (mCursor, i - mCursor).c_str ());
result = atoi (mInput.substr (mCursor, i - mCursor).c_str ());
mCursor = i;
return true;
}
@ -265,7 +265,7 @@ bool Nibbler::getUnsignedInt (int& result)
if (i > mCursor)
{
result = ::atoi (mInput.substr (mCursor, i - mCursor).c_str ());
result = atoi (mInput.substr (mCursor, i - mCursor).c_str ());
mCursor = i;
return true;
}

View file

@ -152,7 +152,7 @@ int Record::get_int (const std::string& name) const
{
Record::const_iterator i = this->find (name);
if (i != this->end ())
return ::atoi (i->second.value ().c_str ());
return atoi (i->second.value ().c_str ());
return 0;
}

View file

@ -98,7 +98,7 @@ void Sequence::parse (const std::string& input)
if (! validId (range[0]))
throw context.stringtable.get (SEQUENCE_BAD_SEQ, "Invalid ID in sequence");
int id = ::atoi (range[0].c_str ());
int id = atoi (range[0].c_str ());
this->push_back (id);
}
break;
@ -109,8 +109,8 @@ void Sequence::parse (const std::string& input)
! validId (range[1]))
throw context.stringtable.get (SEQUENCE_BAD_SEQ, "Invalid ID in range");
int low = ::atoi (range[0].c_str ());
int high = ::atoi (range[1].c_str ());
int low = atoi (range[0].c_str ());
int high = atoi (range[1].c_str ());
if (low > high)
throw context.stringtable.get (SEQUENCE_INVERTED, "Inverted sequence range high-low");

View file

@ -72,7 +72,7 @@ void StringTable::load (const std::string& file)
std::string::size_type equal = line.find (" "); // no i18n
if (equal != std::string::npos)
{
int key = ::atoi (trim (line.substr (0, equal), " \t").c_str ()); // no i18n
int key = atoi (trim (line.substr (0, equal), " \t").c_str ()); // no i18n
std::string value = trim (line.substr (equal+1, line.length () - equal), " \t"); // no i18n
(*this)[key] = value;
}

View file

@ -227,7 +227,7 @@ int TDB::loadPending (std::vector <Task>& tasks, Filter& filter)
fseek (location->pending, 0, SEEK_SET);
while (fgets (line, T_LINE_MAX, location->pending))
{
int length = ::strlen (line);
int length = strlen (line);
if (length > 3) // []\n
{
// TODO Add hidden attribute indicating source?
@ -290,7 +290,7 @@ int TDB::loadCompleted (std::vector <Task>& tasks, Filter& filter)
fseek (location->completed, 0, SEEK_SET);
while (fgets (line, T_LINE_MAX, location->completed))
{
int length = ::strlen (line);
int length = strlen (line);
if (length > 3) // []\n
{
// TODO Add hidden attribute indicating source?
@ -447,7 +447,7 @@ int TDB::gc ()
else if (s == Task::waiting)
{
// Wake up tasks that are waiting.
Date wait_date (::atoi (task->get ("wait").c_str ()));
Date wait_date (atoi (task->get ("wait").c_str ()));
if (now > wait_date)
{
task->setStatus (Task::pending);
@ -538,7 +538,7 @@ void TDB::undo ()
u.pop_back ();
}
Date lastChange (::atoi (when.c_str ()));
Date lastChange (atoi (when.c_str ()));
std::cout << std::endl
<< "The last modification was made "
<< lastChange.toString ()

View file

@ -261,7 +261,7 @@ void Table::addCell (const int row, const int col, const int data)
mData.add (row, col, value);
// Automatically maintain max width.
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) strlen (value));
}
////////////////////////////////////////////////////////////////////////////////
@ -276,7 +276,7 @@ void Table::addCell (const int row, const int col, const float data)
mData.add (row, col, value);
// Automatically maintain max width.
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) strlen (value));
}
////////////////////////////////////////////////////////////////////////////////
@ -291,7 +291,7 @@ void Table::addCell (const int row, const int col, const double data)
mData.add (row, col, value);
// Automatically maintain max width.
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) strlen (value));
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -37,7 +37,7 @@ extern Context context;
Timer::Timer (const std::string& description)
: mDescription (description)
{
::gettimeofday (&mStart, NULL);
gettimeofday (&mStart, NULL);
}
////////////////////////////////////////////////////////////////////////////////
@ -45,7 +45,7 @@ Timer::Timer (const std::string& description)
Timer::~Timer ()
{
struct timeval end;
::gettimeofday (&end, NULL);
gettimeofday (&end, NULL);
std::stringstream s;
s << "Timer " // No i18n

View file

@ -543,7 +543,7 @@ int runCustomReport (
// If the custom report has a defined limit, then allow a numeric override.
// This is an integer specified as a filter (limit:10).
if (context.task.has ("limit"))
maximum = ::atoi (context.task.get ("limit").c_str ());
maximum = atoi (context.task.get ("limit").c_str ());
std::stringstream out;
if (table.rowCount ())

View file

@ -37,7 +37,7 @@ int main (int argc, char** argv)
{
// Set up randomness.
struct timeval tv;
::gettimeofday (&tv, NULL);
gettimeofday (&tv, NULL);
#ifdef HAVE_SRANDOM
srandom (tv.tv_usec);
#else

View file

@ -340,7 +340,7 @@ void updateRecurrenceMask (
{
if (it->get ("uuid") == parent)
{
unsigned int index = ::atoi (task.get ("imask").c_str ());
unsigned int index = atoi (task.get ("imask").c_str ());
std::string mask = it->get ("mask");
if (mask.length () > index)
{

View file

@ -403,7 +403,7 @@ int handleInfo (std::string &outs)
row = table.addRow ();
table.addCell (row, 0, "Due");
Date dt (::atoi (task->get ("due").c_str ()));
Date dt (atoi (task->get ("due").c_str ()));
std::string due = getDueDate (*task);
table.addCell (row, 1, due);
@ -425,7 +425,7 @@ int handleInfo (std::string &outs)
{
row = table.addRow ();
table.addCell (row, 0, "Waiting until");
Date dt (::atoi (task->get ("wait").c_str ()));
Date dt (atoi (task->get ("wait").c_str ()));
table.addCell (row, 1, dt.toString (context.config.get ("dateformat", "m/d/Y")));
}
@ -434,7 +434,7 @@ int handleInfo (std::string &outs)
{
row = table.addRow ();
table.addCell (row, 0, "Start");
Date dt (::atoi (task->get ("start").c_str ()));
Date dt (atoi (task->get ("start").c_str ()));
table.addCell (row, 1, dt.toString (context.config.get ("dateformat", "m/d/Y")));
}
@ -443,7 +443,7 @@ int handleInfo (std::string &outs)
{
row = table.addRow ();
table.addCell (row, 0, "End");
Date dt (::atoi (task->get ("end").c_str ()));
Date dt (atoi (task->get ("end").c_str ()));
table.addCell (row, 1, dt.toString (context.config.get ("dateformat", "m/d/Y")));
}
@ -468,14 +468,14 @@ int handleInfo (std::string &outs)
// entry
row = table.addRow ();
table.addCell (row, 0, "Entered");
Date dt (::atoi (task->get ("entry").c_str ()));
Date dt (atoi (task->get ("entry").c_str ()));
std::string entry = dt.toString (context.config.get ("dateformat", "m/d/Y"));
std::string age;
std::string created = task->get ("entry");
if (created.length ())
{
Date dt (::atoi (created.c_str ()));
Date dt (atoi (created.c_str ()));
age = formatSeconds ((time_t) (now - dt));
}
@ -561,7 +561,7 @@ int handleReportSummary (std::string &outs)
{
++countPending[project];
time_t entry = ::atoi (task->get ("entry").c_str ());
time_t entry = atoi (task->get ("entry").c_str ());
if (entry)
sumEntry[project] = sumEntry[project] + (double) (now - entry);
}
@ -570,8 +570,8 @@ int handleReportSummary (std::string &outs)
{
++countCompleted[project];
time_t entry = ::atoi (task->get ("entry").c_str ());
time_t end = ::atoi (task->get ("end").c_str ());
time_t entry = atoi (task->get ("entry").c_str ());
time_t end = atoi (task->get ("end").c_str ());
if (entry && end)
sumEntry[project] = sumEntry[project] + (double) (end - entry);
}
@ -747,7 +747,7 @@ time_t monthlyEpoch (const std::string& date)
// to epoch form for the date m/1/y.
if (date.length ())
{
Date d1 (::atoi (date.c_str ()));
Date d1 (atoi (date.c_str ()));
int m, d, y;
d1.toMDY (m, d, y);
Date d2 (m, 1, y);
@ -1204,7 +1204,7 @@ int handleReportTimesheet (std::string &outs)
// If task completed within range.
if (task->getStatus () == Task::completed)
{
Date compDate (::atoi (task->get ("end").c_str ()));
Date compDate (atoi (task->get ("end").c_str ()));
if (compDate >= start && compDate < end)
{
int row = completed.addRow ();
@ -1260,7 +1260,7 @@ int handleReportTimesheet (std::string &outs)
if (task->getStatus () == Task::pending &&
task->has ("start"))
{
Date startDate (::atoi (task->get ("start").c_str ()));
Date startDate (atoi (task->get ("start").c_str ()));
if (startDate >= start && startDate < end)
{
int row = started.addRow ();
@ -1433,7 +1433,7 @@ std::string renderMonths (
if (task->getStatus () == Task::pending &&
task->has ("due"))
{
Date due (::atoi (task->get ("due").c_str ()));
Date due (atoi (task->get ("due").c_str ()));
if ((context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) &&
due.day () == d &&
@ -1513,7 +1513,7 @@ int handleReportCalendar (std::string &outs)
// task cal 2010
monthsToDisplay = 12;
mFrom = 1;
yFrom = ::atoi( context.args[1].data());
yFrom = atoi( context.args[1].data());
}
}
else if (numberOfArgs == 3 ) {
@ -1525,15 +1525,15 @@ int handleReportCalendar (std::string &outs)
else {
// task cal 8 2010
monthsToDisplay = monthsPerLine;
mFrom = ::atoi( context.args[1].data());
yFrom = ::atoi( context.args[2].data());
mFrom = atoi( context.args[1].data());
yFrom = atoi( context.args[2].data());
}
}
else if (numberOfArgs == 4 ) {
// task cal 8 2010 y
monthsToDisplay = 12;
mFrom = ::atoi( context.args[1].data());
yFrom = ::atoi( context.args[2].data());
mFrom = atoi( context.args[1].data());
yFrom = atoi( context.args[2].data());
}
if (getpendingdate == true) {
@ -1545,7 +1545,7 @@ int handleReportCalendar (std::string &outs)
{
if (task->has ("due"))
{
Date d (::atoi (task->get ("due").c_str ()));
Date d (atoi (task->get ("due").c_str ()));
if (d < oldest) oldest = d;
}
}
@ -1702,13 +1702,13 @@ int handleReportStats (std::string &outs)
if (it->getStatus () == Task::recurring) ++recurringT;
if (it->getStatus () == Task::waiting) ++waitingT;
time_t entry = ::atoi (it->get ("entry").c_str ());
time_t entry = atoi (it->get ("entry").c_str ());
if (entry < earliest) earliest = entry;
if (entry > latest) latest = entry;
if (it->getStatus () == Task::completed)
{
time_t end = ::atoi (it->get ("end").c_str ());
time_t end = atoi (it->get ("end").c_str ());
daysPending += (end - entry) / 86400.0;
}
@ -1889,7 +1889,7 @@ void gatherNextTasks (std::vector <Task>& tasks)
{
if (task->has ("due"))
{
Date d (::atoi (task->get ("due").c_str ()));
Date d (atoi (task->get ("due").c_str ()));
if (d < now + (7 * 24 * 60 * 60)) // if due:< 1wk
{
std::string project = task->get ("project");
@ -2051,7 +2051,7 @@ std::string getFullDescription (Task& task)
task.getAnnotations (annotations);
foreach (anno, annotations)
{
Date dt (::atoi (anno->name ().substr (11, std::string::npos).c_str ()));
Date dt (atoi (anno->name ().substr (11, std::string::npos).c_str ()));
std::string when = dt.toString (context.config.get ("dateformat", "m/d/Y"));
desc += "\n" + when + " " + anno->value ();
}
@ -2065,7 +2065,7 @@ std::string getDueDate (Task& task)
std::string due = task.get ("due");
if (due.length ())
{
Date d (::atoi (due.c_str ()));
Date d (atoi (due.c_str ()));
due = d.toString (context.config.get ("dateformat", "m/d/Y"));
}

View file

@ -52,7 +52,7 @@ if (open my $fh, '>', 'font.rc')
# 1* 1 0 dashes
# 1* 1 1 underline
#
# * When ::isatty (fileno (stdout)) is false, color is automatically disabled.
# * When isatty (fileno (stdout)) is false, color is automatically disabled.
qx{../task rc:font.rc add foo};
my $output = qx{../task 1 info rc:font.rc rc.color:off rc._forcecolor:off rc.fontunderline:off};