• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/package/ibrcommon/0001-ibrcommon-data-File.cpp-support-POSIX-basename-call.patch
Brendan HeadingBrendan Heading committed 186d5d1b5f315 Sep 2015
Raw file
Source viewDiff to previous
xxxxxxxxxx
 
1
From d667b13a87cf3207599a19eb981a893a1d7a67ee Mon Sep 17 00:00:00 2001
2
From: Brendan Heading <brendanheading@gmail.com>
3
Date: Mon, 14 Sep 2015 23:25:52 +0100
4
Subject: [PATCH 1/1] ibrcommon/data/File.cpp: support POSIX basename call
5
​
6
Firstly, and somewhat strangely, musl chooses not to provide a basename(3)
7
prototype within <string.h> whenever __cplusplus is defined. This can be
8
solved by including the <libgen.h> header defined by POSIX 1003.1 whenever
9
__GLIBC__ is not defined.
10
​
11
However, this leads to a second problem. POSIX defines the function as
12
char* basename(char*) and this is the only version supported by musl.
13
However, the std::string.cstr() method returns a const char*.
14
​
15
POSIX says that the string parameter can be modified. However the GNU
16
implementation never modifies it. glibc therefore supports an extension
17
when compiling under C++ by also supplying
18
const char* basename(const char*). This extension is not present on musl
19
which is the cause of the failure.
20
​
21
The solution is reasonably straightforward; test if __GLIBC__ is defined
22
before calling basename. If not, use the fallback already provided for
23
other platforms whereby basename() is called on a temporary copy.
24
​
25
Signed-off-by: Brendan Heading <brendanheading@gmail.com>
26
Upstream-status: pending
27
---
28
 ibrcommon/data/File.cpp | 4 ++--
29
 1 file changed, 2 insertions(+), 2 deletions(-)
30
​
31
diff --git a/ibrcommon/data/File.cpp b/ibrcommon/data/File.cpp
32
index 31af4ae..68e9b4f 100644
33
--- a/ibrcommon/data/File.cpp
34
+++ b/ibrcommon/data/File.cpp
35
@@ -35,7 +35,7 @@
36
 #include <cerrno>
37
 #include <fstream>
38
 
39
-#if !defined(HAVE_FEATURES_H) || defined(ANDROID)
40
+#if !defined(HAVE_FEATURES_H) || !defined(__GLIBC__) || defined(ANDROID)
41
 #include <libgen.h>
42
 #endif
43
 
44
@@ -225,7 +225,7 @@ namespace ibrcommon
45
 
46
    std::string File::getBasename() const
47
    {
48
-#if !defined(ANDROID) && defined(HAVE_FEATURES_H)
49
+#if !defined(ANDROID) && defined(HAVE_FEATURES_H) && defined(__GLIBC__)
50
        return std::string(basename(_path.c_str()));
51
 #else
52
        char path[_path.length()+1];
53
-- 
54
2.4.3
55
​
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.