>From 84ad1f64aa90fe61ce3b794468c17f6986d1965e Mon Sep 17 00:00:00 2001 From: Mario Domenech Goulart Date: Mon, 22 Aug 2022 22:20:04 +0200 Subject: [PATCH] Make C_curdir get the buffer size as argument Make C_curdir get the buffer size as argument, so that it can be used in the call to getcwd. Also replace the hardcoded value (1024) with the value of C_MAX_PATH for the maximum buffer size in the call to C_curdir. --- library.scm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library.scm b/library.scm index a8103a47..9fc663e0 100644 --- a/library.scm +++ b/library.scm @@ -5883,7 +5883,7 @@ EOF #> #define C_chdir(str) C_fix(chdir(C_c_string(str))) -#define C_curdir(buf) (getcwd(C_c_string(buf), 1024) ? C_fix(strlen(C_c_string(buf))) : C_SCHEME_FALSE) +#define C_curdir(buf, size) (getcwd(C_c_string(buf), size) ? C_fix(strlen(C_c_string(buf))) : C_SCHEME_FALSE) #define C_getenventry(i) (environ[ i ]) #ifdef HAVE_CRT_EXTERNS_H @@ -5949,8 +5949,9 @@ static C_word C_fcall C_setenv(C_word x, C_word y) { (define current-directory (getter-with-setter (lambda () - (let* ((buffer (make-string 1024)) - (len (##core#inline "C_curdir" buffer))) + (let* ((buffer-size (foreign-value "C_MAX_PATH" size_t)) + (buffer (make-string buffer-size)) + (len (##core#inline "C_curdir" buffer buffer-size))) (unless ##sys#windows-platform ; FIXME need `cond-expand' here (##sys#update-errno)) (if len -- 2.30.2