remove environ and os-envs primitives
parent
ab0ed9f988
commit
84ec1eec1d
|
@ -10,7 +10,3 @@ extern int getosreldate(void);
|
|||
|
||||
#define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN)
|
||||
#define DIRECTORY_P(file) ((file)->d_type == DT_DIR)
|
||||
|
||||
#ifndef environ
|
||||
extern char **environ;
|
||||
#endif
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
#define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN)
|
||||
#define DIRECTORY_P(file) ((file)->d_type == DT_DIR)
|
||||
|
||||
#ifndef environ
|
||||
extern char **environ;
|
||||
#endif
|
||||
|
||||
int inotify_init(void);
|
||||
int inotify_add_watch(int fd, const char *name, u32 mask);
|
||||
int inotify_rm_watch(int fd, u32 wd);
|
||||
|
|
|
@ -12,11 +12,6 @@ const char *default_image_path(void);
|
|||
|
||||
DLLEXPORT void c_to_factor_toplevel(CELL quot);
|
||||
|
||||
#ifndef environ
|
||||
extern char ***_NSGetEnviron(void);
|
||||
#define environ (*_NSGetEnviron())
|
||||
#endif
|
||||
|
||||
INLINE void *ucontext_stack_pointer(void *uap)
|
||||
{
|
||||
ucontext_t *ucontext = (ucontext_t *)uap;
|
||||
|
|
|
@ -4,5 +4,3 @@
|
|||
|
||||
#define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN)
|
||||
#define DIRECTORY_P(file) ((file)->d_type == DT_DIR)
|
||||
|
||||
extern char **environ;
|
||||
|
|
|
@ -1,6 +1,2 @@
|
|||
#define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN)
|
||||
#define DIRECTORY_P(file) ((file)->d_type == DT_DIR)
|
||||
|
||||
#ifndef environ
|
||||
extern char **environ;
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,2 @@
|
|||
#define UNKNOWN_TYPE_P(file) 1
|
||||
#define DIRECTORY_P(file) 0
|
||||
|
||||
extern char **environ;
|
||||
|
|
66
vm/os-unix.c
66
vm/os-unix.c
|
@ -99,72 +99,6 @@ DEFINE_PRIMITIVE(read_dir)
|
|||
dpush(result);
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(os_env)
|
||||
{
|
||||
char *name = unbox_char_string();
|
||||
char *value = getenv(name);
|
||||
if(value == NULL)
|
||||
dpush(F);
|
||||
else
|
||||
box_char_string(value);
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(os_envs)
|
||||
{
|
||||
GROWABLE_ARRAY(result);
|
||||
REGISTER_ROOT(result);
|
||||
char **env = environ;
|
||||
|
||||
while(*env)
|
||||
{
|
||||
CELL string = tag_object(from_char_string(*env));
|
||||
GROWABLE_ARRAY_ADD(result,string);
|
||||
env++;
|
||||
}
|
||||
|
||||
UNREGISTER_ROOT(result);
|
||||
GROWABLE_ARRAY_TRIM(result);
|
||||
dpush(result);
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(set_os_env)
|
||||
{
|
||||
char *key = unbox_char_string();
|
||||
REGISTER_C_STRING(key);
|
||||
char *value = unbox_char_string();
|
||||
UNREGISTER_C_STRING(key);
|
||||
setenv(key, value, 1);
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(unset_os_env)
|
||||
{
|
||||
char *key = unbox_char_string();
|
||||
unsetenv(key);
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(set_os_envs)
|
||||
{
|
||||
F_ARRAY *array = untag_array(dpop());
|
||||
CELL size = array_capacity(array);
|
||||
|
||||
/* Memory leak */
|
||||
char **env = calloc(size + 1,sizeof(CELL));
|
||||
|
||||
CELL i;
|
||||
for(i = 0; i < size; i++)
|
||||
{
|
||||
F_STRING *string = untag_string(array_nth(array,i));
|
||||
CELL length = to_fixnum(string->length);
|
||||
|
||||
char *chars = malloc(length + 1);
|
||||
char_string_to_memory(string,chars);
|
||||
chars[length] = '\0';
|
||||
env[i] = chars;
|
||||
}
|
||||
|
||||
environ = env;
|
||||
}
|
||||
|
||||
F_SEGMENT *alloc_segment(CELL size)
|
||||
{
|
||||
int pagesize = getpagesize();
|
||||
|
|
|
@ -214,38 +214,3 @@ void sleep_millis(DWORD msec)
|
|||
{
|
||||
Sleep(msec);
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(os_env)
|
||||
{
|
||||
F_CHAR *key = unbox_u16_string();
|
||||
F_CHAR *value = safe_malloc(MAX_UNICODE_PATH * 2);
|
||||
int ret;
|
||||
ret = GetEnvironmentVariable(key, value, MAX_UNICODE_PATH * 2);
|
||||
if(ret == 0)
|
||||
dpush(F);
|
||||
else
|
||||
dpush(tag_object(from_u16_string(value)));
|
||||
free(value);
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(set_os_env)
|
||||
{
|
||||
F_CHAR *key = unbox_u16_string();
|
||||
REGISTER_C_STRING(key);
|
||||
F_CHAR *value = unbox_u16_string();
|
||||
UNREGISTER_C_STRING(key);
|
||||
if(!SetEnvironmentVariable(key, value))
|
||||
general_error(ERROR_IO, tag_object(get_error_message()), F, NULL);
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(unset_os_env)
|
||||
{
|
||||
if(!SetEnvironmentVariable(unbox_u16_string(), NULL)
|
||||
&& GetLastError() != ERROR_ENVVAR_NOT_FOUND)
|
||||
general_error(ERROR_IO, tag_object(get_error_message()), F, NULL);
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(set_os_envs)
|
||||
{
|
||||
not_implemented_error();
|
||||
}
|
||||
|
|
|
@ -71,7 +71,6 @@ void *primitives[] = {
|
|||
primitive_exit,
|
||||
primitive_data_room,
|
||||
primitive_code_room,
|
||||
primitive_os_env,
|
||||
primitive_millis,
|
||||
primitive_modify_code_heap,
|
||||
primitive_dlopen,
|
||||
|
@ -141,10 +140,6 @@ void *primitives[] = {
|
|||
primitive_innermost_stack_frame_scan,
|
||||
primitive_set_innermost_stack_frame_quot,
|
||||
primitive_call_clear,
|
||||
primitive_os_envs,
|
||||
primitive_set_os_env,
|
||||
primitive_unset_os_env,
|
||||
primitive_set_os_envs,
|
||||
primitive_resize_byte_array,
|
||||
primitive_dll_validp,
|
||||
primitive_unimplemented,
|
||||
|
|
Loading…
Reference in New Issue