diff options
| author | YongDo-Hyun <froster12@naver.com> | 2025-11-26 20:10:42 +0300 |
|---|---|---|
| committer | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-03-27 19:57:09 +0300 |
| commit | edbbe8dcfd30fcfe84f6b62240e22dbf9138677c (patch) | |
| tree | 8b9c8edb939d573d76d6390535d3eacf4342e9c4 /src/io/ozlibstream.cpp | |
| parent | 687e43031df0dc641984b4256bcca50d5b3f7de3 (diff) | |
| download | Project-Tick-edbbe8dcfd30fcfe84f6b62240e22dbf9138677c.tar.gz Project-Tick-edbbe8dcfd30fcfe84f6b62240e22dbf9138677c.zip | |
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 <froster12@naver.com>
Diffstat (limited to 'src/io/ozlibstream.cpp')
| -rw-r--r-- | src/io/ozlibstream.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
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); } } |
