diff --git a/src/CLI2.cpp b/src/CLI2.cpp index c8a2d06db..55dfc1aa5 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -32,8 +32,8 @@ #include #include #include -#include -#include +#include +#include #include extern Context context; @@ -1480,8 +1480,7 @@ void CLI2::findIDs () else if (a._lextype == Lexer::Type::set) { // Split the ID list into elements. - std::vector elements; - split (elements, a.attribute ("raw"), ','); + auto elements = split (a.attribute ("raw"), ','); for (auto& element : elements) { @@ -1536,8 +1535,7 @@ void CLI2::findIDs () a.tag ("FILTER"); // Split the ID list into elements. - std::vector elements; - split (elements, raw, ','); + auto elements = split (raw, ','); for (const auto& element : elements) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6eaee7cf0..3d4e5f9d3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,12 +35,16 @@ add_library (task CLI2.cpp CLI2.h text.cpp text.h util.cpp util.h) -add_library (libshared libshared/src/FS.cpp libshared/src/FS.h +add_library (libshared libshared/src/Datetime.cpp libshared/src/Datetime.h + libshared/src/Duration.cpp libshared/src/Duration.h + libshared/src/FS.cpp libshared/src/FS.h libshared/src/JSON.cpp libshared/src/JSON.h libshared/src/Pig.cpp libshared/src/Pig.h libshared/src/RX.cpp libshared/src/RX.h libshared/src/Table.cpp libshared/src/Table.h libshared/src/Timer.cpp libshared/src/Timer.h + libshared/src/shared.cpp libshared/src/shared.h + libshared/src/format.cpp libshared/src/format.h libshared/src/unicode.cpp libshared/src/unicode.h libshared/src/utf8.cpp libshared/src/utf8.h libshared/src/wcwidth6.cpp) diff --git a/src/Color.cpp b/src/Color.cpp index 557fdfea6..a516e2270 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -31,7 +31,8 @@ #include #include #include -#include +#include +#include #include #include @@ -130,8 +131,7 @@ Color::Color (const std::string& spec) : _value (0) { // Split spec into words. - std::vector words; - split (words, spec, ' '); + auto words = split (spec, ' '); // Construct the color as two separate colors, then blend them later. This // make it possible to declare a color such as "color1 on black", and have diff --git a/src/Config.cpp b/src/Config.cpp index be606f8bb..681a101ce 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include diff --git a/src/Context.cpp b/src/Context.cpp index 518099b13..61c591531 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -39,8 +39,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -576,7 +576,8 @@ bool Context::verbose (const std::string& token) if (verbosity.empty ()) { verbosity_legacy = config.getBoolean ("verbose"); - split (verbosity, config.get ("verbose"), ','); + for (auto& token : split (config.get ("verbose"), ',')) + verbosity.insert (token); // Regular feedback means almost everything. // This odd test is to see if a Boolean-false value is a real one, which @@ -700,8 +701,7 @@ void Context::staticInitialization () rc.first.substr (rc.first.length () - 7, 7) == ".values") { std::string name = rc.first.substr (4, rc.first.length () - 7 - 4); - std::vector values; - split (values, rc.second, ','); + auto values = split (rc.second, ','); for (auto r = values.rbegin(); r != values.rend (); ++r) Task::customOrder[name].push_back (*r); diff --git a/src/DOM.cpp b/src/DOM.cpp index f1b06bbd9..88b6c3c65 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -32,7 +32,8 @@ #include #include #include -#include +#include +#include #include #include @@ -189,8 +190,7 @@ bool getDOM (const std::string& name, const Task& task, Variant& value) } // split name on '.' - std::vector elements; - split (elements, name, '.'); + auto elements = split (name, '.'); Task ref (task); Nibbler n (elements[0]); diff --git a/src/Dates.cpp b/src/Dates.cpp index a721b6a49..1cb4273f0 100644 --- a/src/Dates.cpp +++ b/src/Dates.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/Eval.cpp b/src/Eval.cpp index 9736d0981..f4f0a2a2f 100644 --- a/src/Eval.cpp +++ b/src/Eval.cpp @@ -31,7 +31,8 @@ #include #include #include -#include +#include +#include #include extern Context context; diff --git a/src/Filter.cpp b/src/Filter.cpp index 169ae9ac2..9e7d06c07 100644 --- a/src/Filter.cpp +++ b/src/Filter.cpp @@ -34,8 +34,8 @@ #include #include #include -#include -#include +#include +#include extern Context context; diff --git a/src/Hooks.cpp b/src/Hooks.cpp index abff63366..109aa0490 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -39,10 +39,12 @@ #include #include #include +#include #include #include +#include +#include #include -#include #include extern Context context; @@ -468,7 +470,9 @@ void Hooks::assertSameTask (const std::vector & input, const Task& } json::string* up = (json::string*) u->second; - std::string json_uuid = json::decode (unquoteText (up->dump ())); + auto text = up->dump (); + Lexer::dequote (text); + std::string json_uuid = json::decode (text); if (json_uuid != uuid) { context.error (format (STRING_HOOK_ERROR_SAME2, uuid, json_uuid)); @@ -562,7 +566,7 @@ int Hooks::callHookScript ( else status = execute (script, args, inputStr, outputStr); - split (output, outputStr, '\n'); + output = split (outputStr, '\n'); if (_debug >= 2) { diff --git a/src/ISO8601.cpp b/src/ISO8601.cpp index 0830c21fd..9528393dc 100644 --- a/src/ISO8601.cpp +++ b/src/ISO8601.cpp @@ -35,7 +35,8 @@ #ifdef PRODUCT_TASKWARRIOR #include #endif -#include +#include +#include #include #include diff --git a/src/TDB2.cpp b/src/TDB2.cpp index fa5cea3da..b8caae2b0 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -37,8 +37,8 @@ #include #include #include -#include -#include +#include +#include #include extern Context context; diff --git a/src/TLSClient.cpp b/src/TLSClient.cpp index 8f7653db8..1a9927daf 100644 --- a/src/TLSClient.cpp +++ b/src/TLSClient.cpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #define MAX_BUF 16384 diff --git a/src/Task.cpp b/src/Task.cpp index 1b2d3d8f7..a284b849e 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -45,7 +45,8 @@ #ifdef PRODUCT_TASKWARRIOR #include #endif -#include +#include +#include #include #include @@ -712,8 +713,7 @@ void Task::parseJSON (const json::object* root_obj) else if (i.first == "depends" && i.second->type() == json::j_string) { json::string* deps = (json::string*)i.second; - std::vector uuids; - split (uuids, deps->_data, ','); + auto uuids = split (deps->_data, ','); for (const auto& uuid : uuids) addDependency (uuid); @@ -721,11 +721,19 @@ void Task::parseJSON (const json::object* root_obj) // Strings are decoded. else if (type == "string") - set (i.first, json::decode (unquoteText (i.second->dump ()))); + { + auto text = i.second->dump (); + Lexer::dequote (text); + set (i.first, json::decode (text)); + } // Other types are simply added. else - set (i.first, unquoteText (i.second->dump ())); + { + auto text = i.second->dump (); + Lexer::dequote (text); + set (i.first, text); + } } // UDA orphans and annotations do not have columns. @@ -769,7 +777,9 @@ void Task::parseJSON (const json::object* root_obj) << "' --> preserved\n"; context.debug (message.str ()); #endif - set (i.first, json::decode (unquoteText (i.second->dump ()))); + auto text = i.second->dump (); + Lexer::dequote (text); + set (i.first, json::decode (text)); } } } @@ -909,8 +919,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const // Tags are converted to an array. else if (i.first == "tags") { - std::vector tags; - split (tags, i.second, ','); + auto tags = split (i.second, ','); out << "\"tags\":["; @@ -949,8 +958,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const #endif ) { - std::vector deps; - split (deps, i.second, ','); + auto deps = split (i.second, ','); out << "\"depends\":["; @@ -1148,16 +1156,13 @@ void Task::addDependency (const std::string& uuid) //////////////////////////////////////////////////////////////////////////////// void Task::removeDependency (const std::string& uuid) { - std::vector deps; - split (deps, get ("depends"), ','); + auto deps = split (get ("depends"), ','); auto i = std::find (deps.begin (), deps.end (), uuid); if (i != deps.end ()) { deps.erase (i); - std::string combined; - join (combined, ",", deps); - set ("depends", combined); + set ("depends", join (",", deps)); recalc_urgency = true; } else @@ -1178,8 +1183,7 @@ void Task::removeDependency (int id) //////////////////////////////////////////////////////////////////////////////// void Task::getDependencies (std::vector & all) const { - std::vector deps; - split (deps, get ("depends"), ','); + auto deps = split (get ("depends"), ','); all.clear (); @@ -1190,15 +1194,13 @@ void Task::getDependencies (std::vector & all) const //////////////////////////////////////////////////////////////////////////////// void Task::getDependencies (std::vector & all) const { - all.clear (); - split (all, get ("depends"), ','); + all = split (get ("depends"), ','); } //////////////////////////////////////////////////////////////////////////////// void Task::getDependencies (std::vector & all) const { - std::vector deps; - split (deps, get ("depends"), ','); + std::vector deps = split (get ("depends"), ','); all.clear (); @@ -1214,9 +1216,7 @@ void Task::getDependencies (std::vector & all) const //////////////////////////////////////////////////////////////////////////////// int Task::getTagCount () const { - std::vector tags; - split (tags, get ("tags"), ','); - + auto tags = split (get ("tags"), ','); return (int) tags.size (); } @@ -1275,8 +1275,7 @@ bool Task::hasTag (const std::string& tag) const } // Concrete tags. - std::vector tags; - split (tags, get ("tags"), ','); + auto tags = split (get ("tags"), ','); if (std::find (tags.begin (), tags.end (), tag) != tags.end ()) return true; @@ -1287,15 +1286,12 @@ bool Task::hasTag (const std::string& tag) const //////////////////////////////////////////////////////////////////////////////// void Task::addTag (const std::string& tag) { - std::vector tags; - split (tags, get ("tags"), ','); + auto tags = split (get ("tags"), ','); if (std::find (tags.begin (), tags.end (), tag) == tags.end ()) { tags.push_back (tag); - std::string combined; - join (combined, ",", tags); - set ("tags", combined); + set ("tags", join (",", tags)); recalc_urgency = true; } @@ -1315,22 +1311,19 @@ void Task::addTags (const std::vector & tags) //////////////////////////////////////////////////////////////////////////////// void Task::getTags (std::vector& tags) const { - split (tags, get ("tags"), ','); + tags = split (get ("tags"), ','); } //////////////////////////////////////////////////////////////////////////////// void Task::removeTag (const std::string& tag) { - std::vector tags; - split (tags, get ("tags"), ','); + auto tags = split (get ("tags"), ','); auto i = std::find (tags.begin (), tags.end (), tag); if (i != tags.end ()) { tags.erase (i); - std::string combined; - join (combined, ",", tags); - set ("tags", combined); + set ("tags", join (",", tags)); } recalc_urgency = true; diff --git a/src/Variant.cpp b/src/Variant.cpp index 1de474e85..a4a287515 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include std::string Variant::dateFormat = ""; diff --git a/src/ViewTask.cpp b/src/ViewTask.cpp index b0562995f..4c2f9bff1 100644 --- a/src/ViewTask.cpp +++ b/src/ViewTask.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/src/ViewText.cpp b/src/ViewText.cpp index 07502e9ea..c1d8455d8 100644 --- a/src/ViewText.cpp +++ b/src/ViewText.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/src/columns/ColDepends.cpp b/src/columns/ColDepends.cpp index 0d2d27142..ce425776b 100644 --- a/src/columns/ColDepends.cpp +++ b/src/columns/ColDepends.cpp @@ -28,7 +28,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -91,8 +92,7 @@ void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& ma for (auto& i : blocking) blocking_ids.push_back (i.id); - std::string all; - join (all, " ", blocking_ids); + auto all = join (" ", blocking_ids); maximum = all.length (); unsigned int length; @@ -134,8 +134,7 @@ void ColumnDepends::render ( for (const auto& t : blocking) blocking_ids.push_back (t.id); - std::string combined; - join (combined, " ", blocking_ids); + auto combined = join (" ", blocking_ids); std::vector all; wrapText (all, combined, width, _hyphenate); @@ -150,12 +149,8 @@ void ColumnDepends::render ( //////////////////////////////////////////////////////////////////////////////// void ColumnDepends::modify (Task& task, const std::string& value) { - // Parse IDs - std::vector deps; - split (deps, value, ','); - // Apply or remove dendencies in turn. - for (auto& dep : deps) + for (auto& dep : split (value, ',')) { if (dep[0] == '-') { diff --git a/src/columns/ColDescription.cpp b/src/columns/ColDescription.cpp index ac84b694c..f45358858 100644 --- a/src/columns/ColDescription.cpp +++ b/src/columns/ColDescription.cpp @@ -29,7 +29,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/columns/ColID.cpp b/src/columns/ColID.cpp index de2f41fa3..48e7c016c 100644 --- a/src/columns/ColID.cpp +++ b/src/columns/ColID.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColIMask.cpp b/src/columns/ColIMask.cpp index 97ef05143..5f053fa98 100644 --- a/src/columns/ColIMask.cpp +++ b/src/columns/ColIMask.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColMask.cpp b/src/columns/ColMask.cpp index a00d7b8a8..08a8e70e5 100644 --- a/src/columns/ColMask.cpp +++ b/src/columns/ColMask.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColParent.cpp b/src/columns/ColParent.cpp index 3d1622c0b..38518681f 100644 --- a/src/columns/ColParent.cpp +++ b/src/columns/ColParent.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColProject.cpp b/src/columns/ColProject.cpp index e13162469..069563db8 100644 --- a/src/columns/ColProject.cpp +++ b/src/columns/ColProject.cpp @@ -32,7 +32,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/columns/ColRecur.cpp b/src/columns/ColRecur.cpp index cd8cc8327..aa1c85397 100644 --- a/src/columns/ColRecur.cpp +++ b/src/columns/ColRecur.cpp @@ -33,7 +33,8 @@ #include #include #include -#include +#include +#include #include #include diff --git a/src/columns/ColStatus.cpp b/src/columns/ColStatus.cpp index ebc0b222e..ef403bd00 100644 --- a/src/columns/ColStatus.cpp +++ b/src/columns/ColStatus.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include diff --git a/src/columns/ColString.cpp b/src/columns/ColString.cpp index 581ce491a..5befb51e5 100644 --- a/src/columns/ColString.cpp +++ b/src/columns/ColString.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include diff --git a/src/columns/ColTags.cpp b/src/columns/ColTags.cpp index 6b28b4c4b..c32232030 100644 --- a/src/columns/ColTags.cpp +++ b/src/columns/ColTags.cpp @@ -32,7 +32,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -96,8 +97,7 @@ void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maxim // Find the widest tag. if (tags.find (',') != std::string::npos) { - std::vector all; - split (all, tags, ','); + auto all = split (tags, ','); for (const auto& tag : all) { auto length = utf8_width (tag); @@ -132,10 +132,9 @@ void ColumnTags::render ( { if (tags.find (',') != std::string::npos) { - std::vector all; - split (all, tags, ','); + auto all = split (tags, ','); std::sort (all.begin (), all.end ()); - join (tags, " ", all); + tags = join (" ", all); all.clear (); wrapText (all, tags, width, _hyphenate); @@ -152,8 +151,7 @@ void ColumnTags::render ( } else if (_style == "count") { - std::vector all; - split (all, tags, ','); + auto all = split (tags, ','); renderStringRight (lines, width, color, '[' + format (static_cast (all.size ())) + ']'); } } @@ -167,10 +165,7 @@ void ColumnTags::modify (Task& task, const std::string& value) // TW-1701 task.set ("tags", ""); - std::vector tags; - split (tags, value, ','); - - for (auto& tag : tags) + for (auto& tag : split (value, ',')) { // If it's a DOM ref, eval it first. Lexer lexer (tag); diff --git a/src/columns/ColTypeDate.cpp b/src/columns/ColTypeDate.cpp index 727402d32..c996f3f4f 100644 --- a/src/columns/ColTypeDate.cpp +++ b/src/columns/ColTypeDate.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include extern Context context; diff --git a/src/columns/ColTypeDuration.cpp b/src/columns/ColTypeDuration.cpp index 344fd130a..b3e433d81 100644 --- a/src/columns/ColTypeDuration.cpp +++ b/src/columns/ColTypeDuration.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include extern Context context; diff --git a/src/columns/ColTypeNumeric.cpp b/src/columns/ColTypeNumeric.cpp index 40925c042..b69147f1f 100644 --- a/src/columns/ColTypeNumeric.cpp +++ b/src/columns/ColTypeNumeric.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include extern Context context; diff --git a/src/columns/ColTypeString.cpp b/src/columns/ColTypeString.cpp index 3e18f087c..af91ae008 100644 --- a/src/columns/ColTypeString.cpp +++ b/src/columns/ColTypeString.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include extern Context context; diff --git a/src/columns/ColUDA.cpp b/src/columns/ColUDA.cpp index 9a4016219..d2f316a3c 100644 --- a/src/columns/ColUDA.cpp +++ b/src/columns/ColUDA.cpp @@ -28,7 +28,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/columns/ColUUID.cpp b/src/columns/ColUUID.cpp index 48baf9769..83f1a7dc9 100644 --- a/src/columns/ColUUID.cpp +++ b/src/columns/ColUUID.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColUrgency.cpp b/src/columns/ColUrgency.cpp index b2bf3911f..82a6586ca 100644 --- a/src/columns/ColUrgency.cpp +++ b/src/columns/ColUrgency.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index c3b1b8e4c..75e4e6bd5 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -51,7 +51,8 @@ #include #include #include -#include +#include +#include #include extern Context context; @@ -186,7 +187,7 @@ Column* Column::uda (const std::string& name) c->_name = name; c->_label = label; if (values != "") - split (c->_values, values, ','); + c->_values = split (values, ','); return c; } else if (type == "numeric") @@ -195,7 +196,7 @@ Column* Column::uda (const std::string& name) c->_name = name; c->_label = label; if (values != "") - split (c->_values, values, ','); + c->_values = split (values, ','); return c; } else if (type == "date") @@ -204,7 +205,7 @@ Column* Column::uda (const std::string& name) c->_name = name; c->_label = label; if (values != "") - split (c->_values, values, ','); + c->_values = split (values, ','); return c; } else if (type == "duration") @@ -213,7 +214,7 @@ Column* Column::uda (const std::string& name) c->_name = name; c->_label = label; if (values != "") - split (c->_values, values, ','); + c->_values = split (values, ','); return c; } else if (type != "") diff --git a/src/commands/CmdAdd.cpp b/src/commands/CmdAdd.cpp index efca8d798..e9dd03792 100644 --- a/src/commands/CmdAdd.cpp +++ b/src/commands/CmdAdd.cpp @@ -27,9 +27,9 @@ #include #include #include -#include +#include +#include #include -#include #include extern Context context; diff --git a/src/commands/CmdAnnotate.cpp b/src/commands/CmdAnnotate.cpp index 932ee027b..e980b75e6 100644 --- a/src/commands/CmdAnnotate.cpp +++ b/src/commands/CmdAnnotate.cpp @@ -30,8 +30,8 @@ #include #include #include -#include -#include +#include +#include #include extern Context context; diff --git a/src/commands/CmdAppend.cpp b/src/commands/CmdAppend.cpp index 5be95aee9..e3fe1a3ec 100644 --- a/src/commands/CmdAppend.cpp +++ b/src/commands/CmdAppend.cpp @@ -29,8 +29,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/src/commands/CmdCalendar.cpp b/src/commands/CmdCalendar.cpp index f71e6e8c2..6bc259051 100644 --- a/src/commands/CmdCalendar.cpp +++ b/src/commands/CmdCalendar.cpp @@ -33,8 +33,9 @@ #include #include #include +#include +#include #include -#include #include #include diff --git a/src/commands/CmdColor.cpp b/src/commands/CmdColor.cpp index 7262c614c..231bf3ab7 100644 --- a/src/commands/CmdColor.cpp +++ b/src/commands/CmdColor.cpp @@ -31,7 +31,8 @@ #include #include #include -#include +#include +#include #include extern Context context; diff --git a/src/commands/CmdColumns.cpp b/src/commands/CmdColumns.cpp index 3696bb802..8772a9e85 100644 --- a/src/commands/CmdColumns.cpp +++ b/src/commands/CmdColumns.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/src/commands/CmdConfig.cpp b/src/commands/CmdConfig.cpp index f3d808286..bf938e8a9 100644 --- a/src/commands/CmdConfig.cpp +++ b/src/commands/CmdConfig.cpp @@ -31,8 +31,8 @@ #include #include #include -#include -#include +#include +#include extern Context context; diff --git a/src/commands/CmdContext.cpp b/src/commands/CmdContext.cpp index 0767c5e3a..057b8d6f8 100644 --- a/src/commands/CmdContext.cpp +++ b/src/commands/CmdContext.cpp @@ -33,7 +33,8 @@ #include #include #include -#include +#include +#include #include extern Context context; diff --git a/src/commands/CmdCount.cpp b/src/commands/CmdCount.cpp index a9e5d2043..4f97506d8 100644 --- a/src/commands/CmdCount.cpp +++ b/src/commands/CmdCount.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include //////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/CmdCustom.cpp b/src/commands/CmdCustom.cpp index 1c78dd2ca..cc45fff3d 100644 --- a/src/commands/CmdCustom.cpp +++ b/src/commands/CmdCustom.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/src/commands/CmdDelete.cpp b/src/commands/CmdDelete.cpp index 1697483b8..0bfc1c8ae 100644 --- a/src/commands/CmdDelete.cpp +++ b/src/commands/CmdDelete.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/commands/CmdDenotate.cpp b/src/commands/CmdDenotate.cpp index 1f958f8fa..7bd040aa5 100644 --- a/src/commands/CmdDenotate.cpp +++ b/src/commands/CmdDenotate.cpp @@ -29,7 +29,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/commands/CmdDiagnostics.cpp b/src/commands/CmdDiagnostics.cpp index 9e0a50fd3..15362bf99 100644 --- a/src/commands/CmdDiagnostics.cpp +++ b/src/commands/CmdDiagnostics.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #ifdef HAVE_COMMIT #include diff --git a/src/commands/CmdDone.cpp b/src/commands/CmdDone.cpp index 253ffb4b4..5ddcfa2f1 100644 --- a/src/commands/CmdDone.cpp +++ b/src/commands/CmdDone.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/commands/CmdDuplicate.cpp b/src/commands/CmdDuplicate.cpp index 350dacabc..ab2189313 100644 --- a/src/commands/CmdDuplicate.cpp +++ b/src/commands/CmdDuplicate.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index 44c6f6042..a43e99bde 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -39,7 +39,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -230,8 +231,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat) std::vector tags; task.getTags (tags); - std::string allTags; - join (allTags, " ", tags); + auto allTags = join (" ", tags); if (verbose) before << "# " << STRING_EDIT_TAG_SEP << '\n'; @@ -360,8 +360,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string // tags value = findValue (after, "\n Tags:"); - std::vector tags; - split (tags, value, ' '); + auto tags = split (value, ' '); task.remove ("tags"); task.addTags (tags); @@ -676,8 +675,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string // Dependencies value = findValue (after, "\n Dependencies:"); - std::vector dependencies; - split (dependencies, value, ","); + auto dependencies = split (value, ','); task.remove ("depends"); for (auto& dep : dependencies) diff --git a/src/commands/CmdGet.cpp b/src/commands/CmdGet.cpp index 363574a66..06a911d41 100644 --- a/src/commands/CmdGet.cpp +++ b/src/commands/CmdGet.cpp @@ -30,7 +30,8 @@ #include #include #include -#include +#include +#include #include extern Context context; @@ -90,7 +91,7 @@ int CmdGet::execute (std::string& output) if (results.size () == 0) throw std::string (STRING_CMD_GET_NO_DOM); - join (output, " ", results); + output = join (" ", results); output += '\n'; return 0; } diff --git a/src/commands/CmdHelp.cpp b/src/commands/CmdHelp.cpp index de0d9af85..e04641b78 100644 --- a/src/commands/CmdHelp.cpp +++ b/src/commands/CmdHelp.cpp @@ -30,7 +30,8 @@ #include #include #include -#include +#include +#include #include extern Context context; diff --git a/src/commands/CmdHistory.cpp b/src/commands/CmdHistory.cpp index 5b5569deb..2d7e5b4c7 100644 --- a/src/commands/CmdHistory.cpp +++ b/src/commands/CmdHistory.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/src/commands/CmdIDs.cpp b/src/commands/CmdIDs.cpp index b8894d204..1b4330aeb 100644 --- a/src/commands/CmdIDs.cpp +++ b/src/commands/CmdIDs.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include extern Context context; @@ -163,8 +163,7 @@ int CmdCompletionIds::execute (std::string& output) ids.push_back (task.id); std::sort (ids.begin (), ids.end ()); - join (output, "\n", ids); - output += '\n'; + output = join ("\n", ids) + '\n'; context.headers.clear (); return 0; @@ -240,8 +239,7 @@ int CmdUUIDs::execute (std::string& output) uuids.push_back (task.get ("uuid")); std::sort (uuids.begin (), uuids.end ()); - join (output, " ", uuids); - output += '\n'; + output = join (" ", uuids) + '\n'; context.headers.clear (); return 0; @@ -277,8 +275,7 @@ int CmdCompletionUuids::execute (std::string& output) uuids.push_back (task.get ("uuid")); std::sort (uuids.begin (), uuids.end ()); - join (output, "\n", uuids); - output += '\n'; + output = join ("\n", uuids) + '\n'; context.headers.clear (); return 0; diff --git a/src/commands/CmdImport.cpp b/src/commands/CmdImport.cpp index ae893ac51..4ede977c0 100644 --- a/src/commands/CmdImport.cpp +++ b/src/commands/CmdImport.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 0d8ded1e7..0f6273fb1 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include diff --git a/src/commands/CmdLog.cpp b/src/commands/CmdLog.cpp index 886507578..fbbc33b67 100644 --- a/src/commands/CmdLog.cpp +++ b/src/commands/CmdLog.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/commands/CmdModify.cpp b/src/commands/CmdModify.cpp index db203e180..352939479 100644 --- a/src/commands/CmdModify.cpp +++ b/src/commands/CmdModify.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/commands/CmdPrepend.cpp b/src/commands/CmdPrepend.cpp index c0ead57f1..87162c33b 100644 --- a/src/commands/CmdPrepend.cpp +++ b/src/commands/CmdPrepend.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/commands/CmdProjects.cpp b/src/commands/CmdProjects.cpp index b1ecb8a25..8d7defea4 100644 --- a/src/commands/CmdProjects.cpp +++ b/src/commands/CmdProjects.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/src/commands/CmdPurge.cpp b/src/commands/CmdPurge.cpp index ab6d3b4b7..146754617 100644 --- a/src/commands/CmdPurge.cpp +++ b/src/commands/CmdPurge.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include extern Context context; diff --git a/src/commands/CmdReports.cpp b/src/commands/CmdReports.cpp index 4474f96bd..0fa52cb0c 100644 --- a/src/commands/CmdReports.cpp +++ b/src/commands/CmdReports.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include diff --git a/src/commands/CmdShow.cpp b/src/commands/CmdShow.cpp index 56d848ac5..296c0be66 100644 --- a/src/commands/CmdShow.cpp +++ b/src/commands/CmdShow.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/commands/CmdStart.cpp b/src/commands/CmdStart.cpp index 34f2df484..8da0c3897 100644 --- a/src/commands/CmdStart.cpp +++ b/src/commands/CmdStart.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/commands/CmdStats.cpp b/src/commands/CmdStats.cpp index 67d0a8c26..0ef70197c 100644 --- a/src/commands/CmdStats.cpp +++ b/src/commands/CmdStats.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/src/commands/CmdStop.cpp b/src/commands/CmdStop.cpp index 40dc5e33a..86d23366e 100644 --- a/src/commands/CmdStop.cpp +++ b/src/commands/CmdStop.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include extern Context context; diff --git a/src/commands/CmdSummary.cpp b/src/commands/CmdSummary.cpp index 99783e2c5..1e45e6189 100644 --- a/src/commands/CmdSummary.cpp +++ b/src/commands/CmdSummary.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/src/commands/CmdSync.cpp b/src/commands/CmdSync.cpp index 52d425761..28da9c5a8 100644 --- a/src/commands/CmdSync.cpp +++ b/src/commands/CmdSync.cpp @@ -32,7 +32,8 @@ #include #include #include -#include +#include +#include #include #include @@ -91,8 +92,7 @@ int CmdSync::execute (std::string& output) if (credentials_string == "") throw std::string (STRING_CMD_SYNC_BAD_CRED); - std::vector credentials; - split (credentials, credentials_string, "/"); + auto credentials = split (credentials_string, '/'); if (credentials.size () != 3) throw std::string (STRING_CMD_SYNC_BAD_CRED); @@ -198,8 +198,7 @@ int CmdSync::execute (std::string& output) int download_count = 0; payload = response.getPayload (); - std::vector lines; - split (lines, payload, '\n'); + auto lines = split (payload, '\n'); // Load all tasks, but only if necessary. There is always a sync key in // the payload, so if there are two or more lines, then we have merging diff --git a/src/commands/CmdTags.cpp b/src/commands/CmdTags.cpp index 95eedbb9a..5f75b85b3 100644 --- a/src/commands/CmdTags.cpp +++ b/src/commands/CmdTags.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/src/commands/CmdTimesheet.cpp b/src/commands/CmdTimesheet.cpp index 15d25ba55..65c1f6055 100644 --- a/src/commands/CmdTimesheet.cpp +++ b/src/commands/CmdTimesheet.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include extern Context context; diff --git a/src/commands/CmdUDAs.cpp b/src/commands/CmdUDAs.cpp index d2c20d8eb..00091d904 100644 --- a/src/commands/CmdUDAs.cpp +++ b/src/commands/CmdUDAs.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/src/commands/CmdUnique.cpp b/src/commands/CmdUnique.cpp index 8b28f9020..dbb3cadc2 100644 --- a/src/commands/CmdUnique.cpp +++ b/src/commands/CmdUnique.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include extern Context context; diff --git a/src/commands/CmdUrgency.cpp b/src/commands/CmdUrgency.cpp index 4d45a65bf..caa3587a6 100644 --- a/src/commands/CmdUrgency.cpp +++ b/src/commands/CmdUrgency.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include extern Context context; diff --git a/src/commands/CmdVersion.cpp b/src/commands/CmdVersion.cpp index ce1432fb2..b8ec3c52d 100644 --- a/src/commands/CmdVersion.cpp +++ b/src/commands/CmdVersion.cpp @@ -33,7 +33,7 @@ #ifdef HAVE_COMMIT #include #endif -#include +#include #include extern Context context; diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 86a276f83..b726e6eb8 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -28,7 +28,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/dependency.cpp b/src/dependency.cpp index 2f7a38db2..b8e912579 100644 --- a/src/dependency.cpp +++ b/src/dependency.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/feedback.cpp b/src/feedback.cpp index c5c88b86a..3a96f473d 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -36,8 +36,8 @@ #include #include #include -#include -#include +#include +#include #include extern Context context; @@ -52,10 +52,7 @@ std::string taskIdentifiers (const std::vector & tasks) for (auto task: tasks) identifiers.push_back (task.identifier (true)); - std::string result; - join (result, ", ", identifiers); - - return result; + return join (", ", identifiers); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/legacy.cpp b/src/legacy.cpp index be4039cf0..48beb99dd 100644 --- a/src/legacy.cpp +++ b/src/legacy.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include extern Context context; diff --git a/src/main.h b/src/main.h index ad1c60e88..1fd8dd628 100644 --- a/src/main.h +++ b/src/main.h @@ -83,21 +83,5 @@ std::string legacyCheckForDeprecatedVariables (); std::string legacyCheckForDeprecatedColumns (); void legacyAttributeMap (std::string&); -// list template -/////////////////////////////////////////////////////////////////////////////// -template void listDiff ( - const T& left, const T& right, T& leftOnly, T& rightOnly) -{ - leftOnly.clear (); - for (auto& l : left) - if (std::find (right.begin (), right.end (), l) == right.end ()) - leftOnly.push_back (l); - - rightOnly.clear (); - for (auto& r : right) - if (std::find (left.begin (), left.end (), r) == left.end ()) - rightOnly.push_back (r); -} - #endif //////////////////////////////////////////////////////////////////////////////// diff --git a/src/recur.cpp b/src/recur.cpp index 6ee2179fc..9a09f9a12 100644 --- a/src/recur.cpp +++ b/src/recur.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/rules.cpp b/src/rules.cpp index 16b19eb18..0bb86a161 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include extern Context context; diff --git a/src/sort.cpp b/src/sort.cpp index 58c3e5cc9..055fc6f66 100644 --- a/src/sort.cpp +++ b/src/sort.cpp @@ -32,7 +32,8 @@ #include #include #include -#include +#include +#include #include extern Context context; @@ -52,8 +53,7 @@ void sort_tasks ( global_data = &data; // Split the key defs. - global_keys.clear (); - split (global_keys, keys, ','); + global_keys = split (keys, ','); // Only sort if necessary. if (order.size ()) diff --git a/src/text.cpp b/src/text.cpp index 707889ad9..c4b53fa22 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -170,33 +170,6 @@ std::string unquoteText (const std::string& input) return output; } -//////////////////////////////////////////////////////////////////////////////// -int longestWord (const std::string& input) -{ - int longest = 0; - int length = 0; - std::string::size_type i = 0; - int character; - - while ((character = utf8_next_char (input, i))) - { - if (character == ' ') - { - if (length > longest) - longest = length; - - length = 0; - } - else - length += mk_wcwidth (character); - } - - if (length > longest) - longest = length; - - return longest; -} - //////////////////////////////////////////////////////////////////////////////// int longestLine (const std::string& input) { @@ -312,32 +285,6 @@ bool extractLine ( return false; } -//////////////////////////////////////////////////////////////////////////////// -const std::string str_replace ( - std::string &str, - const std::string& search, - const std::string& replacement) -{ - std::string::size_type pos = 0; - while ((pos = str.find (search, pos)) != std::string::npos) - { - str.replace (pos, search.length (), replacement); - pos += replacement.length (); - } - - return str; -} - -//////////////////////////////////////////////////////////////////////////////// -const std::string str_replace ( - const std::string& str, - const std::string& search, - const std::string& replacement) -{ - std::string modified = str; - return str_replace (modified, search, replacement); -} - //////////////////////////////////////////////////////////////////////////////// const char* optionalBlankLine () { @@ -356,127 +303,6 @@ bool nontrivial (const std::string& input) return false; } -//////////////////////////////////////////////////////////////////////////////// -bool compare ( - const std::string& left, - const std::string& right, - bool sensitive /*= true*/) -{ - // Use strcasecmp if required. - if (!sensitive) - return strcasecmp (left.c_str (), right.c_str ()) == 0 ? true : false; - - // Otherwise, just use std::string::operator==. - return left == right; -} - -//////////////////////////////////////////////////////////////////////////////// -bool closeEnough ( - const std::string& reference, - const std::string& attempt, - unsigned int minLength /* = 0 */) -{ - // An exact match is accepted first. - if (compare (reference, attempt, false)) - return true; - - // A partial match will suffice. - if (attempt.length () < reference.length () && - attempt.length () >= minLength) - return compare (reference.substr (0, attempt.length ()), attempt, false); - - return false; -} - -//////////////////////////////////////////////////////////////////////////////// -std::string::size_type find ( - const std::string& text, - const std::string& pattern, - bool sensitive /*= true*/) -{ - // Implement a sensitive find, which is really just a loop withing a loop, - // comparing lower-case versions of each character in turn. - if (!sensitive) - { - // Handle empty pattern. - const char* p = pattern.c_str (); - size_t len = pattern.length (); - if (len == 0) - return 0; - - // Evaluate these once, for performance reasons. - const char* t = text.c_str (); - const char* start = t; - const char* end = start + text.size (); - - for (; t <= end - len; ++t) - { - int diff = 0; - for (size_t i = 0; i < len; ++i) - if ((diff = tolower (t[i]) - tolower (p[i]))) - break; - - // diff == 0 means there was no break from the loop, which only occurs - // when a difference is detected. Therefore, the loop terminated, and - // diff is zero. - if (diff == 0) - return t - start; - } - - return std::string::npos; - } - - // Otherwise, just use std::string::find. - return text.find (pattern); -} - -//////////////////////////////////////////////////////////////////////////////// -std::string::size_type find ( - const std::string& text, - const std::string& pattern, - std::string::size_type begin, - bool sensitive /*= true*/) -{ - // Implement a sensitive find, which is really just a loop withing a loop, - // comparing lower-case versions of each character in turn. - if (!sensitive) - { - // Handle empty pattern. - const char* p = pattern.c_str (); - size_t len = pattern.length (); - if (len == 0) - return 0; - - // Handle bad begin. - if (begin >= text.length ()) - return std::string::npos; - - // Evaluate these once, for performance reasons. - const char* start = text.c_str (); - const char* t = start + begin; - const char* end = start + text.size (); - - for (; t <= end - len; ++t) - { - int diff = 0; - for (size_t i = 0; i < len; ++i) - if ((diff = tolower (t[i]) - tolower (p[i]))) - break; - - // diff == 0 means there was no break from the loop, which only occurs - // when a difference is detected. Therefore, the loop terminated, and - // diff is zero. - if (diff == 0) - return t - start; - } - - return std::string::npos; - } - - // Otherwise, just use std::string::find. - return text.find (pattern, begin); -} - //////////////////////////////////////////////////////////////////////////////// // Return the length, in characters, of the input, subtracting color control // codes. @@ -536,74 +362,6 @@ const std::string obfuscateText (const std::string& input) return output.str (); } -//////////////////////////////////////////////////////////////////////////////// -const std::string format (std::string& value) -{ - return value; -} - -//////////////////////////////////////////////////////////////////////////////// -const std::string format (const char* value) -{ - std::string s (value); - return s; -} - -//////////////////////////////////////////////////////////////////////////////// -const std::string formatHex (int value) -{ - std::stringstream s; - s.setf (std::ios::hex, std::ios::basefield); - s << value; - return s.str (); -} - -//////////////////////////////////////////////////////////////////////////////// -const std::string format (float value, int width, int precision) -{ - std::stringstream s; - s.width (width); - s.precision (precision); - if (0 < value && value < 1) - { - // For value close to zero, width - 2 (2 accounts for the first zero and - // the dot) is the number of digits after zero that are significant - double factor = 1; - for (int i = 2; i < width; i++) - factor *= 10; - value = roundf (value * factor) / factor; - } - s << value; - return s.str (); -} - -//////////////////////////////////////////////////////////////////////////////// -const std::string format (double value, int width, int precision) -{ - std::stringstream s; - s.width (width); - s.precision (precision); - if (0 < value && value < 1) - { - // For value close to zero, width - 2 (2 accounts for the first zero and - // the dot) is the number of digits after zero that are significant - double factor = 1; - for (int i = 2; i < width; i++) - factor *= 10; - value = round (value * factor) / factor; - } - s << value; - return s.str (); -} - -//////////////////////////////////////////////////////////////////////////////// -const std::string format (double value) -{ - std::stringstream s; - s << std::fixed << value; - return s.str (); -} - //////////////////////////////////////////////////////////////////////////////// void replace_positional ( std::string& fmt, diff --git a/src/text.h b/src/text.h index e2e858faa..26d6b23d6 100644 --- a/src/text.h +++ b/src/text.h @@ -35,7 +35,6 @@ // text.cpp, Non-UTF-8 aware. void wrapText (std::vector &, const std::string&, const int, bool); std::string unquoteText (const std::string&); -int longestWord (const std::string&); int longestLine (const std::string&); bool extractLine (std::string&, const std::string&, int, bool, unsigned int&); void split (std::set&, const std::string&, const char); @@ -43,53 +42,12 @@ void split (std::vector&, const std::string&, const char); void split (std::vector&, const std::string&, const std::string&); void join (std::string&, const std::string&, const std::vector&); void join (std::string&, const std::string&, const std::vector&); -const std::string str_replace (std::string&, const std::string&, const std::string&); -const std::string str_replace (const std::string&, const std::string&, const std::string&); const char* optionalBlankLine (); bool nontrivial (const std::string&); -bool compare (const std::string&, const std::string&, bool sensitive = true); -bool closeEnough (const std::string&, const std::string&, unsigned int minLength = 0); -std::string::size_type find (const std::string&, const std::string&, bool sensitive = true); -std::string::size_type find (const std::string&, const std::string&, std::string::size_type, bool sensitive = true); int strippedLength (const std::string&); const std::string obfuscateText (const std::string&); -const std::string format (std::string&); -const std::string format (const char*); -const std::string formatHex (int); -const std::string format (float, int, int); -const std::string format (double, int, int); -const std::string format (double); void replace_positional (std::string&, const std::string&, const std::string&); -template -const std::string format (T value) -{ - std::stringstream s; - s << value; - return s.str (); -} - -template -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)); - return output; -} - -template -const std::string format (int fmt_num, const std::string& fmt, T arg, Args... args) -{ - const std::string fmt_replaced (format (fmt_num, fmt, arg)); - return format (fmt_num+1, fmt_replaced, args...); -} - -template -const std::string format (const std::string& fmt, Args... args) -{ - return format (1, fmt, args...); -} - std::string leftJustify (const int, const int); std::string leftJustify (const std::string&, const int); std::string rightJustifyZero (const int, const int); diff --git a/src/util.cpp b/src/util.cpp index f4eeb1565..fd37193d3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -25,7 +25,7 @@ //////////////////////////////////////////////////////////////////////////////// #include -#include +#include // If is included, put it after , because it includes // , and therefore would ignore the _WITH_GETLINE. #ifdef FREEBSD @@ -163,41 +163,6 @@ std::string formatBytes (size_t bytes) return Lexer::commify (formatted); } -//////////////////////////////////////////////////////////////////////////////// -int autoComplete ( - const std::string& partial, - const std::vector& list, - std::vector& matches, - int minimum/* = 1*/) -{ - matches.clear (); - - // Handle trivial case. - unsigned int length = partial.length (); - if (length) - { - for (auto& item : list) - { - // An exact match is a special case. Assume there is only one exact match - // and return immediately. - if (partial == item) - { - matches.clear (); - matches.push_back (item); - return 1; - } - - // Maintain a list of partial matches. - else if (length >= (unsigned) minimum && - length <= item.length () && - partial == item.substr (0, length)) - matches.push_back (item); - } - } - - return matches.size (); -} - // Handle the generation of UUIDs on FreeBSD in a separate implementation // of the uuid () function, since the API is quite different from Linux's. // Also, uuid_unparse_lower is not needed on FreeBSD, because the string diff --git a/src/util.h b/src/util.h index 078fadbe6..a53e6e49b 100644 --- a/src/util.h +++ b/src/util.h @@ -43,7 +43,6 @@ bool confirm (const std::string&); int confirm4 (const std::string&); std::string formatBytes (size_t); -int autoComplete (const std::string&, const std::vector&, std::vector&, int minimum = 1); #ifndef HAVE_UUID_UNPARSE_LOWER void uuid_unparse_lower (uuid_t uu, char *out);