[libc-commits] [libc] [libc][stdlib] Add putenv (PR #208339)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Thu Jul 9 00:00:32 PDT 2026


================
@@ -265,5 +265,41 @@ int EnvironmentManager::unset(cpp::string_view name) {
   return 0;
 }
 
+int EnvironmentManager::put(char *string) {
+  cpp::string_view sv(string);
+  size_t eq_pos = sv.find_first_of('=');
+
+  // No '=' found: treat as unset (glibc/musl convention).
----------------
labath wrote:

This is one of the permitted behaviors under the latest posix: https://pubs.opengroup.org/onlinepubs/9799919799/functions/putenv.html

> If the string argument points to a string containing a valid name, the putenv() function shall either remove the environment variable with that name (if it exists) from the environment or fail with errno set to [EINVAL]

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


More information about the libc-commits mailing list