File hurd_file_name_support.patch of Package lilypond

Description: Hurd build without PATH_MAX; currently broken
Forwarded: http://lists.gnu.org/archive/html/bug-lilypond/2017-01/msg00023.html
Origin: vendor, https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=761036;filename=hurd_file_name_support;msg=5
Bug-Debian: https://bugs.debian.org/761036
Author: Don Armstrong <don@debian.org>
Author: Petter Reinholdtsen <pere@hungry.com>
Reviewed-by: Dr. Tobias Quathamer <toddy@debian.org>
Reviewed-by: Anthony Fok <foka@debian.org>
Last-Update: 2017-01-27
Index: flower/file-name.cc
===================================================================
--- flower/file-name.cc.orig	2014-03-17 17:29:16.000000000 +0200
+++ flower/file-name.cc	2018-05-15 10:47:37.694730726 +0200
@@ -96,9 +96,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: flower/test-file-path.cc
===================================================================
--- flower/test-file-path.cc.orig	2014-03-17 17:29:16.000000000 +0200
+++ flower/test-file-path.cc	2018-05-15 10:47:37.694730726 +0200
@@ -6,12 +6,26 @@
 #include "yaffut.hh"
 #include "config.hh"
 
+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
+}
+
 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);