Package: lilypond
Version: 2.12.3-1
Tags: patch
Severity: wishlist
User: debian-h...@lists.debian.org
Usertags: hurd

Hi.  The lilypond package do not build on hurd, even with a hurd patch
in place.  The cause seem to be a typo in the file
debian/patches/hurd_file_name_support, checking for _GNU_SOURCE_
instead of _GNU_SOURCE (at least that is what the getcwd() manual page
claim to look for).

Attached is an updated patch, fixing that bug, a memory leak
forgetting to release the memory allocated by get_current_dir_name(),
and adding the same code in the test code.

Please replace the patch in the current source with this new one, and
consider sending it upstream. :)

-- 
Happy hacking
Petter Reinholdtsen
Description: Hurd build without PATH_MAX; currently broken
Forwarded: not-needed
Origin: vendor
Author: Don Armstrong <d...@debian.org>
Index: lilypond-2.18.2-pere/flower/file-name.cc
===================================================================
--- lilypond-2.18.2-pere.orig/flower/file-name.cc       2014-09-10 
09:25:45.057177512 +0200
+++ lilypond-2.18.2-pere/flower/file-name.cc    2014-09-10 09:30:19.783634883 
+0200
@@ -96,9 +96,16 @@
 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: lilypond-2.18.2-pere/flower/test-file-path.cc
===================================================================
--- lilypond-2.18.2-pere.orig/flower/test-file-path.cc  2014-09-10 
09:26:15.057445802 +0200
+++ lilypond-2.18.2-pere/flower/test-file-path.cc       2014-09-10 
09:30:05.599507531 +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);

Reply via email to