-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There is no setenv() in Solaris 5.8. The trivial calls to setenv() were replaced by putenv() in a much earlier patch, but setenv() was used again in git.c. This patch just adds a compat/setenv.c. The rule for building git$(X) also needs to include compat. objects and compiler flags. Those are now in makefile vars COMPAT_OBJS and COMPAT_CFLAGS. Signed-off-by: E. Jason Riedy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
- Loading branch information
Jason Riedy
authored and
Junio C Hamano
committed
Dec 4, 2005
1 parent
7057463
commit e40b61f
Showing
3 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
int gitsetenv(const char *name, const char *value, int replace) | ||
{ | ||
int out; | ||
size_t namelen, valuelen; | ||
char *envstr; | ||
|
||
if (!name || !value) return -1; | ||
if (!replace) { | ||
char *oldval = NULL; | ||
oldval = getenv(name); | ||
if (oldval) return 0; | ||
} | ||
|
||
namelen = strlen(name); | ||
valuelen = strlen(value); | ||
envstr = malloc((namelen + valuelen + 2) * sizeof(char)); | ||
if (!envstr) return -1; | ||
|
||
memcpy(envstr, name, namelen); | ||
envstr[namelen] = '='; | ||
memcpy(envstr + namelen + 1, value, valuelen); | ||
envstr[namelen + valuelen + 1] = 0; | ||
|
||
out = putenv(envstr); | ||
|
||
free(envstr); | ||
return out; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters