Skip to content

Commit

Permalink
Make project compile with clang 11.0.1-2 in Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfea committed Mar 30, 2023
1 parent cb0db7c commit 169aa33
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/include/OpenImageIO/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,6 @@ class basic_string_view {
using string_view = basic_string_view<char>;
using wstring_view = basic_string_view<wchar_t>;



// DEPRECATED name equivalence
OIIO_DEPRECATED("Use string_view (2.3)")
typedef string_view string_ref;
Expand Down
6 changes: 4 additions & 2 deletions src/include/OpenImageIO/strutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,13 +670,15 @@ template<> inline double from_string<double> (string_view s) {

template<> inline int64_t from_string<int64_t>(string_view s) {
// For conversion of string_view to unsigned int, fall back on strtoll.
auto r = strtoll(std::string(s).c_str(), nullptr, 10);
std::string s2 = std::string(s);
auto r = strtoll(s2.c_str(), nullptr, 10);
return static_cast<int64_t>(r);
}

template<> inline uint64_t from_string<uint64_t>(string_view s) {
// For conversion of string_view to unsigned int, fall back on strtoull.
auto r = strtoull(std::string(s).c_str(), nullptr, 10);
std::string s2 = std::string(s);
auto r = strtoull(s2.c_str(), nullptr, 10);
return static_cast<uint64_t>(r);
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/libOpenImageIO/imagebuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ ImageBufImpl::error(string_view message) const
// a single newline.
if (m_err.size() && m_err.back() != '\n')
m_err += '\n';
m_err += message;
m_err += std::string(message);
}


Expand Down
2 changes: 1 addition & 1 deletion src/libOpenImageIO/imageinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ ImageInput::append_error(string_view message) const
if (errptr->size() < 1024 * 1024 * 16) {
if (errptr->size() && errptr->back() != '\n')
*errptr += '\n';
*errptr += message;
*errptr += std::string(message);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libOpenImageIO/imageio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,12 @@ pvt::append_error(string_view message)
// a single newline.
if (error_msg.size() && error_msg.back() != '\n')
error_msg += '\n';
error_msg += message;
error_msg += std::string(message);

// Remove a single trailing newline
if (message.size() && message.back() == '\n')
message.remove_suffix(1);
error_msg = message;
error_msg = std::string(message);
}


Expand Down
2 changes: 1 addition & 1 deletion src/libOpenImageIO/imageoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ ImageOutput::append_error(string_view message) const
&& "Accumulated error messages > 16MB. Try checking return codes!");
if (errptr->size() && errptr->back() != '\n')
*errptr += '\n';
*errptr += message;
*errptr += std::string(message);
}


Expand Down
2 changes: 1 addition & 1 deletion src/libtexture/imagecache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3942,7 +3942,7 @@ ImageCacheImpl::append_error(string_view message) const
&& "Accumulated error messages > 16MB. Try checking return codes!");
if (errptr->size() && errptr->back() != '\n')
*errptr += '\n';
*errptr += message;
*errptr += std::string(message);
}


Expand Down
2 changes: 1 addition & 1 deletion src/libtexture/texturesys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ TextureSystemImpl::append_error(string_view message) const
&& "Accumulated error messages > 16MB. Try checking return codes!");
if (errptr->size() && errptr->back() != '\n')
*errptr += '\n';
*errptr += message;
*errptr += std::string(message);
}


Expand Down
12 changes: 11 additions & 1 deletion src/libutil/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
# include <sys/stat.h>
# include <sys/types.h>
# include <unistd.h>
#ifdef __APPLE__
# include <utime.h>
#endif
#endif

#if defined(USE_STD_FILESYSTEM)
Expand Down Expand Up @@ -778,12 +781,19 @@ Filesystem::last_write_time(string_view path, std::time_t time) noexcept
times.modtime = time;
_wutime(u8path(path).c_str(), &times);
#else
#ifndef __APPLE__
struct timespec times[2];
times[0].tv_sec = 0;
times[0].tv_nsec = UTIME_OMIT;
times[1].tv_sec = time;
times[1].tv_nsec = 0;
utimensat((int)AT_FDCWD, u8path(path).c_str(), times, AT_SYMLINK_NOFOLLOW);
utimensat((int)AT_FDCWD, u8path(path).c_str(), times, AT_SYMLINK_NOFOLLOW);
#else
struct utimbuf times;
times.actime = time;
times.modtime = time;
utime(u8path(path).c_str(), &times);
#endif
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/oiiotool/imagerec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,5 +413,5 @@ ImageRec::append_error(string_view message) const
&& "Accumulated error messages > 16MB. Try checking return codes!");
if (m_err.size() && m_err[m_err.size() - 1] != '\n')
m_err += '\n';
m_err += message;
m_err += std::string(message);
}

0 comments on commit 169aa33

Please sign in to comment.