mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
libhsared: migrating from local to libshared
This commit is contained in:
parent
0e56abd0f9
commit
8a43f4902d
88 changed files with 185 additions and 510 deletions
37
src/util.cpp
37
src/util.cpp
|
@ -25,7 +25,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <util.h>
|
||||
#include <shared.h>
|
||||
// If <iostream> is included, put it after <stdio.h>, because it includes
|
||||
// <stdio.h>, 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<std::string>& list,
|
||||
std::vector<std::string>& 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue