Skip to content

Commit ad725d3

Browse files
authored
Use std::getenv #3414 (#3415)
1 parent e655dbb commit ad725d3

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

include/spdlog/cfg/helpers-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ inline std::unordered_map<std::string, std::string> extract_key_vals_(const std:
7171
}
7272

7373
SPDLOG_INLINE void load_levels(const std::string &input) {
74-
if (input.empty() || input.size() > 512) {
74+
if (input.empty() || input.size() >= 32768) {
7575
return;
7676
}
7777

include/spdlog/details/os-inl.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -563,21 +563,21 @@ SPDLOG_INLINE filename_t dir_name(const filename_t &path) {
563563
return pos != filename_t::npos ? path.substr(0, pos) : filename_t{};
564564
}
565565

566+
#ifdef _MSC_VER
567+
#pragma warning(push)
568+
#pragma warning(disable : 4996)
569+
#endif // _MSC_VER
566570
std::string SPDLOG_INLINE getenv(const char *field) {
567-
#if defined(_MSC_VER)
568-
#if defined(__cplusplus_winrt)
571+
#if defined(_MSC_VER) && defined(__cplusplus_winrt)
569572
return std::string{}; // not supported under uwp
570-
#else
571-
size_t len = 0;
572-
char buf[128];
573-
bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0;
574-
return ok ? buf : std::string{};
575-
#endif
576-
#else // revert to getenv
577-
char *buf = ::getenv(field);
573+
#else
574+
char *buf = std::getenv(field);
578575
return buf ? buf : std::string{};
579576
#endif
580577
}
578+
#ifdef _MSC_VER
579+
#pragma warning(pop)
580+
#endif // _MSC_VER
581581

582582
// Do fsync by FILE handlerpointer
583583
// Return true on success

0 commit comments

Comments
 (0)