From bc12a4bf72a22e669e5bd14c491585eb461ba908 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Mon, 5 Sep 2022 21:45:21 -0700 Subject: [PATCH] Fix bug in ls for esp32. --- esp32/bindings.fs | 2 +- esp32/builtins.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/esp32/bindings.fs b/esp32/bindings.fs index 4749e84..2a209a2 100644 --- a/esp32/bindings.fs +++ b/esp32/bindings.fs @@ -15,7 +15,7 @@ ( Migrate various words to separate vocabularies, and constants ) forth definitions internals -: read-dir ( dh -- a n ) dup if errno else 0 then ; +: read-dir ( dh -- a n ) readdir dup if z>s else 0 then ; forth definitions vocabulary ESP ESP definitions diff --git a/esp32/builtins.h b/esp32/builtins.h index cfd901b..e5151f5 100644 --- a/esp32/builtins.h +++ b/esp32/builtins.h @@ -146,7 +146,8 @@ static cell_t ResizeFile(cell_t fd, cell_t size); X("OPEN-DIR", OPEN_DIR, memcpy(filename, a1, n0); filename[n0] = 0; \ n1 = (cell_t) opendir(filename); n0 = n1 ? 0 : errno) \ X("CLOSE-DIR", CLOSE_DIR, n0 = closedir((DIR *) n0); n0 = n0 ? errno : 0) \ - YV(internals, READDIR, SET readdir((DIR *) n0)->d_name) + YV(internals, READDIR, \ + struct dirent *ent = readdir((DIR *) n0); SET (ent ? ent->d_name: 0)) #ifndef ENABLE_LEDC_SUPPORT # define OPTIONAL_LEDC_SUPPORT