From edbbe8dcfd30fcfe84f6b62240e22dbf9138677c Mon Sep 17 00:00:00 2001 From: YongDo-Hyun Date: Wed, 26 Nov 2025 20:10:42 +0300 Subject: feat: add local test executable and improve JSON string escaping - Added option to build a local test executable for value assignments. - Enhanced JSON string formatting by escaping special characters. - Updated README with build instructions and prerequisites. - Modified .gitignore to include .vscode directory. - Added file read/write tests in format_test.cpp. - Refactored value assignment logic to reduce code duplication. Signed-off-by: YongDo-Hyun --- src/io/ozlibstream.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/io/ozlibstream.cpp') diff --git a/src/io/ozlibstream.cpp b/src/io/ozlibstream.cpp index cf0f505394..b936219787 100644 --- a/src/io/ozlibstream.cpp +++ b/src/io/ozlibstream.cpp @@ -101,9 +101,20 @@ void ozlibstream::close() } catch(...) { - setstate(badbit); //FIXME: This will throw the wrong type of exception - //but there's no good way of setting the badbit - //without causing an exception when exceptions is set + // Setting the stream state while exceptions are enabled may cause + // `setstate` to throw an `ios_base::failure` which would replace + // the original exception. Temporarily disable exceptions on this + // stream, set the `badbit`, then restore the exception mask. + std::ios_base::iostate old_ex = exceptions(); + try { + exceptions(std::ios_base::goodbit); + setstate(std::ios_base::badbit); + } + catch(...) { + // If anything unexpected happens while setting state, swallow + // it — we don't want this to throw here. + } + exceptions(old_ex); } } -- cgit 0.0.5-2-1-g0f52