From 0ea28ef8a347c8d59410f761f94c74a910e64ff4 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 9 Apr 2013 20:50:05 -0400 Subject: [PATCH] Bug #1196 - #1196 Now builds on Hurd (thanks to Jakub Wilk). --- CMakeLists.txt | 2 ++ ChangeLog | 1 + cmake.h.in | 3 +++ src/Directory.cpp | 11 +++++++++++ 4 files changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa8062bdc..dad6e188c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,8 @@ endif (READLINE_FOUND) check_function_exists (random HAVE_RANDOM) check_function_exists (srandom HAVE_SRANDOM) check_function_exists (timegm HAVE_TIMEGM) +check_function_exists (get_current_dir_name HAVE_GET_CURRENT_DIR_NAME) + check_struct_has_member ("struct tm" tm_gmtoff time.h HAVE_TM_GMTOFF) check_struct_has_member ("struct stat" st_birthtime "sys/types.h;sys/stat.h" HAVE_ST_BIRTHTIME) diff --git a/ChangeLog b/ChangeLog index 115cef655..3e59654f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ Features + Began fr-FR localization. Bugs + + #1196 Now builds on Hurd (thanks to Jakub Wilk). + #1197 Now 'tasksh' recognizes Ctrl-D to exit. + #1211 The 'dateformat' settings now default to the ISO-8601 standard of 'Y-M-D' (thanks to Robin Björklin). diff --git a/cmake.h.in b/cmake.h.in index d305f1007..41c38c92b 100644 --- a/cmake.h.in +++ b/cmake.h.in @@ -58,6 +58,9 @@ /* Found timegm */ #cmakedefine HAVE_TIMEGM +/* Found get_current_dir_name */ +#cmakedefine HAVE_GET_CURRENT_DIR_NAME + /* Found the uuid library */ #cmakedefine HAVE_UUID #cmakedefine HAVE_UUID_UNPARSE_LOWER diff --git a/src/Directory.cpp b/src/Directory.cpp index f77198907..b4ee4b914 100644 --- a/src/Directory.cpp +++ b/src/Directory.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -148,9 +150,18 @@ std::vector Directory::listRecursive () //////////////////////////////////////////////////////////////////////////////// std::string Directory::cwd () { +#ifdef HAVE_GET_CURRENT_DIR_NAME + char *buf = get_current_dir_name (); + if (buf == NULL) + throw std::bad_alloc (); + std::string result (buf); + free (buf); + return result; +#else char buf[PATH_MAX]; getcwd (buf, PATH_MAX - 1); return std::string (buf); +#endif } ////////////////////////////////////////////////////////////////////////////////