From e2ad5f961912c9d9b8e8ada82f6b923c26081e73 Mon Sep 17 00:00:00 2001 From: jie Date: Fri, 5 Nov 2021 19:53:42 +0800 Subject: [PATCH] fix bug: WebApp: rendering: read_bin: eof & change std to c++17 --- WebApp/WebApp/WebApp.vcxproj | 2 +- WebApp/WebApp/rendering.cpp | 7 +++++-- WebApp/bserv/bserv.vcxproj | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/WebApp/WebApp/WebApp.vcxproj b/WebApp/WebApp/WebApp.vcxproj index 0e9933b..b9c02ee 100644 --- a/WebApp/WebApp/WebApp.vcxproj +++ b/WebApp/WebApp/WebApp.vcxproj @@ -116,7 +116,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp20 + stdcpp17 ..\..\dependencies\inja\include;..\..\dependencies\inja\third_party\include;..\bserv\include;..\..\dependencies\libpqxx\include;..\..\dependencies;..\..\dependencies\boost;%(AdditionalIncludeDirectories) /bigobj %(AdditionalOptions) diff --git a/WebApp/WebApp/rendering.cpp b/WebApp/WebApp/rendering.cpp index 79bae51..6d03cfd 100644 --- a/WebApp/WebApp/rendering.cpp +++ b/WebApp/WebApp/rendering.cpp @@ -69,8 +69,11 @@ mime_type(boost::beast::string_view path) { std::string read_bin(const std::string& file) { std::ifstream fin(file, std::ios_base::in | std::ios_base::binary); std::string res; - char c; - while ((c = (char)fin.get()) != EOF) res += c; + while (true) { + char c = (char)fin.get(); + if (fin.eof()) break; + res += c; + } return res; } diff --git a/WebApp/bserv/bserv.vcxproj b/WebApp/bserv/bserv.vcxproj index 2055f2b..c96093d 100644 --- a/WebApp/bserv/bserv.vcxproj +++ b/WebApp/bserv/bserv.vcxproj @@ -127,7 +127,7 @@ Use pch.h ..\..\dependencies\libpqxx\include;..\..\dependencies;..\..\dependencies\boost;include;%(AdditionalIncludeDirectories) - stdcpp20 + stdcpp17 /bigobj %(AdditionalOptions)