commit:     1a48b2360b0be82bd6f2c828142859235c44a0b3
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 15 17:21:00 2019 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun Dec 15 17:21:00 2019 +0000
URL:        https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=1a48b236

bin/gen-eclass-html.sh: Fix regexp for link substitution.

The previous regexp was too greedy and combined several links into
one, if they were on the same line.

Remove dead relative links (i.e., not pointing to other eclasses).

Replace the complicated "tail" command by a simple "1,4d" in sed.
This also makes the temporary file unnecessary.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 bin/gen-eclass-html.sh | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh
index 5ccfc71..b557093 100755
--- a/bin/gen-eclass-html.sh
+++ b/bin/gen-eclass-html.sh
@@ -98,20 +98,17 @@ for i in $(/usr/bin/qlist eclass-manpages) 
/usr/share/man/man5/ebuild.5*; do
        BASENAME="${FILEBASE%.5*}"
        [[ ${BASENAME} != "${FILEBASE}" ]] || continue
        DIRNAME="${OUTPUTDIR}/${BASENAME}"
-       TMP="${DIRNAME}/index.html.tmp"
        FINAL="${DIRNAME}/index.html"
        DECOMPRESS=$(guesscompress "${i}")
        [[ -d ${DIRNAME} ]] || mkdir -p ${DIRNAME}
        # rebuild the man page each time
        echo -n "${HEADER//@TITLE@/${BASENAME}}" > "${FINAL}"
-    # generate html pages and fix hyperlinks for eclass and ebuild man pages
-    $DECOMPRESS "$i" | /usr/bin/man2html -r - | \
-    sed -e "/<A HREF=/s:=.*man.*/\(.*eclass\).*html\">:=../\1/index.html>:" \
-    -e "/<\/BODY>/d" -e "/<\/HTML>/d"  \
-    -e "/<A HREF=/s:=.*man.*/\(.*ebuild\).*html\">:=../\1/\index.html>:" >> 
${TMP}
-       # The first 4 lines are cruft for devmanual
-       tail -n $(($(wc -l ${TMP} | awk '{print $1}') - 4)) ${TMP} >> ${FINAL}
-       rm -f ${TMP}
+       # generate html pages and fix hyperlinks for eclass and ebuild man pages
+       ${DECOMPRESS} "${i}" | /usr/bin/man2html -r - \
+       | sed -e "1,4d;/<\/BODY>/d;/<\/HTML>/d" \
+               -e '/<A 
HREF=/s:"\.\./man5/\([^"]*eclass\|ebuild\)\.5\.html":"../\1/index.html":g' \
+               -e 's:<A HREF="\.\./man[^"]*">\([^<>]*\)</A>:\1:g' \
+               >> "${FINAL}"
        echo -n "${FOOTER}" >> "${FINAL}"
 done
 

Reply via email to