80 lines
2.4 KiB
Ruby
80 lines
2.4 KiB
Ruby
class Expat < Formula
|
|
desc "XML 1.0 parser"
|
|
homepage "https://libexpat.github.io/"
|
|
url "https://github.com/libexpat/libexpat/releases/download/R_2_2_10/expat-2.2.10.tar.xz"
|
|
sha256 "5dfe538f8b5b63f03e98edac520d7d9a6a4d22e482e5c96d4d06fcc5485c25f2"
|
|
license "MIT"
|
|
|
|
livecheck do
|
|
url :stable
|
|
strategy :github_latest
|
|
regex(/href=.*?expat[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_big_sur: "5e3abf13602731bb6eb80eb0cb5fd4acb0bfe24e561f7a608b6c92b7c7c5b4a9"
|
|
sha256 cellar: :any, big_sur: "bdc39dc9c66e5efa771a59842102be8f35e8bab1f11f2b2353af0d986df95ec0"
|
|
sha256 cellar: :any, catalina: "1a8b10b3ce11187fbc9d26013ac5939d69f53ad7e0768ecb3d026ae6007005ac"
|
|
sha256 cellar: :any, mojave: "0715be3a1c1f7472cb662c640b263ed8c78da9cc20ebadb3f8df40e2300a87a8"
|
|
sha256 cellar: :any, high_sierra: "f1d65a87a4535918db8fb7cae639335e70e0a0ac780a000f5ddb4685a47526e2"
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/libexpat/libexpat.git"
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "docbook2x" => :build
|
|
depends_on "libtool" => :build
|
|
end
|
|
|
|
keg_only :provided_by_macos
|
|
|
|
def install
|
|
cd "expat" if build.head?
|
|
system "autoreconf", "-fiv" if build.head?
|
|
args = ["--prefix=#{prefix}", "--mandir=#{man}"]
|
|
args << "--with-docbook" if build.head?
|
|
system "./configure", *args
|
|
system "make", "install"
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.c").write <<~EOS
|
|
#include <stdio.h>
|
|
#include "expat.h"
|
|
|
|
static void XMLCALL my_StartElementHandler(
|
|
void *userdata,
|
|
const XML_Char *name,
|
|
const XML_Char **atts)
|
|
{
|
|
printf("tag:%s|", name);
|
|
}
|
|
|
|
static void XMLCALL my_CharacterDataHandler(
|
|
void *userdata,
|
|
const XML_Char *s,
|
|
int len)
|
|
{
|
|
printf("data:%.*s|", len, s);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
static const char str[] = "<str>Hello, world!</str>";
|
|
int result;
|
|
|
|
XML_Parser parser = XML_ParserCreate("utf-8");
|
|
XML_SetElementHandler(parser, my_StartElementHandler, NULL);
|
|
XML_SetCharacterDataHandler(parser, my_CharacterDataHandler);
|
|
result = XML_Parse(parser, str, sizeof(str), 1);
|
|
XML_ParserFree(parser);
|
|
|
|
return result;
|
|
}
|
|
EOS
|
|
system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lexpat", "-o", "test"
|
|
assert_equal "tag:str|data:Hello, world!|", shell_output("./test")
|
|
end
|
|
end
|