Skip to content

Commit

Permalink
Add null case to put_env function in sys
Browse files Browse the repository at this point in the history
Increment version number to 2.4.0
  • Loading branch information
tobil4sk committed Sep 24, 2021
1 parent 1a5f373 commit df572a7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
endif()

set(NEKO_VERSION_MAJOR 2)
set(NEKO_VERSION_MINOR 3)
set(NEKO_VERSION_MINOR 4)
set(NEKO_VERSION_PATCH 0)
set(NEKO_VERSION ${NEKO_VERSION_MAJOR}.${NEKO_VERSION_MINOR}.${NEKO_VERSION_PATCH})

Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ variables:
- name: AZURE_PIPELINES_BRANCH
value: $(Build.SourceBranchName)
- name: NEKO_VERSION
value: "2.3.0"
value: "2.4.0"

trigger:
branches:
Expand Down
20 changes: 14 additions & 6 deletions libs/std/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,28 @@ static value get_env( value v ) {
<doc>Set some environment variable value</doc>
**/
static value put_env( value e, value v ) {
val_check(e,string);
bool is_null = val_is_null(v);
#ifdef NEKO_WINDOWS
buffer b;
val_check(e,string);
val_check(v,string);
if( !is_null )
val_check(v,string);
b = alloc_buffer(NULL);
val_buffer(b,e);
buffer_append_sub(b,"=",1);
val_buffer(b,v);
if( !is_null )
val_buffer(b,v);
if( putenv(val_string(buffer_to_string(b))) != 0 )
neko_error();
#else
val_check(e,string);
val_check(v,string);
if( setenv(val_string(e),val_string(v),1) != 0 )
int result;
if( is_null )
result = unsetenv(val_string(e));
else {
val_check(v,string);
result = setenv(val_string(e),val_string(v),1);
}
if( result != 0 )
neko_error();
#endif
return val_true;
Expand Down

0 comments on commit df572a7

Please sign in to comment.