Cleanup: Don't use string literals when character literals are needed

This commit is contained in:
Paul Beckingham 2016-10-14 23:11:28 -04:00
parent 95f4989f77
commit 8922728888
27 changed files with 122 additions and 122 deletions

View file

@ -72,9 +72,9 @@ std::string Msg::serialize () const
{
std::string output;
for (auto& i : _header)
output += i.first + ": " + i.second + "\n";
output += i.first + ": " + i.second + '\n';
output += "\n" + _payload + "\n";
output += '\n' + _payload + '\n';
return output;
}
@ -95,7 +95,7 @@ bool Msg::parse (const std::string& input)
{
auto delimiter = i.find (':');
if (delimiter == std::string::npos)
throw std::string ("ERROR: Malformed message header '") + i + "'";
throw std::string ("ERROR: Malformed message header '") + i + '\'';
_header[Lexer::trim (i.substr (0, delimiter))] = Lexer::trim (i.substr (delimiter + 1));
}

View file

@ -61,7 +61,7 @@ TF2::~TF2 ()
{
if (_dirty && TDB2::debug_mode)
std::cout << format (STRING_TDB2_DIRTY_EXIT, std::string (_file))
<< "\n";
<< '\n';
}
////////////////////////////////////////////////////////////////////////////////
@ -301,7 +301,7 @@ void TF2::commit ()
for (auto& task : _tasks)
// Skip over the tasks that are marked to be purged
if (_purged_tasks.find (task.get ("uuid")) == _purged_tasks.end ())
_file.write_raw (task.composeF4 () + "\n");
_file.write_raw (task.composeF4 () + '\n');
// Write out all the added lines.
_file.append (_added_lines);
@ -708,9 +708,9 @@ void TDB2::update (
// old <task>
// new <task>
// ---
undo.add_line ("time " + ISO8601d ().toEpochString () + "\n");
undo.add_line ("old " + original.composeF4 () + "\n");
undo.add_line ("new " + task.composeF4 () + "\n");
undo.add_line ("time " + ISO8601d ().toEpochString () + '\n');
undo.add_line ("old " + original.composeF4 () + '\n');
undo.add_line ("new " + task.composeF4 () + '\n');
undo.add_line ("---\n");
}
else
@ -727,14 +727,14 @@ void TDB2::update (
// time <time>
// new <task>
// ---
undo.add_line ("time " + ISO8601d ().toEpochString () + "\n");
undo.add_line ("new " + task.composeF4 () + "\n");
undo.add_line ("time " + ISO8601d ().toEpochString () + '\n');
undo.add_line ("new " + task.composeF4 () + '\n');
undo.add_line ("---\n");
}
// Add task to backlog.
if (add_to_backlog)
backlog.add_line (task.composeJSON () + "\n");
backlog.add_line (task.composeJSON () + '\n');
}
////////////////////////////////////////////////////////////////////////////////
@ -861,7 +861,7 @@ void TDB2::revert ()
File::write (backlog._file._data, b);
}
else
std::cout << STRING_CMD_CONFIG_NO_CHANGE << "\n";
std::cout << STRING_CMD_CONFIG_NO_CHANGE << '\n';
}
////////////////////////////////////////////////////////////////////////////////
@ -909,7 +909,7 @@ void TDB2::revert_pending (
const std::string& uuid,
const std::string& prior)
{
std::string uuid_att = "uuid:\"" + uuid + "\"";
std::string uuid_att = "uuid:\"" + uuid + '"';
// is 'current' in pending?
for (auto task = p.begin (); task != p.end (); ++task)
@ -922,12 +922,12 @@ void TDB2::revert_pending (
if (prior != "")
{
*task = prior;
std::cout << STRING_TDB2_REVERTED << "\n";
std::cout << STRING_TDB2_REVERTED << '\n';
}
else
{
p.erase (task);
std::cout << STRING_TDB2_REMOVED << "\n";
std::cout << STRING_TDB2_REMOVED << '\n';
}
break;
@ -942,7 +942,7 @@ void TDB2::revert_completed (
const std::string& uuid,
const std::string& prior)
{
std::string uuid_att = "uuid:\"" + uuid + "\"";
std::string uuid_att = "uuid:\"" + uuid + '"';
// is 'current' in completed?
for (auto task = c.begin (); task != c.end (); ++task)
@ -961,12 +961,12 @@ void TDB2::revert_completed (
{
c.erase (task);
p.push_back (prior);
std::cout << STRING_TDB2_REVERTED << "\n";
std::cout << STRING_TDB2_REVERTED << '\n';
context.debug ("TDB::revert_completed - task belongs in pending.data");
}
else
{
std::cout << STRING_TDB2_REVERTED << "\n";
std::cout << STRING_TDB2_REVERTED << '\n';
context.debug ("TDB::revert_completed - task belongs in completed.data");
}
}
@ -974,11 +974,11 @@ void TDB2::revert_completed (
{
c.erase (task);
std::cout << STRING_TDB2_REVERTED << "\n";
std::cout << STRING_TDB2_REVERTED << '\n';
context.debug ("TDB::revert_completed - task removed");
}
std::cout << STRING_TDB2_UNDO_COMPLETE << "\n";
std::cout << STRING_TDB2_UNDO_COMPLETE << '\n';
break;
}
}
@ -991,7 +991,7 @@ void TDB2::revert_backlog (
const std::string& current,
const std::string& prior)
{
std::string uuid_att = "\"uuid\":\"" + uuid + "\"";
std::string uuid_att = "\"uuid\":\"" + uuid + '"';
bool found = false;
for (auto task = b.rbegin (); task != b.rend (); ++task)
@ -1038,9 +1038,9 @@ void TDB2::show_diff (
if (context.config.get ("undo.style") == "side")
{
std::cout << "\n"
std::cout << '\n'
<< format (STRING_TDB2_LAST_MOD, lastChange.toString ())
<< "\n";
<< '\n';
// Attributes are all there is, so figure the different attribute names
// between before and after.
@ -1114,9 +1114,9 @@ void TDB2::show_diff (
}
}
std::cout << "\n"
std::cout << '\n'
<< view.render ()
<< "\n";
<< '\n';
}
// This style looks like this:
@ -1203,21 +1203,21 @@ void TDB2::show_diff (
else if (before_att != "" && after_att == "")
{
row = view.addRow ();
view.set (row, 0, "-" + a + ":", color_red);
view.set (row, 0, '-' + a + ':', color_red);
view.set (row, 1, before_att, color_red);
row = view.addRow ();
view.set (row, 0, "+" + a + ":", color_green);
view.set (row, 0, '+' + a + ':', color_green);
}
// Attribute added.
else if (before_att == "" && after_att != "")
{
row = view.addRow ();
view.set (row, 0, "-" + a + ":", color_red);
view.set (row, 0, '-' + a + ':', color_red);
row = view.addRow ();
view.set (row, 0, "+" + a + ":", color_green);
view.set (row, 0, '+' + a + ':', color_green);
view.set (row, 1, after_att, color_green);
}
@ -1225,19 +1225,19 @@ void TDB2::show_diff (
else
{
row = view.addRow ();
view.set (row, 0, "-" + a + ":", color_red);
view.set (row, 0, '-' + a + ':', color_red);
view.set (row, 1, before_att, color_red);
row = view.addRow ();
view.set (row, 0, "+" + a + ":", color_green);
view.set (row, 0, '+' + a + ':', color_green);
view.set (row, 1, after_att, color_green);
}
}
}
std::cout << "\n"
std::cout << '\n'
<< view.render ()
<< "\n";
<< '\n';
}
}

View file

@ -799,7 +799,7 @@ void Task::parseLegacy (const std::string& line)
std::stringstream message;
message << "Invalid fileformat at line '"
<< line
<< "'";
<< '\'';
context.debug (message.str ());
#endif
throw std::string (STRING_TASK_PARSE_UNREC_FF);
@ -836,13 +836,13 @@ std::string Task::composeF4 () const
ff4 += encode (json::encode (it.second));
else
ff4 += it.second;
ff4 += "\"";
ff4 += '"';
first = false;
}
}
ff4 += "]";
ff4 += ']';
return ff4;
}
@ -850,12 +850,12 @@ std::string Task::composeF4 () const
std::string Task::composeJSON (bool decorate /*= false*/) const
{
std::stringstream out;
out << "{";
out << '{';
// ID inclusion is optional, but not a good idea, because it remains correct
// only until the next gc.
if (decorate)
out << "\"id\":" << id << ",";
out << "\"id\":" << id << ',';
// First the non-annotations.
int attributes_written = 0;
@ -870,7 +870,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
continue;
if (attributes_written)
out << ",";
out << ',';
std::string type = Task::attributes[i.first];
if (type == "")
@ -880,12 +880,12 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
if (type == "date")
{
ISO8601d d (i.second);
out << "\""
out << '"'
<< (i.first == "modification" ? "modified" : i.first)
<< "\":\""
// Date was deleted, do not export parsed empty string
<< (i.second == "" ? "" : d.toISO ())
<< "\"";
<< '"';
++attributes_written;
}
@ -898,7 +898,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
*/
else if (type == "numeric")
{
out << "\""
out << '"'
<< i.first
<< "\":"
<< i.second;
@ -918,12 +918,12 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
for (auto i : tags)
{
if (count++)
out << ",";
out << ',';
out << "\"" << i << "\"";
out << '"' << i << '"';
}
out << "]";
out << ']';
++attributes_written;
}
@ -958,23 +958,23 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
for (auto i : deps)
{
if (count++)
out << ",";
out << ',';
out << "\"" << i << "\"";
out << '"' << i << '"';
}
out << "]";
out << ']';
++attributes_written;
}
// Everything else is a quoted value.
else
{
out << "\""
out << '"'
<< i.first
<< "\":\""
<< (type == "string" ? json::encode (i.second) : i.second)
<< "\"";
<< '"';
++attributes_written;
}
@ -983,7 +983,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
// Now the annotations, if any.
if (annotation_count)
{
out << ","
out << ','
<< "\"annotations\":[";
int annotations_written = 0;
@ -992,7 +992,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
if (! i.first.compare (0, 11, "annotation_", 11))
{
if (annotations_written)
out << ",";
out << ',';
ISO8601d d (i.first.substr (11));
out << "{\"entry\":\""
@ -1005,18 +1005,18 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
}
}
out << "]";
out << ']';
}
#ifdef PRODUCT_TASKWARRIOR
// Include urgency.
if (decorate)
out << ","
out << ','
<< "\"urgency\":"
<< urgency_c ();
#endif
out << "}";
out << '}';
return out.str ();
}
@ -1123,7 +1123,7 @@ void Task::addDependency (const std::string& uuid)
{
// Check for extant dependency.
if (depends.find (uuid) == std::string::npos)
set ("depends", depends + "," + uuid);
set ("depends", depends + ',' + uuid);
else
{
#ifdef PRODUCT_TASKWARRIOR
@ -1828,7 +1828,7 @@ float Task::urgency_c () const
if (end != std::string::npos)
{
const std::string uda = var.first.substr (12, end - 12);
auto dot = uda.find (".");
auto dot = uda.find ('.');
if (dot == std::string::npos)
{
// urgency.uda.<name>.coefficient
@ -2106,13 +2106,13 @@ void Task::modify (modType type, bool text_required /* = false */)
if (a.attribute ("sign") == "+")
{
context.debug (label + "tags <-- add '" + tag + "'");
context.debug (label + "tags <-- add '" + tag + '\'');
addTag (tag);
feedback_special_tags (*this, tag);
}
else
{
context.debug (label + "tags <-- remove '" + tag + "'");
context.debug (label + "tags <-- remove '" + tag + '\'');
removeTag (tag);
}
@ -2138,7 +2138,7 @@ void Task::modify (modType type, bool text_required /* = false */)
switch (type)
{
case modReplace:
context.debug (label + "description <-- '" + text + "'");
context.debug (label + "description <-- '" + text + '\'');
set ("description", text);
break;
@ -2148,12 +2148,12 @@ void Task::modify (modType type, bool text_required /* = false */)
break;
case modAppend:
context.debug (label + "description <-- description + '" + text + "'");
context.debug (label + "description <-- description + '" + text + '\'');
set ("description", get ("description") + ' ' + text);
break;
case modAnnotate:
context.debug (label + "new annotation <-- '" + text + "'");
context.debug (label + "new annotation <-- '" + text + '\'');
addAnnotation (text);
break;
}

View file

@ -125,7 +125,7 @@ void ColumnDepends::render (
dependencyGetBlocking (task, blocking);
if (_style == "count")
renderStringRight (lines, width, color, "[" + format (static_cast <int>(blocking.size ())) + "]");
renderStringRight (lines, width, color, '[' + format (static_cast <int>(blocking.size ())) + ']');
else if (_style == "default" ||
_style == "list")

View file

@ -238,7 +238,7 @@ void ColumnDescription::render (
else if (_style == "count")
{
if (task.annotation_count)
description += " [" + format (task.annotation_count) + "]";
description += " [" + format (task.annotation_count) + ']';
std::vector <std::string> raw;
wrapText (raw, description, width, _hyphenate);
@ -256,7 +256,7 @@ void ColumnDescription::render (
int len_annos = 0;
if (task.annotation_count)
{
annos_count = " [" + format (task.annotation_count) + "]";
annos_count = " [" + format (task.annotation_count) + ']';
len_annos = utf8_width (annos_count);
len += len_annos;
}

View file

@ -134,7 +134,7 @@ void ColumnProject::modify (Task& task, const std::string& value)
Variant v;
e.evaluateInfixExpression (value, v);
task.set (_name, (std::string) v);
context.debug (label + _name + " <-- '" + (std::string) v + "' <-- '" + value + "'");
context.debug (label + _name + " <-- '" + (std::string) v + "' <-- '" + value + '\'');
}
catch (const std::string& e)
{
@ -143,7 +143,7 @@ void ColumnProject::modify (Task& task, const std::string& value)
if (e == STRING_EVAL_NOT_EXPRESSION)
{
task.set (_name, value);
context.debug (label + _name + " <-- '" + value + "'");
context.debug (label + _name + " <-- '" + value + '\'');
}
else
throw;
@ -152,7 +152,7 @@ void ColumnProject::modify (Task& task, const std::string& value)
else
{
task.set (_name, value);
context.debug (label + _name + " <-- '" + value + "'");
context.debug (label + _name + " <-- '" + value + '\'');
}
}

View file

@ -129,7 +129,7 @@ void ColumnRecur::modify (Task& task, const std::string& value)
{
// Store the raw value, for 'recur'.
std::string label = " MODIFICATION ";
context.debug (label + _name + " <-- '" + value + "'");
context.debug (label + _name + " <-- '" + value + '\'');
task.set (_name, value);
}
else

View file

@ -154,7 +154,7 @@ void ColumnTags::render (
{
std::vector <std::string> all;
split (all, tags, ',');
renderStringRight (lines, width, color, "[" + format (static_cast <int> (all.size ())) + "]");
renderStringRight (lines, width, color, '[' + format (static_cast <int> (all.size ())) + ']');
}
}
}
@ -187,12 +187,12 @@ void ColumnTags::modify (Task& task, const std::string& value)
Variant v;
e.evaluateInfixExpression (value, v);
task.addTag ((std::string) v);
context.debug (label + "tags <-- '" + (std::string) v + "' <-- '" + tag + "'");
context.debug (label + "tags <-- '" + (std::string) v + "' <-- '" + tag + '\'');
}
else
{
task.addTag (tag);
context.debug (label + "tags <-- '" + tag + "'");
context.debug (label + "tags <-- '" + tag + '\'');
}
feedback_special_tags (task, tag);

View file

@ -61,7 +61,7 @@ ColumnTypeDate::ColumnTypeDate ()
now.toEpochString (),
now.toISO (),
ISO8601p (ISO8601d () - now).formatVague (),
"-" + ISO8601p (ISO8601d () - now).formatVague (),
'-' + ISO8601p (ISO8601d () - now).formatVague (),
"",
ISO8601p (ISO8601d () - now).format ()};
}
@ -183,7 +183,7 @@ void ColumnTypeDate::render (
if (now > date)
renderStringLeft (lines, width, color, ISO8601p (now - date).formatVague ());
else
renderStringLeft (lines, width, color, "-" + ISO8601p (date - now).formatVague ());
renderStringLeft (lines, width, color, '-' + ISO8601p (date - now).formatVague ());
}
else if (_style == "relative")
{
@ -191,7 +191,7 @@ void ColumnTypeDate::render (
if (now < date)
renderStringLeft (lines, width, color, ISO8601p (date - now).formatVague ());
else
renderStringLeft (lines, width, color, "-" + ISO8601p (now - date).formatVague ());
renderStringLeft (lines, width, color, '-' + ISO8601p (now - date).formatVague ());
}
else if (_style == "remaining")
@ -226,7 +226,7 @@ void ColumnTypeDate::modify (Task& task, const std::string& value)
std::string label = " MODIFICATION ";
if (evaluatedValue.type () == Variant::type_duration)
{
context.debug (label + _name + " <-- '" + format ("{1}", format (evaluatedValue.get_duration ())) + "' <-- '" + (std::string) evaluatedValue + "' <-- '" + value + "'");
context.debug (label + _name + " <-- '" + format ("{1}", format (evaluatedValue.get_duration ())) + "' <-- '" + (std::string) evaluatedValue + "' <-- '" + value + '\'');
Variant now;
if (namedDates ("now", now))
evaluatedValue += now;
@ -234,7 +234,7 @@ void ColumnTypeDate::modify (Task& task, const std::string& value)
else
{
evaluatedValue.cast (Variant::type_date);
context.debug (label + _name + " <-- '" + format ("{1}", evaluatedValue.get_date ()) + "' <-- '" + (std::string) evaluatedValue + "' <-- '" + value + "'");
context.debug (label + _name + " <-- '" + format ("{1}", evaluatedValue.get_date ()) + "' <-- '" + (std::string) evaluatedValue + "' <-- '" + value + '\'');
}
// If a date doesn't parse (2/29/2014) then it evaluates to zero.

View file

@ -68,7 +68,7 @@ void ColumnTypeDuration::modify (Task& task, const std::string& value)
if (evaluatedValue.type () == Variant::type_duration)
{
// Store the raw value, for 'recur'.
context.debug (label + _name + " <-- " + (std::string) evaluatedValue + " <-- '" + value + "'");
context.debug (label + _name + " <-- " + (std::string) evaluatedValue + " <-- '" + value + '\'');
task.set (_name, evaluatedValue);
}
else

View file

@ -63,7 +63,7 @@ void ColumnTypeNumeric::modify (Task& task, const std::string& value)
}
std::string label = " MODIFICATION ";
context.debug (label + _name + " <-- '" + evaluatedValue.get_string () + "' <-- '" + value + "'");
context.debug (label + _name + " <-- '" + evaluatedValue.get_string () + "' <-- '" + value + '\'');
// If the result is not readily convertible to a numeric value, then this is
// an error.

View file

@ -66,7 +66,7 @@ void ColumnTypeString::modify (Task& task, const std::string& value)
if (validate (strValue))
{
task.set (_name, strValue);
context.debug (label + _name + " <-- '" + strValue + "' <-- '" + value + "'");
context.debug (label + _name + " <-- '" + strValue + "' <-- '" + value + '\'');
}
else
throw format (STRING_INVALID_MOD, _name, value);
@ -76,7 +76,7 @@ void ColumnTypeString::modify (Task& task, const std::string& value)
if (validate (value))
{
task.set (_name, value);
context.debug (label + _name + " <-- '" + value + "'");
context.debug (label + _name + " <-- '" + value + '\'');
}
else
throw format (STRING_INVALID_MOD, _name, value);

View file

@ -60,7 +60,7 @@ int CmdZshAttributes::execute (std::string& output)
std::stringstream out;
for (auto& col : columns)
out << col << ":" << col << '\n';
out << col << ':' << col << '\n';
output = out.str ();
return 0;

View file

@ -214,7 +214,7 @@ Chart::Chart (char type)
std::vector <std::string> words = context.cli2.getWords ();
std::string filter;
join (filter, " ", words);
_title = "(" + filter + ")";
_title = '(' + filter + ')';
}
////////////////////////////////////////////////////////////////////////////////
@ -860,7 +860,7 @@ void Chart::calculateRates ()
_completion = end.toString (format)
+ " ("
+ delta.formatVague ()
+ ")";
+ ')';
std::stringstream completion_message;
completion_message << "Chart::calculateRates ("

View file

@ -224,8 +224,8 @@ int CmdZshCommands::execute (std::string& output)
// Emit the commands in order.
std::stringstream out;
for (auto& zc : commands)
out << zc._command << ":"
<< Command::categoryNames.at (zc._category) << ":"
out << zc._command << ':'
<< Command::categoryNames.at (zc._category) << ':'
<< zc._description << '\n';
output = out.str ();

View file

@ -65,8 +65,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.
auto comment = line.find ("#");
auto pos = line.find (name + "=");
auto comment = line.find ('#');
auto pos = line.find (name + '=');
if (pos != std::string::npos &&
(comment == std::string::npos ||
@ -77,9 +77,9 @@ bool CmdConfig::setConfigVariable (std::string name, std::string value, bool con
confirm (format (STRING_CMD_CONFIG_CONFIRM, name, context.config.get (name), value)))
{
if (comment != std::string::npos)
line = name + "=" + json::encode (value) + ' ' + line.substr (comment);
line = name + '=' + json::encode (value) + ' ' + line.substr (comment);
else
line = name + "=" + json::encode (value);
line = name + '=' + json::encode (value);
change = true;
}
@ -91,7 +91,7 @@ bool CmdConfig::setConfigVariable (std::string name, std::string value, bool con
(!confirmation ||
confirm (format (STRING_CMD_CONFIG_CONFIRM2, name, value))))
{
contents.push_back (name + "=" + json::encode (value));
contents.push_back (name + '=' + json::encode (value));
change = true;
}
@ -116,8 +116,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.
auto comment = line->find ("#");
auto pos = line->find (name + "=");
auto comment = line->find ('#');
auto pos = line->find (name + '=');
if (pos != std::string::npos &&
(comment == std::string::npos ||

View file

@ -89,7 +89,7 @@ int CmdDiagnostics::execute (std::string& output)
<< " " << STRING_CMD_DIAG_VERSION << ": "
<< __VERSION__ << '\n'
#endif
<< " " << STRING_CMD_DIAG_CAPS << ":"
<< " " << STRING_CMD_DIAG_CAPS << ':'
#ifdef __STDC__
<< " +stdc"
#endif
@ -168,7 +168,7 @@ int CmdDiagnostics::execute (std::string& output)
#ifdef CMAKE_BUILD_TYPE
<< CMAKE_BUILD_TYPE
#else
<< "-"
<< '-'
#endif
<< "\n\n";
@ -273,7 +273,7 @@ int CmdDiagnostics::execute (std::string& output)
auto last_slash = credentials.rfind ('/');
if (last_slash != std::string::npos)
credentials = credentials.substr (0, last_slash)
+ "/"
+ '/'
+ std::string (credentials.length () - last_slash - 1, '*');
out << " Creds: "
@ -379,7 +379,7 @@ int CmdDiagnostics::execute (std::string& output)
<< (term ? term : STRING_CMD_DIAG_NONE)
<< " ("
<< context.getWidth ()
<< "x"
<< 'x'
<< context.getHeight ()
<< ")\n";

View file

@ -798,7 +798,7 @@ CmdEdit::editResult CmdEdit::editFile (Task& task)
// Complete the command line.
editor += ' ';
editor += "\"" + file.str () + "\"";
editor += '"' + file.str () + '"';
ARE_THESE_REALLY_HARMFUL:
bool changes = false; // No changes made.

View file

@ -84,7 +84,7 @@ int CmdExport::execute (std::string& output)
if (counter)
{
if (json_array)
output += ",";
output += ',';
output += '\n';
}

View file

@ -525,9 +525,9 @@ int CmdGHistoryMonthly::execute (std::string& output)
}
else
{
std::string aBar = ""; while (aBar.length () < addedBar) aBar += "+";
std::string cBar = ""; while (cBar.length () < completedBar) cBar += "X";
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += "-";
std::string aBar = ""; while (aBar.length () < addedBar) aBar += '+';
std::string cBar = ""; while (cBar.length () < completedBar) cBar += 'X';
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += '-';
bar += std::string (leftOffset - aBar.length (), ' ');
bar += aBar + cBar + dBar;
@ -722,9 +722,9 @@ int CmdGHistoryAnnual::execute (std::string& output)
}
else
{
std::string aBar = ""; while (aBar.length () < addedBar) aBar += "+";
std::string cBar = ""; while (cBar.length () < completedBar) cBar += "X";
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += "-";
std::string aBar = ""; while (aBar.length () < addedBar) aBar += '+';
std::string cBar = ""; while (cBar.length () < completedBar) cBar += 'X';
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += '-';
bar += std::string (leftOffset - aBar.length (), ' ');
bar += aBar + cBar + dBar;

View file

@ -103,7 +103,7 @@ std::string CmdIDs::compressIds (const std::vector <int>& ids)
result << ' ';
if (range_start < range_end)
result << ids[range_start] << "-" << ids[range_end];
result << ids[range_start] << '-' << ids[range_end];
else
result << ids[range_start];
}
@ -119,7 +119,7 @@ std::string CmdIDs::compressIds (const std::vector <int>& ids)
result << ' ';
if (range_start < range_end)
result << ids[range_start] << "-" << ids[range_end];
result << ids[range_start] << '-' << ids[range_end];
else
result << ids[range_start];
@ -312,7 +312,7 @@ int CmdZshCompletionUuids::execute (std::string& output)
std::stringstream out;
for (auto& task : filtered)
out << task.get ("uuid")
<< ":"
<< ':'
<< str_replace (task.get ("description"), ":", zshColonReplacement)
<< '\n';

View file

@ -231,7 +231,7 @@ int CmdInfo::execute (std::string& output)
age = ISO8601p (now - dt).formatVague ();
}
view.set (row, 1, entry + " (" + age + ")");
view.set (row, 1, entry + " (" + age + ')');
// wait
if (task.has ("wait"))
@ -289,7 +289,7 @@ int CmdInfo::execute (std::string& output)
ISO8601d mod (task.get_date ("modified"));
std::string age = ISO8601p (now - mod).formatVague ();
view.set (row, 1, mod.toString (dateformat) + " (" + age + ")");
view.set (row, 1, mod.toString (dateformat) + " (" + age + ')');
}
// tags ...
@ -399,8 +399,8 @@ int CmdInfo::execute (std::string& output)
context.columns.find (att) == context.columns.end ())
{
row = view.addRow ();
view.set (row, 0, "[" + att);
view.set (row, 1, task.get (att) + "]");
view.set (row, 0, '[' + att);
view.set (row, 1, task.get (att) + ']');
}
}

View file

@ -232,7 +232,7 @@ int CmdStats::execute (std::string& output)
view.set (row, 0, STRING_CMD_STATS_TAGGED);
std::stringstream value;
value << std::setprecision (3) << (100.0 * taggedT / totalT) << "%";
value << std::setprecision (3) << (100.0 * taggedT / totalT) << '%';
view.set (row, 1, value.str ());
}

View file

@ -207,7 +207,7 @@ static void colorizeKeyword (Task& task, const std::string& rule, const Color& b
static void colorizeUDA (Task& task, const std::string& rule, const Color& base, Color& c, bool merge)
{
// Is the rule color.uda.name.value or color.uda.name?
auto pos = rule.find (".", 10);
auto pos = rule.find ('.', 10);
if (pos == std::string::npos)
{
if (task.has (rule.substr (10)))

View file

@ -283,7 +283,7 @@ bool extractLine (
// No backtrack, possible hyphenation.
else if (hyphenate)
{
line = text.substr (offset, prior_cursor - offset) + "-";
line = text.substr (offset, prior_cursor - offset) + '-';
offset = prior_cursor;
return true;
}

View file

@ -73,7 +73,7 @@ template<typename T>
const std::string format (int fmt_num, const std::string& fmt, T arg)
{
std::string output = fmt;
replace_positional (output, "{" + format (fmt_num) + "}", format (arg));
replace_positional (output, '{' + format (fmt_num) + '}', format (arg));
return output;
}

View file

@ -64,7 +64,7 @@ static void signal_handler (int s)
{
if (s == SIGINT)
{
std::cout << "\n\n" << STRING_ERROR_CONFIRM_SIGINT << "\n";
std::cout << "\n\n" << STRING_ERROR_CONFIRM_SIGINT << '\n';
exit (1);
}
}
@ -89,7 +89,7 @@ bool confirm (const std::string& question)
std::string answer {""};
std::getline (std::cin, answer);
context.debug ("STDIN '" + answer + "'");
context.debug ("STDIN '" + answer + '\'');
answer = std::cin.eof () ? STRING_UTIL_CONFIRM_NO : Lexer::lowerCase (Lexer::trim (answer));
autoComplete (answer, options, matches, 1); // Hard-coded 1.
@ -121,15 +121,15 @@ int confirm4 (const std::string& question)
{
std::cout << question
<< " ("
<< options[1] << "/"
<< options[2] << "/"
<< options[4] << "/"
<< options[1] << '/'
<< options[2] << '/'
<< options[4] << '/'
<< options[5]
<< ") ";
std::string answer {""};
std::getline (std::cin, answer);
context.debug ("STDIN '" + answer + "'");
context.debug ("STDIN '" + answer + '\'');
answer = std::cin.eof () ? STRING_UTIL_CONFIRM_QUIT : Lexer::lowerCase (Lexer::trim (answer));
autoComplete (answer, options, matches, 1); // Hard-coded 1.
}