C++11: N1984 auto

This commit is contained in:
Paul Beckingham 2015-05-24 13:36:26 -04:00
parent 7bbc794d3a
commit e8d04bdce6
24 changed files with 77 additions and 77 deletions

View file

@ -593,7 +593,7 @@ void Chart::optimizeGrid ()
std::string::size_type ws;
while ((ws = _grid.find (" \n")) != std::string::npos)
{
std::string::size_type non_ws = ws;
auto non_ws = ws;
while (_grid[non_ws] == ' ')
--non_ws;

View file

@ -336,7 +336,7 @@ int CmdCalendar::execute (std::string& output)
// If the executable was "cal" or equivalent, replace it with "task".
std::string executable = context.cli._args[0].attribute ("raw");
std::string::size_type cal = executable.find ("cal");
auto cal = executable.find ("cal");
if (cal != std::string::npos)
executable = executable.substr (0, cal) + PACKAGE;

View file

@ -59,8 +59,8 @@ bool CmdConfig::setConfigVariable (std::string name, std::string value, bool con
for (auto& line : contents)
{
// If there is a comment on the line, it must follow the pattern.
std::string::size_type comment = line.find ("#");
std::string::size_type pos = line.find (name + "=");
auto comment = line.find ("#");
auto pos = line.find (name + "=");
if (pos != std::string::npos &&
(comment == std::string::npos ||
@ -110,8 +110,8 @@ int CmdConfig::unsetConfigVariable (std::string name, bool confirmation /* = fal
bool lineDeleted = false;
// If there is a comment on the line, it must follow the pattern.
std::string::size_type comment = line->find ("#");
std::string::size_type pos = line->find (name + "=");
auto comment = line->find ("#");
auto pos = line->find (name + "=");
if (pos != std::string::npos &&
(comment == std::string::npos ||

View file

@ -108,7 +108,7 @@ int CmdDenotate::execute (std::string& output)
{
for (auto i = annotations.begin (); i != annotations.end (); ++i)
{
std::string::size_type loc = find (i->second, pattern, sensitive);
auto loc = find (i->second, pattern, sensitive);
if (loc != std::string::npos)
{
anno = i->second;

View file

@ -285,7 +285,7 @@ int CmdDiagnostics::execute (std::string& output)
// Get credentials, but mask out the key.
std::string credentials = context.config.get ("taskd.credentials");
std::string::size_type last_slash = credentials.rfind ('/');
auto last_slash = credentials.rfind ('/');
if (last_slash != std::string::npos)
credentials = credentials.substr (0, last_slash)
+ "/"

View file

@ -78,10 +78,10 @@ std::string CmdEdit::findValue (
const std::string& text,
const std::string& name)
{
std::string::size_type found = text.find (name);
auto found = text.find (name);
if (found != std::string::npos)
{
std::string::size_type eol = text.find ("\n", found + 1);
auto eol = text.find ("\n", found + 1);
if (eol != std::string::npos)
{
std::string value = text.substr (
@ -101,10 +101,10 @@ std::string CmdEdit::findMultilineValue (
const std::string& startMarker,
const std::string& endMarker)
{
std::string::size_type start = text.find (startMarker);
auto start = text.find (startMarker);
if (start != std::string::npos)
{
std::string::size_type end = text.find (endMarker, start);
auto end = text.find (endMarker, start);
if (end != std::string::npos)
{
std::string value = text.substr (start + startMarker.length (),
@ -128,7 +128,7 @@ std::vector <std::string> CmdEdit::findValues (
found = text.find (name, found + 1);
if (found != std::string::npos)
{
std::string::size_type eol = text.find ("\n", found + 1);
auto eol = text.find ("\n", found + 1);
if (eol != std::string::npos)
{
std::string value = text.substr (
@ -612,14 +612,14 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
{
found += 14; // Length of "\n Annotation:".
std::string::size_type eol = after.find ("\n", found + 1);
auto eol = after.find ("\n", found + 1);
if (eol != std::string::npos)
{
std::string value = trim (after.substr (
found,
eol - found), "\t ");
std::string::size_type gap = value.find (" -- ");
auto gap = value.find (" -- ");
if (gap != std::string::npos)
{
// TODO keeping the initial dates even if dateformat approximates them
@ -714,7 +714,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
std::vector <std::string> orphanValues = findValues (after, "\n UDA Orphan ");
for (auto& orphan : orphanValues)
{
std::string::size_type colon = orphan.find (':');
auto colon = orphan.find (':');
if (colon != std::string::npos)
{
std::string name = trim (orphan.substr (0, colon), "\t ");

View file

@ -426,7 +426,7 @@ int CmdInfo::execute (std::string& output)
if (var.first.substr (0, 13) == "urgency.user.")
{
// urgency.user.project.<project>.coefficient
std::string::size_type end = std::string::npos;
auto end = std::string::npos;
if (var.first.substr (13, 8) == "project." &&
(end = var.first.find (".coefficient")) != std::string::npos)
{
@ -459,11 +459,11 @@ int CmdInfo::execute (std::string& output)
{
// urgency.uda.<name>.coefficient
// urgency.uda.<name>.<value>.coefficient
std::string::size_type end = var.first.find (".coefficient");
auto end = var.first.find (".coefficient");
if (end != std::string::npos)
{
const std::string uda = var.first.substr (12, end - 12);
std::string::size_type dot = uda.find (".");
auto dot = uda.find (".");
if (dot == std::string::npos)
{
// urgency.uda.<name>.coefficient

View file

@ -56,7 +56,7 @@ int CmdReports::execute (std::string& output)
if (i.first.substr (0, 7) == "report.")
{
std::string report = i.first.substr (7);
std::string::size_type columns = report.find (".columns");
auto columns = report.find (".columns");
if (columns != std::string::npos)
reports.push_back (report.substr (0, columns));
}

View file

@ -337,7 +337,7 @@ bool CmdSync::send (
{
// It is important that the ':' be the *last* colon, in order to support
// IPv6 addresses.
std::string::size_type colon = to.rfind (':');
auto colon = to.rfind (':');
if (colon == std::string::npos)
throw format (STRING_CMD_SYNC_BAD_SERVER, to);

View file

@ -60,7 +60,7 @@ int CmdUDAs::execute (std::string& output)
if (name.first.substr (0, 4) == "uda." &&
name.first.find (".type") != std::string::npos)
{
std::string::size_type period = name.first.find ('.', 4);
auto period = name.first.find ('.', 4);
if (period != std::string::npos)
udas.push_back (name.first.substr (4, period - 4));
}
@ -187,7 +187,7 @@ int CmdCompletionUDAs::execute (std::string& output)
if (name.first.substr (0, 4) == "uda." &&
name.first.find (".type") != std::string::npos)
{
std::string::size_type period = name.first.find ('.', 4);
auto period = name.first.find ('.', 4);
if (period != std::string::npos)
udas.push_back (name.first.substr (4, period - 4));
}

View file

@ -170,7 +170,7 @@ void Command::factory (std::map <std::string, Command*>& all)
if (i.first.substr (0, 7) == "report.")
{
std::string report = i.first.substr (7);
std::string::size_type columns = report.find (".columns");
auto columns = report.find (".columns");
if (columns != std::string::npos)
reports.push_back (report.substr (0, columns));
}