Skip to content

Commit

Permalink
xmlto: fix build with clang 16
Browse files Browse the repository at this point in the history
Fix implicit `int` on `main` and `static` declarations. Clang 16 reports
these as errors.
  • Loading branch information
reckenrode committed Jun 30, 2023
1 parent 7cb8db1 commit 1a39d22
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkgs/tools/typesetting/xmlto/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ fetchurl, lib, stdenv, libxml2, libxslt
, docbook_xml_dtd_45, docbook_xsl, w3m
, docbook_xml_dtd_45, docbook_xsl, flex, w3m
, bash, getopt, makeWrapper }:

stdenv.mkDerivation rec {
Expand All @@ -10,6 +10,9 @@ stdenv.mkDerivation rec {
sha256 = "0xhj8b2pwp4vhl9y16v3dpxpsakkflfamr191mprzsspg4xdyc0i";
};

# Implicit `int` is an error with clang 16.
patches = [ ./fix-implicit-int.patch ];

postPatch = ''
patchShebangs xmlif/test/run-test
Expand All @@ -23,7 +26,7 @@ stdenv.mkDerivation rec {

# `libxml2' provides `xmllint', needed at build-time and run-time.
# `libxslt' provides `xsltproc', used by `xmlto' at run-time.
nativeBuildInputs = [ makeWrapper getopt ];
nativeBuildInputs = [ makeWrapper flex getopt ];
buildInputs = [ libxml2 libxslt docbook_xml_dtd_45 docbook_xsl ];

postInstall = ''
Expand Down
21 changes: 21 additions & 0 deletions pkgs/tools/typesetting/xmlto/fix-implicit-int.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff -ur a/xmlif/xmlif.l b/xmlif/xmlif.l
--- a/xmlif/xmlif.l 2015-02-11 07:20:51.000000000 -0500
+++ b/xmlif/xmlif.l 2023-06-03 11:35:11.394139373 -0400
@@ -43,7 +43,7 @@

static char **selections; /* selection tokens */
static int nselections; /* number of selections */
-static ifsense; /* sense of last `if' or unless seen */
+static int ifsense; /* sense of last `if' or unless seen */
static char *attribute; /* last attribute scanned */

struct stack_t {
@@ -239,7 +239,7 @@

int yywrap() {exit(0);};

-main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
int i;

0 comments on commit 1a39d22

Please sign in to comment.