Remove dependency on `wcsnlen` for string length calculation. The `wcsnlen` function is not consistently available across all target environments. Its prior use was intended as a micro-optimization and safeguard to limit string scanning to the remaining buffer size and prevent potential issues with malformed strings lacking a null terminator. This change now relies on the implicit `std::wstring_view` constructor to determine the string length. `CopyToEncodedBuffer` will continue to handle truncation effectively, mitigating the original concerns. PiperOrigin-RevId: 756378282 Change-Id: I858bad01724507f7926f868aa300eabad8a4358c
diff --git a/absl/log/internal/log_message.cc b/absl/log/internal/log_message.cc index 07d17a0..3aed3a2 100644 --- a/absl/log/internal/log_message.cc +++ b/absl/log/internal/log_message.cc
@@ -27,7 +27,6 @@ #include <algorithm> #include <array> #include <atomic> -#include <cwchar> #include <ios> #include <memory> #include <ostream> @@ -425,8 +424,7 @@ CopyToEncodedBuffer<StringType::kNotLiteral>( absl::string_view(kCharNull.data(), kCharNull.size() - 1)); } else { - CopyToEncodedBuffer<StringType::kNotLiteral>( - std::wstring_view(v, wcsnlen(v, data_->encoded_remaining().size()))); + CopyToEncodedBuffer<StringType::kNotLiteral>(v); } return *this; }