From d32ef0530b79b2e0870c4fae53e587928952d95e Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Mon, 15 Jan 2024 13:51:55 +0100 Subject: [PATCH] fix writing to binary port --- dist/std.min.scm | 2 +- dist/std.scm | 4 +++- dist/std.xcb | Bin 93842 -> 93921 bytes lib/R5RS.scm | 4 +++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index f397fef8b..834f02b0a 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -232,7 +232,7 @@ (define (char-upper-case? char) "(char-upper-case? char)\u000A\u000AChecks if character is upper case." (typecheck "char-upper-case?" char "character") (and (char-alphabetic? char) (char=? (char-upcase char) char))) (define (char-lower-case? char) "(char-upper-case? char)\u000A\u000AChecks if character is lower case." (typecheck "char-lower-case?" char "character") (and (char-alphabetic? char) (char=? (char-downcase char) char))) (define (newline . rest) "(newline [port])\u000A\u000AWrite newline character to standard output or given port" (let ((port (if (null? rest) (current-output-port) (car rest)))) (display "\u000A" port))) -(define (write obj . rest) "(write obj [port])\u000A\u000AWrite object to standard output or give port. For strings it will include\u000Awrap in quotes." (let ((port (if (null? rest) (current-output-port) (car rest)))) (display (repr obj #t) port))) +(define (write obj . rest) "(write obj [port])\u000A\u000AWrite object to standard output or give port. For strings it will include\u000Awrap in quotes." (let ((port (if (null? rest) (current-output-port) (car rest)))) (if (binary-port? port) (display obj port) (display (repr obj #t) port)))) (define (write-char char . rest) "(write-char char [port])\u000A\u000AWrite single character to given port using write function." (typecheck "write-char" char "character") (if (not (null? rest)) (typecheck "write-char" (car rest) "output-port")) (apply display (cons (char.valueOf) rest))) (define fold-right reduce) (define fold-left fold) diff --git a/dist/std.scm b/dist/std.scm index 8e168642b..dc2fd9896 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -2675,7 +2675,9 @@ Write object to standard output or give port. For strings it will include wrap in quotes." (let ((port (if (null? rest) (current-output-port) (car rest)))) - (display (repr obj true) port))) + (if (binary-port? port) + (display obj port) + (display (repr obj true) port)))) ;; ----------------------------------------------------------------------------- (define (write-char char . rest) diff --git a/dist/std.xcb b/dist/std.xcb index 1e413641ccbf9c3e8322135fee00ab2a878e4b31..1542737265106b5ea3e96636308dee93fea61c28 100644 GIT binary patch delta 939 zcmXBSU1%It7zW_8yWiTg>!jHvvtdb^_fjw3KjVR(mc4rXkd7nOWOKW-V#S z+=)vtd@LtY#aib3{NM%a7wPugFph6Vd*C?0xFIU9(t(-F(4Jc&ZlKD6%9Ph!kGu#c z0ieBp88Wk6c3QTKf@X`Jn-p!!l}G(*Eq0bB94oY$CCjE0uo+%^JN0w&9ayNh8{u~M zJz^|!*ReBRN)(FZtcD)5KMAZbz$037dQ8xLwH&;2A4q-n^e1;2$I41|=)%ar`3!9O@(L~8s!l)g_6`_hqB(hRjts-F# zD>12j%;GdhcoYTk(XZnOeo!zQg(Abwx`RGbag)%HK8!9$Rb;Q|^U5W=O@*;1Q`y=T zc%$xMIVq-UsYcquJx2X%;9#p^Nfutw`V2PZdFEvDbNDfOL+JkU>RPwH`K)1g#`a$m_qb6wiVO~ z9I7zWi&e(RL$$75eDAeIt&;H+acBSLzlKsFjsO4v delta 859 zcmWNPU1%It6vyvo&op<}iEcK#n`M(GSF>xjnAs#dqphVMiHXIug=nKvOoO>Qb7yBZ zcW2g_JL|62E=C`U7LkN%g%m`@k0&XjAW;!PQ3P%4(+U*@5kCq(2`c??-p<20{13n1 z|K}^x#uX`kbm74zLZ+iP=!N*!x1DOqD4fItJsXYmw(dS89i3eNdvrxT|7z{ESfJ=V zAIQFH$nsp~5olyvn1Q3O3fpx`@)JN+ zWQ%r#=@!%UH94&vKL?YVoz7Za<*CYD1-;|A-;F)GtYtogWz}xIfXC++_rZ|1<_5i2 zm46zphfcu?01N@lsEjrmd|*M%Rtoj182*(#wXG34^pm!kpTx6k zs7}|I(qwvGxS3a|v-_u)iV<=ramcc1bHrD6#p81x>!Hz2LW#qk+(G0+(T{}{ZXi}~ zh&Ew79GD~g62S{5f!)OR3GzcEwrMly7-aBIpNTjH&a;!mHHpYuEVU$DbSo7V5<61r zz6;v`>Z;C}=w@%j17`TUA8?XUbsUDu1(nTu*F2j39DbJ$rvMIyz|_irFY1bNpc~+G z>b{o^3Cknc)t}dC`lJ!wqwSli4d`Gzmc1X6DUfsbeqXEhojxd6)YPv~(s1iQF)>1% zU2zmY#zf#bJ|e;k7_rT0->URR$VG&H2z3l%QhtYzcRH>pJZ<@(2`_BN{)7dOpHYq8 z_4yW~Uaa*_8Ffc{%{|*Sxph(Tn3*`VUq{KrE&on@y|;*R=uMc|F?soJNT%;`HHnvjfkh}J&!%`M(y diff --git a/lib/R5RS.scm b/lib/R5RS.scm index 150ef8dd2..fbd05997c 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -1104,7 +1104,9 @@ Write object to standard output or give port. For strings it will include wrap in quotes." (let ((port (if (null? rest) (current-output-port) (car rest)))) - (display (repr obj true) port))) + (if (binary-port? port) + (display obj port) + (display (repr obj true) port)))) ;; ----------------------------------------------------------------------------- (define (write-char char . rest)