[libcxx-commits] [libcxx] [libc++] Fix ungetc failing after xsgetn (PR #210951)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 21 04:18:28 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions ,cpp -- libcxx/test/extensions/libcxx/input.output/file.streams/fstreams/filebuf.members/xsgetn.buffer.pass.cpp libcxx/include/fstream libcxx/test/std/input.output/file.streams/fstreams/ifstream.members/xsgetn.pass.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index bd94bb4bf..6f7f87489 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -409,7 +409,7 @@ private:
         } else {
           __self.setg(__self.__intbuf_, __self.__intbuf_ + __self.__ibs_, __self.__intbuf_ + __self.__ibs_);
         }
-        __self.__cm_ = ios_base::in;
+        __self.__cm_  = ios_base::in;
         __unget_size_ = 0;
       }
 
@@ -417,9 +417,7 @@ private:
         __self.setg(std::addressof(__1buf_), std::addressof(__1buf_) + 1, std::addressof(__1buf_) + 1);
     }
 
-    size_t __unget_size() {
-      return __unget_size_;
-    }
+    size_t __unget_size() { return __unget_size_; }
 
     ~__read_guard() {
       if (__self_.eback() == std::addressof(__1buf_))
@@ -850,7 +848,7 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>
   __read_guard __guard(__1buf, *this);
 
   const size_t __unget_sz = __guard.__unget_size();
-  int_type __c = traits_type::eof();
+  int_type __c            = traits_type::eof();
   if (this->gptr() == this->egptr()) {
     std::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
     if (__always_noconv_) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/210951


More information about the libcxx-commits mailing list