File 0883-erl_docgen-Fix-codeinclude.patch of Package erlang

From 2fea265c8461b0345d40bb36def3002bb393aadc Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Mon, 31 Jan 2022 11:40:41 +0100
Subject: [PATCH] erl_docgen: Fix codeinclude

The regexp for finding <codeinclude> did not take into
consideration that elements in xml do not need to have
a closing tag. We shouldn't really try parsing xml with
regexp, but we try to make the best of the situation.

This commit also removed codeinclude from the dtd so that
at least in the future if any other codeinclude falls through
the regexp matching the xmllint will catch it.

Closes #5662
---
 lib/erl_docgen/doc/src/Makefile                             | 6 +++++-
 .../doc/src/{block_tags.xml => block_tags.xmlsrc}           | 2 +-
 lib/erl_docgen/priv/bin/codeline_preprocessing.escript      | 2 +-
 lib/erl_docgen/priv/dtd/common.dtd                          | 2 +-
 4 files changed, 8 insertions(+), 4 deletions(-)
 rename lib/erl_docgen/doc/src/{block_tags.xml => block_tags.xmlsrc} (99%)

diff --git a/lib/erl_docgen/doc/src/Makefile b/lib/erl_docgen/doc/src/Makefile
index bf6fd9d2a5..143a421cd2 100644
--- a/lib/erl_docgen/doc/src/Makefile
+++ b/lib/erl_docgen/doc/src/Makefile
@@ -47,14 +47,18 @@ XML_CHAPTER_FILES = \
 	inline_tags.xml \
 	header_tags.xml \
 	character_entities.xml \
-	block_tags.xml \
 	doc_storage.xml
 
+XML_CHAPTER_GEN_FILES = \
+	block_tags.xml
+
 BOOK_FILES = book.xml
 
 XML_FILES = $(BOOK_FILES) $(XML_APPLICATION_FILES) $(XML_REF6_FILES) \
             $(XML_PART_FILES) $(XML_CHAPTER_FILES) 
 
+XML_GEN_FILES = $(XML_CHAPTER_GEN_FILES:%=$(XMLDIR)/%)
+
 TECHNICAL_DESCR_FILES = 
 
 EXAMPLE_FILES = \
diff --git a/lib/erl_docgen/doc/src/block_tags.xml b/lib/erl_docgen/doc/src/block_tags.xmlsrc
similarity index 99%
rename from lib/erl_docgen/doc/src/block_tags.xml
rename to lib/erl_docgen/doc/src/block_tags.xmlsrc
index a2c1310cd0..a3e59c1b6f 100644
--- a/lib/erl_docgen/doc/src/block_tags.xml
+++ b/lib/erl_docgen/doc/src/block_tags.xmlsrc
@@ -27,7 +27,7 @@
     <docno/>
     <date/>
     <rev/>
-    <file>block_tags.xml</file>
+    <file>block_tags.xmlsrc</file>
   </header>
 
   <p>Block tags typically define a separate block of information, such
diff --git a/lib/erl_docgen/priv/bin/codeline_preprocessing.escript b/lib/erl_docgen/priv/bin/codeline_preprocessing.escript
index 1a87f2307c..8195dfa743 100755
--- a/lib/erl_docgen/priv/bin/codeline_preprocessing.escript
+++ b/lib/erl_docgen/priv/bin/codeline_preprocessing.escript
@@ -77,7 +77,7 @@ parse(InDev, OutDev, CPath) ->
 
 
 parse_line(CPath, Line) ->
-    case re:run(Line, "<codeinclude([^>]*)>.*</codeinclude>", [{capture, [1], list}]) of
+    case re:run(Line, "<codeinclude(.*)(>.*</codeinclude>|/>)", [{capture, [1], list}]) of
         {match,[Attributes]} ->
             File =
                 case re:run(Attributes,"file=\"([^\"]+)\"",[{capture, [1], list}]) of
diff --git a/lib/erl_docgen/priv/dtd/common.dtd b/lib/erl_docgen/priv/dtd/common.dtd
index cc186fe5d6..9f5bdc50b8 100644
--- a/lib/erl_docgen/priv/dtd/common.dtd
+++ b/lib/erl_docgen/priv/dtd/common.dtd
@@ -24,7 +24,7 @@
 
 <!ENTITY % refs               "seemfa|seeerl|seetype|seeapp|seecom|seecref|seefile|seeguide|url" >
 
-<!ENTITY % block              "p|pre|code|list|taglist|codeinclude" >
+<!ENTITY % block              "p|pre|code|list|taglist" >
 <!ENTITY % inline             "#PCDATA|c|i|em|strong|term|br|%refs;|
                                marker|anno|image" >
 <!-- XXX --> 
-- 
2.34.1

openSUSE Build Service is sponsored by