mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
[util] const in env_set
This commit is contained in:
parent
d6d891c5de
commit
84c5b2da03
@ -24,7 +24,7 @@
|
||||
* set @a name to specified substring of @a value.
|
||||
*/
|
||||
int
|
||||
env_set(const char *name, char *value, int length)
|
||||
env_set(const char *name, const char *value, int length)
|
||||
{
|
||||
int true_length, substring = 0;
|
||||
|
||||
@ -36,18 +36,21 @@ env_set(const char *name, char *value, int length)
|
||||
|
||||
#if defined(HAVE_SETENV)
|
||||
{
|
||||
int ret, allocated = 0;
|
||||
|
||||
if (substring) {
|
||||
if (!substring) {
|
||||
return setenv(name, value, 1);
|
||||
} else {
|
||||
/* Copy the substring. */
|
||||
value = memacpy(value, length);
|
||||
if (!value) return -1;
|
||||
allocated = 1;
|
||||
}
|
||||
char *v = memacpy(value, length);
|
||||
|
||||
ret = setenv(name, value, 1);
|
||||
if (allocated) mem_free(value);
|
||||
return ret;
|
||||
if (v) {
|
||||
int ret = setenv(name, v, 1);
|
||||
mem_free(v);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(HAVE_PUTENV)
|
||||
|
@ -5,7 +5,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int env_set(const char *name, char *value, int len);
|
||||
int env_set(const char *name, const char *value, int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user