Skip to content

Commit

Permalink
confuse 3.0
Browse files Browse the repository at this point in the history
Hold back to v3.0 since 3.1 onwards rely on fmemopen(3) and its
implementation for backwards compatibility with systems that lack it
e.g Tiger doesn't work.
libconfuse/libconfuse#147
  • Loading branch information
sevan committed Mar 28, 2024
1 parent 3c99b10 commit 73e2e53
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions Library/Formula/confuse.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
class Confuse < Formula
desc "Configuration file parser library written in C"
homepage "http://www.nongnu.org/confuse/"
url "http://savannah.nongnu.org/download/confuse/confuse-2.7.tar.gz"
sha256 "e32574fd837e950778dac7ade40787dd2259ef8e28acd6ede6847ca895c88778"
homepage "https://github.com/libconfuse/libconfuse"
url "https://github.com/libconfuse/libconfuse/releases/download/v3.0/confuse-3.0.tar.xz"
sha256 "bb75174e02aa8b44fa1a872a47beeea1f5fe715ab669694c97803eb6127cc861"
license "ISC"

bottle do
cellar :any
sha1 "1364f86a7dfa199fee07f273f6e3b4945b9db02a" => :yosemite
sha1 "d1edb26d0b30a9d85453cf811a5acf582dba3d56" => :mavericks
sha1 "9ede76f809eb464d96a8f703fb74c1678fc0c48d" => :mountain_lion
end

depends_on "pkg-config" => :build

def install
# Need unsetenv(3) to return int, not void
ENV.append_to_cflags "-D__DARWIN_UNIX03" if MacOS.version == :tiger
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make", "check"
system "make", "install"
end

test do
(testpath/"test.c").write <<~EOS
#include <confuse.h>
#include <stdio.h>
cfg_opt_t opts[] =
{
CFG_STR("hello", NULL, CFGF_NONE),
CFG_END()
};
int main(void)
{
cfg_t *cfg = cfg_init(opts, CFGF_NONE);
if (cfg_parse_buf(cfg, "hello=world") == CFG_SUCCESS)
printf("%s\\n", cfg_getstr(cfg, "hello"));
cfg_free(cfg);
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-lconfuse", "-o", "test"
assert_match "world", shell_output("./test")
end
end

0 comments on commit 73e2e53

Please sign in to comment.