Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,15 @@
return false;
std::string buf(128, '\0');
{
#if __cplusplus >= 201703L
// C++17 provides an overload with non-const data()
#define CONST_CAST(x) (x)
#else
#define CONST_CAST(x) const_cast<char*>(x)
#endif
// TODO: read the whole first line only
const char * const res = fgets(const_cast<char*>(buf.data()), buf.size(), fp);
const char * const res = fgets(CONST_CAST(buf.data()), buf.size(), fp);
#undef CONST_CAST
fclose(fp);
fp = nullptr;
if (!res)
Expand Down