mailing list of musl libc
 help / color / mirror / code / Atom feed
facae1da0752bbacdbc12c710ada5c0d293585a2 blob 1042 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
#include <stdlib.h>
#include <string.h>
#include "libc.h"

char *__strchrnul(const char *, int);
int __unsetenv(const char *, size_t, char **);

static void dummy(char *p, char *r) {}
weak_alias(dummy, __env_change);

int __putenv(char *s, size_t l, char *r)
{
	size_t i=0;
	if (__environ)
		for (; __environ[i]; i++)
			if (!strncmp(__environ[i], s, l+1)) {
				char *tmp = __environ[i];
				__environ[i] = s;
				__env_change(tmp, r);
				return __unsetenv(s, l, __environ+i+1);
			}
	static char **oldenv;
	char **newenv;
	if (__environ == oldenv) {
		newenv = realloc(oldenv, sizeof *newenv * (i+2));
		if (!newenv) goto oom;
	} else {
		newenv = malloc(sizeof *newenv * (i+2));
		if (!newenv) goto oom;
		if (i) memcpy(newenv, __environ, sizeof *newenv * i);
		free(oldenv);
	}
	newenv[i] = s;
	newenv[i+1] = 0;
	__environ = oldenv = newenv;
	if (r) __env_change(0, r);
	return 0;
oom:
	free(r);
	return -1;
}

int putenv(char *s)
{
	size_t l = __strchrnul(s, '=') - s;
	if (!l || !s[l]) return unsetenv(s);
	return __putenv(s, l, 0);
}
debug log:

solving facae1d ...
found facae1d in https://inbox.vuxu.org/musl/1457895230-13602-3-git-send-email-amonakov@ispras.ru/
found 39a71be in https://inbox.vuxu.org/musl/1457895230-13602-2-git-send-email-amonakov@ispras.ru/
found 7153042 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 7153042669da81a80bff37a3c25aeb1618a64da9	src/env/putenv.c

applying [1/2] https://inbox.vuxu.org/musl/1457895230-13602-2-git-send-email-amonakov@ispras.ru/
diff --git a/src/env/putenv.c b/src/env/putenv.c
dissimilarity index 88%
index 7153042..39a71be 100644


applying [2/2] https://inbox.vuxu.org/musl/1457895230-13602-3-git-send-email-amonakov@ispras.ru/
diff --git a/src/env/putenv.c b/src/env/putenv.c
index 39a71be..facae1d 100644

Checking patch src/env/putenv.c...
Applied patch src/env/putenv.c cleanly.
Checking patch src/env/putenv.c...
Applied patch src/env/putenv.c cleanly.

index at:
100644 facae1da0752bbacdbc12c710ada5c0d293585a2	src/env/putenv.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).