[libc-commits] [libc] Implement inet_pton (PR #224644)
Pavel Labath via libc-commits
libc-commits at lists.llvm.org
Tue Sep 22 02:32:31 PDT 2026
================
@@ -26,8 +27,48 @@
#include "src/string/memory_utils/inline_memcpy.h"
namespace LIBC_NAMESPACE_DECL {
+
namespace net {
+int inet_pton_v4(cpp::string_view src, void *dst) {
+ uint8_t bytes[4];
+ size_t idx = 0;
+ uint32_t current_val = 0;
+ size_t digits_in_octet = 0;
+
+ for (char c : src) {
+ if (c >= '0' && c <= '9') {
----------------
labath wrote:
We're also (trying to) support non-ascii targets, so these kinds of conditions aren't safe. This should be `internal::isdigit(c)`. Or just make a switch listing out all the cases (the two should produce rougly the same code).
https://github.com/llvm/llvm-project/pull/224644
More information about the libc-commits
mailing list