mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Bug 795
- Improved detection of uuid library, and the uuid_unparse_lower function. Signed-off-by: Paul Beckingham <paul@beckingham.net>
This commit is contained in:
parent
9ceae7c5c2
commit
f5e155e54d
4 changed files with 52 additions and 30 deletions
21
src/util.cpp
21
src/util.cpp
|
@ -223,29 +223,28 @@ int autoComplete (
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef HAVE_UUID
|
||||
|
||||
#include <uuid/uuid.h>
|
||||
#ifndef HAVE_UUID_UNPARSE_LOWER
|
||||
// Older versions of libuuid don't have uuid_unparse_lower(), only uuid_unparse()
|
||||
void uuid_unparse_lower (uuid_t uu, char *out)
|
||||
{
|
||||
uuid_unparse (uu, out);
|
||||
// Characters in out are either 0-9, a-z, '-', or A-Z. A-Z is mapped to
|
||||
// a-z by bitwise or with 0x20, and the others already have this bit set
|
||||
for (size_t i = 0; i < 36; ++i) out[i] |= 0x20;
|
||||
}
|
||||
#endif
|
||||
|
||||
const std::string uuid ()
|
||||
{
|
||||
uuid_t id;
|
||||
uuid_generate (id);
|
||||
char buffer[100] = {0};
|
||||
#ifdef SOLARIS
|
||||
uuid_unparse (id, buffer);
|
||||
#else
|
||||
uuid_unparse_lower (id, buffer);
|
||||
#endif
|
||||
|
||||
// Bug found by Steven de Brouwer.
|
||||
buffer[36] = '\0';
|
||||
|
||||
#ifdef SOLARIS
|
||||
std::string data = std::string (buffer);
|
||||
std::transform (data.begin(), data.end(), data.begin(), ::tolower);
|
||||
return data;
|
||||
#else
|
||||
return std::string (buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
#include <Task.h>
|
||||
#include <cmake.h>
|
||||
|
||||
#ifdef HAVE_UUID
|
||||
#include <uuid/uuid.h>
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
@ -59,7 +63,12 @@ int confirm4 (const std::string&);
|
|||
void delay (float);
|
||||
std::string formatBytes (size_t);
|
||||
int autoComplete (const std::string&, const std::vector<std::string>&, std::vector<std::string>&);
|
||||
|
||||
#if defined(HAVE_UUID) && !defined(HAVE_UUID_UNPARSE_LOWER)
|
||||
void uuid_unparse_lower (uuid_t uu, char *out);
|
||||
#endif
|
||||
const std::string uuid ();
|
||||
|
||||
int execute (const std::string&, std::vector<std::string>);
|
||||
|
||||
#ifdef SOLARIS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue