From fb80e0421275403a929743cad86b71de7ffd646e Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 1 Jun 2017 14:05:03 -0700 Subject: Check sentry to remove unused variable warning --- tiny_obj_loader.h | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tiny_obj_loader.h b/tiny_obj_loader.h index 3c80145..1006070 100644 --- a/tiny_obj_loader.h +++ b/tiny_obj_loader.h @@ -401,20 +401,22 @@ static std::istream &safeGetline(std::istream &is, std::string &t) { std::istream::sentry se(is, true); std::streambuf *sb = is.rdbuf(); - for (;;) { - int c = sb->sbumpc(); - switch (c) { - case '\n': - return is; - case '\r': - if (sb->sgetc() == '\n') sb->sbumpc(); - return is; - case EOF: - // Also handle the case when the last line has no line ending - if (t.empty()) is.setstate(std::ios::eofbit); - return is; - default: - t += static_cast(c); + if (se) { + for (;;) { + int c = sb->sbumpc(); + switch (c) { + case '\n': + return is; + case '\r': + if (sb->sgetc() == '\n') sb->sbumpc(); + return is; + case EOF: + // Also handle the case when the last line has no line ending + if (t.empty()) is.setstate(std::ios::eofbit); + return is; + default: + t += static_cast(c); + } } } } -- cgit v1.2.3