From 3ff6dcaa7469ac2885be7bbd8ae74a8a105f5ddf Mon Sep 17 00:00:00 2001 From: alex-eg Date: Fri, 9 Oct 2026 18:12:51 +0300 Subject: [PATCH] drop the blocks around case bodies, and size block codes by type A case body that declares is its own block now (sex#51), and sizeof takes a pointer type (sex#52). Co-Authored-By: Claude Opus 5.5 --- src/save.sex | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/save.sex b/src/save.sex index 6f2a36d..5c9c071 100644 --- a/src/save.sex +++ b/src/save.sex @@ -79,21 +79,17 @@ (switch type (case 1 (snprintf value 64 "%d" (cast (read-le (& r) 4) i32)) (break)) (case 2 (snprintf value 64 "%lld" (cast (read-le (& r) 8) i64)) (break)) - ;; TODO sex#51: drop the (do ...) around case bodies once each - ;; case gets its own scope. (case 3 - (do - (var bits u64 (read-le (& r) 8)) - (var d double) - (memcpy (& d) (& bits) 8) - (snprintf value 64 "%.17g" d)) + (var bits u64 (read-le (& r) 8)) + (var d double) + (memcpy (& d) (& bits) 8) + (snprintf value 64 "%.17g" d) (break)) (case 4 - (do - (var bits u32 (cast (read-le (& r) 4) u32)) - (var f float) - (memcpy (& f) (& bits) 4) - (snprintf value 64 "%.9g" (cast f double))) + (var bits u32 (cast (read-le (& r) 4) u32)) + (var f float) + (memcpy (& f) (& bits) 4) + (snprintf value 64 "%.9g" (cast f double)) (break)) (case 5 (add-config s key (read-dotnet-string (& r))) @@ -128,9 +124,7 @@ (if (> id max-id) (= max-id id))) (.skip (& entry) wire)))) (= (. s block-count) (+ max-id 1)) - ;; TODO sex#52: write (sizeof (* char)) once sizeof takes a pointer - ;; type. - (= (. s block-codes) (calloc (+ max-id 1) (sizeof [(. s block-codes) 0]))) + (= (. s block-codes) (calloc (+ max-id 1) (sizeof (* char)))) (while (> (.field (& r) (& wire)) 0) (var entry pb (.bytes (& r))) (var id int -1)