mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-26 15:47:19 +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
|
@ -11,6 +11,18 @@ SET (TASK_MAN5DIR share/man/man5 CACHE STRING "Installation directory for man pa
|
||||||
SET (TASK_DOCDIR share/doc/task CACHE STRING "Installation directory for doc files")
|
SET (TASK_DOCDIR share/doc/task CACHE STRING "Installation directory for doc files")
|
||||||
SET (TASK_BINDIR bin CACHE STRING "Installation directory for the binary")
|
SET (TASK_BINDIR bin CACHE STRING "Installation directory for the binary")
|
||||||
|
|
||||||
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
|
set (LINUX true)
|
||||||
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
set (DARWIN true)
|
||||||
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||||
|
set (FREEBSD true)
|
||||||
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
|
||||||
|
set (SOLARIS true)
|
||||||
|
else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
|
set (UNKNOWN true)
|
||||||
|
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
|
|
||||||
message ("-- Looking for SHA1 references")
|
message ("-- Looking for SHA1 references")
|
||||||
if (EXISTS .git/index)
|
if (EXISTS .git/index)
|
||||||
set (HAVE_COMMIT true)
|
set (HAVE_COMMIT true)
|
||||||
|
@ -51,31 +63,32 @@ endif (LUA51_FOUND)
|
||||||
check_function_exists (random HAVE_RANDOM)
|
check_function_exists (random HAVE_RANDOM)
|
||||||
check_function_exists (srandom HAVE_SRANDOM)
|
check_function_exists (srandom HAVE_SRANDOM)
|
||||||
|
|
||||||
# Some systems include uuid automatically (OS X), others need the includes/library
|
message ("-- Looking for libuuid")
|
||||||
check_function_exists (uuid_unparse_lower HAVE_UUID)
|
if (DARWIN)
|
||||||
if (NOT HAVE_UUID)
|
# Apple includes the uuid functions in their libc, rather than libuuid
|
||||||
message ("-- Looking for libuuid")
|
set (HAVE_UUID true)
|
||||||
|
check_function_exists (uuid_unparse_lower HAVE_UUID_UNPARSE_LOWER)
|
||||||
|
else (DARWIN)
|
||||||
find_path (UUID_INCLUDE_DIR uuid/uuid.h)
|
find_path (UUID_INCLUDE_DIR uuid/uuid.h)
|
||||||
find_library (UUID_LIBRARY NAMES uuid)
|
find_library (UUID_LIBRARY NAMES uuid)
|
||||||
if (UUID_INCLUDE_DIR AND UUID_LIBRARY)
|
if (UUID_INCLUDE_DIR AND UUID_LIBRARY)
|
||||||
message ("-- Found libuuid: ${UUID_LIBRARY}")
|
|
||||||
set (HAVE_UUID true)
|
set (HAVE_UUID true)
|
||||||
set (TASK_INCLUDE_DIRS ${TASK_INCLUDE_DIRS} ${UUID_INCLUDE_DIR})
|
set (TASK_INCLUDE_DIRS ${TASK_INCLUDE_DIRS} ${UUID_INCLUDE_DIR})
|
||||||
set (TASK_LIBRARIES ${TASK_LIBRARIES} ${UUID_LIBRARY})
|
set (TASK_LIBRARIES ${TASK_LIBRARIES} ${UUID_LIBRARY})
|
||||||
|
# Look for uuid_unparse_lower
|
||||||
|
set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${UUID_INCLUDE_DIR})
|
||||||
|
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${UUID_LIBRARY})
|
||||||
|
check_function_exists (uuid_unparse_lower HAVE_UUID_UNPARSE_LOWER)
|
||||||
endif (UUID_INCLUDE_DIR AND UUID_LIBRARY)
|
endif (UUID_INCLUDE_DIR AND UUID_LIBRARY)
|
||||||
endif (NOT HAVE_UUID)
|
endif (DARWIN)
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
if (HAVE_UUID AND HAVE_UUID_UNPARSE_LOWER)
|
||||||
set (LINUX true)
|
message ("-- Found libuuid")
|
||||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
elseif (HAVE_UUID AND NOT HAVE_UUID_UNPARSE_LOWER)
|
||||||
set (DARWIN true)
|
message ("-- Found libuuid, using internal uuid_unparse_lower")
|
||||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
else (HAVE_UUID AND HAVE_UUID_UNPARSE_LOWER)
|
||||||
set (FREEBSD true)
|
message ("-- libuuid not found, using internal uuid")
|
||||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
|
endif (HAVE_UUID AND HAVE_UUID_UNPARSE_LOWER)
|
||||||
set (SOLARIS true)
|
|
||||||
else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
set (UNKNOWN true)
|
|
||||||
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
|
|
||||||
message ("-- Configuring cmake.h")
|
message ("-- Configuring cmake.h")
|
||||||
configure_file (
|
configure_file (
|
||||||
|
|
|
@ -53,6 +53,7 @@ Override PACKAGE_LANGUAGE, then
|
||||||
/* Found srandom */
|
/* Found srandom */
|
||||||
#cmakedefine HAVE_SRANDOM
|
#cmakedefine HAVE_SRANDOM
|
||||||
|
|
||||||
/* Found uuid_unparse_lower */
|
/* Found the uuid library */
|
||||||
#cmakedefine HAVE_UUID
|
#cmakedefine HAVE_UUID
|
||||||
|
#cmakedefine HAVE_UUID_UNPARSE_LOWER
|
||||||
|
|
||||||
|
|
21
src/util.cpp
21
src/util.cpp
|
@ -223,29 +223,28 @@ int autoComplete (
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#ifdef HAVE_UUID
|
#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 ()
|
const std::string uuid ()
|
||||||
{
|
{
|
||||||
uuid_t id;
|
uuid_t id;
|
||||||
uuid_generate (id);
|
uuid_generate (id);
|
||||||
char buffer[100] = {0};
|
char buffer[100] = {0};
|
||||||
#ifdef SOLARIS
|
|
||||||
uuid_unparse (id, buffer);
|
|
||||||
#else
|
|
||||||
uuid_unparse_lower (id, buffer);
|
uuid_unparse_lower (id, buffer);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Bug found by Steven de Brouwer.
|
// Bug found by Steven de Brouwer.
|
||||||
buffer[36] = '\0';
|
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);
|
return std::string (buffer);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -35,6 +35,10 @@
|
||||||
#include <Task.h>
|
#include <Task.h>
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_UUID
|
||||||
|
#include <uuid/uuid.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef min
|
#ifndef min
|
||||||
#define min(a,b) ((a) < (b) ? (a) : (b))
|
#define min(a,b) ((a) < (b) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,7 +63,12 @@ int confirm4 (const std::string&);
|
||||||
void delay (float);
|
void delay (float);
|
||||||
std::string formatBytes (size_t);
|
std::string formatBytes (size_t);
|
||||||
int autoComplete (const std::string&, const std::vector<std::string>&, std::vector<std::string>&);
|
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 ();
|
const std::string uuid ();
|
||||||
|
|
||||||
int execute (const std::string&, std::vector<std::string>);
|
int execute (const std::string&, std::vector<std::string>);
|
||||||
|
|
||||||
#ifdef SOLARIS
|
#ifdef SOLARIS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue