Skip to content

Commit

Permalink
Fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Melchizedek6809 committed Apr 26, 2024
1 parent 765c711 commit 6bf0605
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
33 changes: 17 additions & 16 deletions bin/environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
#include <unistd.h>
#endif

#if (defined(__MSYS__)) || (defined(__MINGW32__)) || (defined(_WIN32))
#include <windows.h>
#else
extern char **environ;
#endif

/* Add environment key/value pair to tree T */
static void addVar(const char *e, lMap *t){
int endOfKey, endOfString;
Expand All @@ -18,31 +24,26 @@ static void addVar(const char *e, lMap *t){
lMapSet(t, lValKeywordS(sym), v);
}

#if (defined(__MSYS__)) || (defined(__MINGW32__)) || (defined(_WIN32))
#include <windows.h>

/* Windows specific - add Environment args to `environment/variables` */
/* Add Environment args to `environment/variables` */
void lRedefineEnvironment(lClosure *c){
lTree *t = NULL;
lMap *t = lMapAllocRaw();

#if (defined(__MSYS__)) || (defined(__MINGW32__)) || (defined(_WIN32))
/* Windows */
LPCH env = GetEnvironmentStrings();
while(*env){
addVar(env,t);
while(*env++){}
}
lDefineClosureSym(c,lSymS("System/Environment"), lValMap(t));
}

#else
extern char **environ;
/* Add Environment args to `environment/variables` */
void lRedefineEnvironment(lClosure *c){
lMap *t = lMapAllocRaw();
#ifdef __wasi__
#elif defined(__wasi__)
/* Wasm */
addVar("PATH=",t); // Necessary so that tests don't fail
#endif
#else
/* Most other system, mainly *nix Systems */
for(int i=0;environ[i];i++){
addVar(environ[i], t);
}
#endif

lDefineClosureSym(c,lSymS("System/Environment"), lValMap(t));
}
#endif
6 changes: 1 addition & 5 deletions lib/imageReader.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@ static void readMapSet(readImageMap *map, i32 key, void *val){
lMapSet(map->map, lValInt(key), lValInt((u64)val));
}

static inline i32 readI8(const lImage *img, i32 off){
static i32 readI8(const lImage *img, i32 off){
return img->data[off ];
}

static inline i32 readI16(const lImage *img, i32 off){
return img->data[off ] | (img->data[off+1]<<8);
}

static i32 readI24(const lImage *img, i32 off){
return img->data[off ] | (img->data[off+1]<<8) | (img->data[off+2]<<16);
}
Expand Down

0 comments on commit 6bf0605

Please sign in to comment.