18 lines
736 B
Plaintext
18 lines
736 B
Plaintext
;;;; A NUL as a string's last byte, handed to C. Only a literal crosses
|
|
;;;; uncopied, and only because the checker marks it at the call; a string that
|
|
;;;; merely ends in a NUL is copied like any other, and the NUL inside it is
|
|
;;;; refused. Each argument is one way to spell such a string, and each is
|
|
;;;; refused naming the call.
|
|
(declare-c c-puts [s str] i32 "puts")
|
|
|
|
(defn main [args [str]] i32
|
|
(let [which (if (> (length args) 1) (bytes->i64 (bytes-view (at args 1))) 0)]
|
|
(println "before")
|
|
(cond
|
|
(= which 1) (let [s "ab\0"] (c-puts s))
|
|
(= which 2) (c-puts (str (slice (bytes-view "ab\0c") 0 3)))
|
|
(= which 3) (c-puts (str (bytes "q\0")))
|
|
:else (c-puts "ab\0"))
|
|
(println "unreachable"))
|
|
0)
|