Skip to content

Commit

Permalink
Added clearenv polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchcapper committed Dec 6, 2024
1 parent d4056f9 commit 795a6aa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
29 changes: 28 additions & 1 deletion osfixes.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,48 @@
#include "osfixes.h"
#define _CRTIMP
#define WIN32_LEAN_AND_MEAN
#define _GL_CTYPE_H
#define _GL_CONFIG_H_INCLUDED 1
#include <windows.h>
#ifdef WLB_INCL_WLB_DEBUG_H
#include "wlb_debug.h"
#endif
#ifndef MAX_LONG_PATH
#define MAX_LONG_PATH 32768
#endif // !MAX_LONG_PATH


// #include "term.h"
// #include "general.h"

#include <../ucrt/stdlib.h>
#include <../ucrt/stdio.h>
#ifndef TRUE
#define FALSE 0
#define TRUE 1
#endif // !FALSE

int clearenv(void)
{
char* envp, * s;
char name[MAX_LONG_PATH];


while (environ && (envp = *environ)) {
if ((s = strchr(envp, '=')) != NULL) {
strncpy(name, envp, s - envp + 1);
strncpy_s(name, sizeof(name), envp, s - envp+1);
name[s - envp + 1+1] = 0;

if (_putenv(name) == -1) {
return -1;
}
}
else {
return -1;
}
}
return 0;
}
#if defined (WLB_DISABLE_DEBUG_ASSERT_POPUP_AT_EXIT) || defined(WLB_DISABLE_DEBUG_ASSERT_POPUP_AT_LAUNCH)
#if !defined(DisableDebugAssertPopup)

Expand Down
1 change: 1 addition & 0 deletions osfixes.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define WLB_DISABLE_DEBUG_ASSERT_POPUP_AT_LAUNCH
#define WLB_CONSTRUCTOR_SUPPORT
*/
int clearenv(void);
extern void DisableDebugAssertAtExit();
#if (defined(WLB_DISABLE_DEBUG_ASSERT_POPUP_AT_LAUNCH) || defined(WLB_DISABLE_DEBUG_ASSERT_POPUP_AT_EXIT)) && ! defined(WLB_CONSTRUCTOR_SUPPORT)
#define WLB_CONSTRUCTOR_SUPPORT
Expand Down

0 comments on commit 795a6aa

Please sign in to comment.