From e632a63b594206ed96f34f75b813411857af6a49 Mon Sep 17 00:00:00 2001 From: Masamichi Hosoda Date: Fri, 10 Mar 2017 21:45:36 +0900 Subject: [PATCH] Issue 5077/1: Fix build failure on GNU Hurd LilyPond failed to build on GNU Hurd because Hurd does not have PATH_MAX. This commit is based on the following patch by Debian. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=761036 However, the patch raises an error on `make check`. This commit has been fixed so that the error does not raise. --- flower/file-name.cc | 7 +++++++ flower/test-file-path.cc | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/flower/file-name.cc b/flower/file-name.cc index c65d8fc7ed..e5dd6f6160 100644 --- a/flower/file-name.cc +++ b/flower/file-name.cc @@ -77,9 +77,16 @@ dir_name (const string &file_name) string get_working_directory () { +#ifdef _GNU_SOURCE + char *cwd = get_current_dir_name(); + string scwd(cwd); + free(cwd); + return scwd; +#else char cwd[PATH_MAX]; // getcwd returns NULL upon a failure, contents of cwd would be undefined! return string (getcwd (cwd, PATH_MAX)); +#endif } /* Join components to full file_name. */ diff --git a/flower/test-file-path.cc b/flower/test-file-path.cc index a20364b98c..8a891afeea 100644 --- a/flower/test-file-path.cc +++ b/flower/test-file-path.cc @@ -1,4 +1,5 @@ #include "file-path.hh" +#include "file-name.hh" #include #include @@ -10,8 +11,7 @@ TEST (File_path, Find) { char const *extensions[] = {"ly", "", 0}; string file = "init"; - char cwd[PATH_MAX]; - if (!getcwd (cwd, PATH_MAX)) + if (get_working_directory().empty()) { cerr << "Could not get current work directory\n"; exit (1); -- 2.39.2