diff --git a/src/common.h b/src/common.h index 46953359f..4ea4637df 100644 --- a/src/common.h +++ b/src/common.h @@ -4,6 +4,7 @@ #include "config.h" // IWYU pragma: keep #include +#include #include #include // IWYU pragma: keep #include @@ -89,6 +90,17 @@ typedef std::vector wcstring_list_t; #define INPUT_COMMON_BASE (wchar_t)0xF700 #define INPUT_COMMON_END (INPUT_COMMON_BASE + 64) +// NAME_MAX is not defined on Solaris +#if !defined(NAME_MAX) +#include +#if defined(MAXNAMELEN) +// MAXNAMELEN is defined on Linux, BSD, and Solaris among others +#define NAME_MAX MAXNAMELEN +#else +static_assert(false, "Neither NAME_MAX nor MAXNAMELEN is defined!"); +#endif +#endif + enum escape_string_style_t { STRING_STYLE_SCRIPT, STRING_STYLE_URL, STRING_STYLE_VAR }; // Flags for unescape_string functions. diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index eac8b1e10..86ad085bd 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -55,13 +55,6 @@ #include #endif // Haiku -// NAME_MAX is not defined on Solaris and suggests the use of pathconf() -// There is no obvious sensible pathconf() for shared memory and _XPG_NAME_MAX -// seems a reasonable choice. -#if !defined(NAME_MAX) && defined(_XOPEN_NAME_MAX) -#define NAME_MAX _XOPEN_NAME_MAX -#endif - /// The set command. #define SET_STR L"SET" diff --git a/src/wutil.cpp b/src/wutil.cpp index d777555bf..ab5de1d76 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -92,7 +92,7 @@ bool wreaddir(DIR *dir, wcstring &out_name) { // long when it should be at least NAME_MAX + 1. union { struct dirent d; - char c[offsetof(struct dirent, d_name) + NAME_MAX + 1]; /* NAME_MAX is POSIX. */ + char c[offsetof(struct dirent, d_name) + NAME_MAX + 1]; } d_u; struct dirent *result = NULL;