From 01748d2b179a40f542e5a3fde352b318b532e0af Mon Sep 17 00:00:00 2001 From: Yogthos Date: Mon, 22 Jun 2026 12:15:14 -0400 Subject: [PATCH] System/getProperty os.name reflects the real platform (was hardcoded Mac OS X) Derive os.name from Chez's machine-type (*osx -> Mac OS X, else Linux/Windows). OS-branching code (socket sockaddr layout, etc.) needs the truth; a library binding sockets via jolt.ffi reads os.name to pick the platform struct layout. --- host/chez/host-static.ss | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/host/chez/host-static.ss b/host/chez/host-static.ss index 57a081c..6ca69dd 100644 --- a/host/chez/host-static.ss +++ b/host/chez/host-static.ss @@ -238,8 +238,21 @@ (make-jhost "class" (list (cons 'name nm)))))))) ;; ---- System helpers (defined before use above via top-level order) ---------- +;; os.name reflects the actual platform (Chez's machine-type names it): a *osx +;; machine is macOS, otherwise Linux. Code that branches on the OS (socket struct +;; layout, path handling) needs the truth, not a fixed value. +(define (substring-index needle hay) + (let ((nl (string-length needle)) (hl (string-length hay))) + (let loop ((i 0)) (cond ((> (+ i nl) hl) #f) + ((string=? (substring hay i (+ i nl)) needle) i) + (else (loop (+ i 1))))))) +(define sys-os-name + (let ((m (symbol->string (machine-type)))) + (cond ((or (substring-index "osx" m) (substring-index "macos" m)) "Mac OS X") + ((or (substring-index "nt" m) (substring-index "windows" m)) "Windows") + (else "Linux")))) (define (sys-get-property k . dflt) - (cond ((string=? k "os.name") "Mac OS X") + (cond ((string=? k "os.name") sys-os-name) ((string=? k "line.separator") "\n") ((string=? k "file.separator") "/") ((string=? k "path.separator") ":") @@ -249,7 +262,7 @@ ((pair? dflt) (car dflt)) (else jolt-nil))) (define (sys-properties-map) - (jolt-hash-map "os.name" "Mac OS X" "line.separator" "\n" "file.separator" "/" + (jolt-hash-map "os.name" sys-os-name "line.separator" "\n" "file.separator" "/" "user.dir" (or (getenv "PWD") ".") "user.home" (or (getenv "HOME") "") "java.io.tmpdir" (or (getenv "TMPDIR") "/tmp")))