From 7d4bc6917b58d0e2743c438be4b0d20de28108f4 Mon Sep 17 00:00:00 2001 From: "benjamin.drung@gmail.com" Date: Thu, 21 Nov 2013 20:52:17 +0000 Subject: [PATCH] Fix build failure caused by undefined PATH_MAX. Use PATH_MAX for PLATFORM_MAX_PATH only if it is defined and replace all instances of PATH_MAX by PLATFORM_MAX_PATH. --- src/Audacity.h | 4 ++++ src/FileNames.cpp | 4 ++-- src/effects/VST/VSTEffect.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Audacity.h b/src/Audacity.h index 91e6ccf18..cf76b08e6 100644 --- a/src/Audacity.h +++ b/src/Audacity.h @@ -69,6 +69,7 @@ class wxWindow; void QuitAudacity(bool bForce); void QuitAudacity(); +// Please try to support unlimited path length instead of using PLATFORM_MAX_PATH! // Define one constant for maximum path value, so we don't have to do // platform-specific conditionals everywhere we want to check it. #define PLATFORM_MAX_PATH 260 // Play it safe for default, with same value as Windows' MAX_PATH. @@ -81,9 +82,12 @@ void QuitAudacity(); #ifdef __WXGTK__ #include "configunix.h" +// Some systems do not restrict the path length and therefore PATH_MAX is undefined +#ifdef PATH_MAX #undef PLATFORM_MAX_PATH #define PLATFORM_MAX_PATH PATH_MAX #endif +#endif #ifdef __WXX11__ #include "configunix.h" diff --git a/src/FileNames.cpp b/src/FileNames.cpp index 3a69ba7cd..67da50cc4 100644 --- a/src/FileNames.cpp +++ b/src/FileNames.cpp @@ -225,10 +225,10 @@ wxString FileNames::PathFromAddr(void *addr) #if defined(__WXMAC__) || defined(__WXGTK__) Dl_info info; if (dladdr(addr, &info)) { - char realname[PATH_MAX + 1]; + char realname[PLATFORM_MAX_PATH + 1]; int len; name = LAT1CTOWX(info.dli_fname); - len = readlink(OSINPUT(name.GetFullPath()), realname, PATH_MAX); + len = readlink(OSINPUT(name.GetFullPath()), realname, PLATFORM_MAX_PATH); if (len > 0) { realname[len] = 0; name.SetFullName(LAT1CTOWX(realname)); diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index fb29fad1f..7683322b7 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -2142,7 +2142,7 @@ bool VSTEffect::Load() } // Convert back to path - UInt8 exePath[PATH_MAX]; + UInt8 exePath[PLATFORM_MAX_PATH]; success = CFURLGetFileSystemRepresentation(exeRef, true, exePath, sizeof(exePath)); // Done with the executable reference