~ chicken-core (chicken-5) d3a304ef69d067ea490a357b873ab438b42d003e
commit d3a304ef69d067ea490a357b873ab438b42d003e Author: Mario Domenech Goulart <mario@parenteses.org> AuthorDate: Mon Aug 22 22:20:04 2022 +0200 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Tue Aug 23 10:54:18 2022 +0200 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. Signed-off-by: felix <felix@call-with-current-continuation.org> 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 lenTrap