]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 5077/1: Fix build failure on GNU Hurd
authorMasamichi Hosoda <trueroad@trueroad.jp>
Fri, 10 Mar 2017 12:45:36 +0000 (21:45 +0900)
committerMasamichi Hosoda <trueroad@trueroad.jp>
Sun, 19 Mar 2017 14:45:34 +0000 (23:45 +0900)
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
flower/test-file-path.cc

index c65d8fc7ed8c9ecfdfaba536d450b3ec70c010de..e5dd6f61602369773f53406d56bc4bd1ef12c4fa 100644 (file)
@@ -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. */
index a20364b98cf6214e0f727ec9a9672fef85f217d0..8a891afeea8c79d1d6da211fccc148803fcf8424 100644 (file)
@@ -1,4 +1,5 @@
 #include "file-path.hh"
+#include "file-name.hh"
 
 #include <limits.h>
 #include <unistd.h>
@@ -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);