]> git.donarmstrong.com Git - lilypond.git/blob - debian/patches/hurd_file_name_support
Fix patch for FTBFS on hurd. Thanks to Petter Reinholdtsen for the bug report and...
[lilypond.git] / debian / patches / hurd_file_name_support
1 Description: Hurd build without PATH_MAX; currently broken
2 Forwarded: http://lists.gnu.org/archive/html/bug-lilypond/2017-01/msg00023.html
3 Origin: vendor, https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=761036;filename=hurd_file_name_support;msg=5
4 Bug-Debian: https://bugs.debian.org/761036
5 Author: Don Armstrong <don@debian.org>
6 Author: Petter Reinholdtsen <pere@hungry.com>
7 Reviewed-by: Dr. Tobias Quathamer <toddy@debian.org>
8 Reviewed-by: Anthony Fok <foka@debian.org>
9 Last-Update: 2017-01-27
10 --- a/flower/file-name.cc
11 +++ b/flower/file-name.cc
12 @@ -96,9 +96,16 @@
13  string
14  get_working_directory ()
15  {
16 +#ifdef _GNU_SOURCE
17 +  char *cwd = get_current_dir_name();
18 +  string scwd(cwd);
19 +  free(cwd);
20 +  return scwd;
21 +#else
22    char cwd[PATH_MAX];
23    // getcwd returns NULL upon a failure, contents of cwd would be undefined!
24    return string (getcwd (cwd, PATH_MAX));
25 +#endif
26  }
27  
28  /* Join components to full file_name. */
29 --- a/flower/test-file-path.cc
30 +++ b/flower/test-file-path.cc
31 @@ -6,12 +6,26 @@
32  #include "yaffut.hh"
33  #include "config.hh"
34  
35 +string
36 +get_working_directory ()
37 +{
38 +#ifdef _GNU_SOURCE
39 +  char *cwd = get_current_dir_name();
40 +  string scwd(cwd);
41 +  free(cwd);
42 +  return scwd;
43 +#else
44 +  char cwd[PATH_MAX];
45 +  // getcwd returns NULL upon a failure, contents of cwd would be undefined!
46 +  return string (getcwd (cwd, PATH_MAX));
47 +#endif
48 +}
49 +
50  TEST (File_path, Find)
51  {
52    char const *extensions[] = {"ly", "", 0};
53    string file = "init";
54 -  char cwd[PATH_MAX];
55 -  if (!getcwd (cwd, PATH_MAX))
56 +  if (get_working_directory().empty())
57      {
58        cerr << "Could not get current work directory\n";
59        exit (1);