diff --git a/.gitignore b/.gitignore index a263d14..e54faa1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ xml-light-2.2.cvs20070817.tar.gz /xml-light-234.tar.gz +/xml-light-2.4.tar.gz diff --git a/README.md b/README.md new file mode 100644 index 0000000..bfb2d89 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# ocaml-xml-light + +[Xml-Light](http://tech.motion-twin.com/xmllight.html) is a minimal XML parser +& printer for OCaml. It provides functions to parse an XML document into +an OCaml data structure, work with it, and print it back to an XML document. +It also supports DTD parsing and checking, and is entirely written in OCaml; +hence it does not require a C library. diff --git a/ocaml-xml-light-hex-entities.patch b/ocaml-xml-light-hex-entities.patch new file mode 100644 index 0000000..dfc0487 --- /dev/null +++ b/ocaml-xml-light-hex-entities.patch @@ -0,0 +1,29 @@ +--- a/xml_lexer.mll ++++ b/xml_lexer.mll +@@ -123,6 +123,7 @@ let break = ['\r'] + let space = [' ' '\t'] + let identchar = ['A'-'Z' 'a'-'z' '_' '0'-'9' ':' '-'] + let entitychar = ['A'-'Z' 'a'-'z' '0'-'9'] ++let hexdigit = ['A'-'F' 'a'-'f' '0'-'9'] + let pcchar = [^ '\r' '\n' '<' '>' '&'] + let cdata_start = ['c''C']['d''D']['a''A']['t''T']['a''A'] + +@@ -280,14 +281,15 @@ and entity = parse + with + Not_found -> "&" ^ ident + } +- | '#' ['0'-'9']+ ';' +- { ++ | "#x" hexdigit+ ';' ++ | '#' ['0'-'9']+ ';' ++ { + let ident = lexeme lexbuf in + try + Hashtbl.find idents (String.lowercase ident) + with + Not_found -> "&" ^ ident +- } ++ } + | _ | eof + { raise (Error EUnterminatedEntity) } + diff --git a/ocaml-xml-light.spec b/ocaml-xml-light.spec index f017a90..b25d241 100644 --- a/ocaml-xml-light.spec +++ b/ocaml-xml-light.spec @@ -1,44 +1,33 @@ -%global opt %(test -x %{_bindir}/ocamlopt && echo 1 || echo 0) +%ifnarch %{ocaml_native_compiler} %global debug_package %{nil} - -%global svnrev 234 +%endif Name: ocaml-xml-light -Version: 2.3 -Release: 0.56.svn%{svnrev}%{?dist} +Version: 2.4 +Release: 1%{?dist} Summary: Minimal XML parser and printer for OCaml -License: LGPLv2+ +License: LGPLv2+ with exceptions URL: http://tech.motion-twin.com/xmllight.html - -# Upstream does not have releases (or rather, it did up to version 2.2 -# and then they stopped). Use the SVN repository here: -# https://code.google.com/p/ocamllibs/source/checkout -# -# To prepare a source release: -# (1) Adjust 'svnrev' above to the latest release. -# (2) Check out the sources: -# svn checkout http://ocamllibs.googlecode.com/svn/trunk/ ocamllibs -# (3) Create a tarball: -# cd ocamllibs/xml-light/ -# tar -zcf /tmp/xml-light-NNN.tar.gz --xform='s,^\.,xml-light-NNN,' . -# (where NNN is the svnrev above) -Source0: xml-light-%{svnrev}.tar.gz - - -BuildRequires: make +Source0: https://github.com/ncannasse/xml-light/archive/%{version}/xml-light-%{version}.tar.gz +Source1: https://raw.githubusercontent.com/ocaml/opam-repository/master/packages/xml-light/xml-light.%{version}/opam +# Fix parsing of hexadecimal entities +# See https://github.com/ncannasse/xml-light/issues/1 for background +# See https://github.com/ncannasse/xml-light/pull/6 for the patch +Patch0: %{name}-hex-entities.patch + +BuildRequires: make BuildRequires: ocaml >= 4.00.1 BuildRequires: ocaml-findlib-devel >= 1.3.3-3 BuildRequires: ocaml-ocamldoc -BuildRequires: gawk %description Xml-Light is a minimal XML parser & printer for OCaml. It provides functions to parse an XML document into an OCaml data structure, work -with it, and print it back to an XML document. It support also DTD -parsing and checking, and is entirely written in OCaml, hence it does -not require additional C library. +with it, and print it back to an XML document. It also supports DTD +parsing and checking, and is entirely written in OCaml; hence it does +not require a C library. %package devel @@ -52,7 +41,10 @@ developing applications that use %{name}. %prep -%setup -n xml-light-%{svnrev} +%autosetup -p1 -n xml-light-%{version} + +# Enable debuginfo +sed -i 's/[CL]FLAGS=/&-g/' Makefile %build @@ -60,7 +52,7 @@ developing applications that use %{name}. unset MAKEFLAGS make all make doc -%if %opt +%ifarch %{ocaml_native_compiler} make opt %endif sed -e 's/@VERSION@/%{VERSION}/' < META.in > META @@ -72,7 +64,7 @@ sed -e 's/@VERSION@/%{VERSION}/' < META.in > META EOF -%if %opt +%ifarch %{ocaml_native_compiler} ./test_opt.exe <<123/> @@ -83,28 +75,30 @@ EOF %install export DESTDIR=$RPM_BUILD_ROOT export OCAMLFIND_DESTDIR=$RPM_BUILD_ROOT%{_libdir}/ocaml -mkdir -p $OCAMLFIND_DESTDIR $OCAMLFIND_DESTDIR/stublibs +mkdir -p $OCAMLFIND_DESTDIR rm -f test.cmi ocamlfind install xml-light META *.mli *.cmi *.cma \ -%if %{opt} -*.a *.cmxa *.cmx +%ifarch %{ocaml_native_compiler} +*.a *.cmxa *.cmx *.cmxs %endif +cp -p %{SOURCE1} $OCAMLFIND_DESTDIR/xml-light %files %doc README -%{_libdir}/ocaml/xml-light -%if %opt -%exclude %{_libdir}/ocaml/xml-light/*.a -%exclude %{_libdir}/ocaml/xml-light/*.cmxa -%exclude %{_libdir}/ocaml/xml-light/*.cmx +%dir %{_libdir}/ocaml/xml-light +%{_libdir}/ocaml/xml-light/META +%{_libdir}/ocaml/xml-light/*.cma +%{_libdir}/ocaml/xml-light/*.cmi +%ifarch %{ocaml_native_compiler} +%{_libdir}/ocaml/xml-light/*.cmxs %endif -%exclude %{_libdir}/ocaml/xml-light/*.mli %files devel %doc README doc/* -%if %opt +%{_libdir}/ocaml/xml-light/opam +%ifarch %{ocaml_native_compiler} %{_libdir}/ocaml/xml-light/*.a %{_libdir}/ocaml/xml-light/*.cmxa %{_libdir}/ocaml/xml-light/*.cmx @@ -113,6 +107,12 @@ ocamlfind install xml-light META *.mli *.cmi *.cma \ %changelog +* Mon Dec 26 2021 Jerry James - 2.4-1 +- Version 2.4 +- New upstream URL +- Clarify that license includes the OCaml exception +- Add patch to fix parsing of hex entities + * Mon Oct 04 2021 Richard W.M. Jones - 2.3-0.56.svn234 - Bump release and rebuild. diff --git a/opam b/opam new file mode 100644 index 0000000..f700b01 --- /dev/null +++ b/opam @@ -0,0 +1,17 @@ +opam-version: "2.0" +maintainer: "https://github.com/ocaml/opam-repository/issues" +remove: ["ocamlfind" "remove" "xml-light"] +depends: ["ocaml" "ocamlfind"] +dev-repo: "git+https://github.com/ncannasse/xml-light" +install: [make "install_ocamlfind"] +synopsis: "Xml-Light is a minimal XML parser & printer for OCaml" +description: """ +It provide functions to parse an XML document into an OCaml data +structure, work with it, and print it back to an XML document. It +support also DTD parsing and checking, and is entirely written in +OCaml, hence it does not require additional C library.""" +flags: light-uninstall +url { + src: "https://github.com/ncannasse/xml-light/archive/2.4.tar.gz" + checksum: "md5=fe55697c13e867ced31ec79d5e33c7de" +} diff --git a/sources b/sources index 26103fe..55a27ed 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -1c02254c9f78ef8894b769d47112816d xml-light-234.tar.gz +SHA512 (xml-light-2.4.tar.gz) = 029068c6eb48cd1223438dc0f86e1c5e6fd0412d160ea4d79928eec5e5f5843af46260d7240e4260851e9580e7f92d578c764c63c8e0acab348637455493ef02