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 74586b9
Showing 1 changed file with 48 additions and 7 deletions.
55 changes: 48 additions & 7 deletions Library/Formula/confuse.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,62 @@
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

# fmemopen() implementation for systems which lack it is broken, sidestep the issue
# by not using it for the test case.
# https://github.com/libconfuse/libconfuse/issues/147
patch :p0, :DATA

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
__END__
--- tests/empty_string.c.orig 2024-02-07 00:08:37.000000000 +0000
+++ tests/empty_string.c 2024-02-09 00:14:12.000000000 +0000
@@ -23,7 +23,7 @@
cfg = cfg_init(opts, 0);
fail_unless(cfg_parse_buf(cfg, "string = ''") == CFG_SUCCESS);
fail_unless(strcmp(cfg_getstr(cfg, "string"), "") == 0);
- f = fmemopen(buf, sizeof(buf), "w+");
+ f = tmpfile();
fail_unless(f != NULL);
cfg_print(cfg, f);
cfg_free(cfg);

0 comments on commit 74586b9

Please sign in to comment.