if-elsebut that's just what
ifs like an idiot...
Yeah kind of! What sparked this was I was investigating sdiff, which is a nice tool for interactively applying hunks from diffs to a file, but it had two downsides:
So I wanted to write a sort of "modern sdiff". I peeked into the code a bit and it turns out sdiff just shells out to diff to perform the diffing between two files, using popen(). I realized we didn't have this in core, plus a couple of other libc functions so I figured it might be useful to wrap them, e.g.
(register popen (Fn [(Ptr CChar) (Ptr CChar)] (Ptr FILE))) (register pclose (Fn [(Ptr FILE)] Int)) (register fgets (Fn [(Ptr CChar) Int (Ptr FILE)] (Ptr CChar))) (register PATH_MAX Int) (defn main  (let [fp (popen (cstr "ls *") (cstr "r")) path (cstr &(String.allocate PATH_MAX \a)) status 0] (do (while (not-null? (fgets path PATH_MAX fp)) (IO.println &(from-cstr path))) (set! status (pclose fp)) (if (= status -1) (IO.println "error!") (System.exit 0)))) )
&(String.allocate PATH_MAX \a)to just allocate an empty string w/o filling with arbitrary characters?
static_assertmacro will only take a string literal, but because carp manages strings it tends to output a variable name in the literal position, e.g.
(Libc.Assert.static-assert 0 (cstr "foo")) out/main.c:9445:22: error: expected string literal for diagnostic message in static_assert static_assert(0, _8);
static_assert, then use it with the literal directly
(static-assert "my literal")it get emitted as
static_assert("my literal"). Are you saying it it emits
"char* v1 = "my literal"; static_assert(v1);?