[libc-commits] [libc] Implement inet_pton (PR #224644)
via libc-commits
libc-commits at lists.llvm.org
Tue Sep 22 05:33:48 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') {
----------------
afnrow wrote:
I tried testing non-ASCII characters against `glibc`'s `inet_pton` and it returned an error and I think RFC 2373 which is what `inet_pton` is based on standardises ASCII only.
https://github.com/llvm/llvm-project/pull/224644
More information about the libc-commits
mailing list