2 # Adds the reference to the Glibc documentation and to the Linux manual page
3 # to the file foo.texi.
4 # Usage: add-links.sh foo.texi
12 if test -f _index.html \
13 ||
{ wget
-O _index1.html https
://www.gnu.org
/software
/libc
/manual
/html_node
/Function-Index.html \
14 && wget
-O _index2.html https
://www.gnu.org
/software
/libc
/manual
/html_node
/Variable-Index.html \
15 && cat _index1.html _index2.html
> _index.html
; \
17 glibc_page
=`sed -n -e "s|^.*<a href=\"\([^\"]*\)\"><code>$g</code></a>.*|\1|p" < _index.html | sed -s 's/#.*//'`
18 if test -n "$glibc_page"; then
19 glibc_page_title
=`wget -O - "https://www.gnu.org/software/libc/manual/html_node/$glibc_page" 2>/dev/null | sed -n -e 's/^.*<h[1-4][^>]*>[0-9. ]*\(.*\)<\/h.*/\1/p' | sed -e 's|<[^>]*>||g' -e 's|,||g' | head -n 1`
20 if test -n "$glibc_page_title"; then
21 glibc_node
=`echo "$glibc_page" | sed -e 's/\.html$//' -e 's/_/\\\\u/g' -e 's/\\u00\([0-7]\)/\\x\1/g' -e 's/-/ /g'`
22 # Avoid the broken built-in 'printf' in the dash shell.
23 glibc_node
=`/usr/bin/printf "$glibc_node" 2>/dev/null || printf "$glibc_node"`
24 glibc_inforef
="@ref{$glibc_node,,$glibc_page_title,libc}"
25 glibc_link
="@url{https://www.gnu.org/software/libc/manual/html_node/$glibc_page}"
27 echo "failed to determine page title of https://www.gnu.org/software/libc/manual/html_node/$glibc_page"
30 echo $f not documented
in glibc manual
33 echo "failed to fetch glibc index"
36 if wget https
://www.kernel.org
/doc
/man-pages
/online
/pages
/man
3/${g}.3.html
>/dev
/null
2>&1; then
37 manpages_link
="@uref{https://www.kernel.org/doc/man-pages/online/pages/man3/${g}.3.html,,man ${g}}"
39 if wget https
://www.kernel.org
/doc
/man-pages
/online
/pages
/man
2/${g}.2.html
>/dev
/null
2>&1; then
40 manpages_link
="@uref{https://www.kernel.org/doc/man-pages/online/pages/man2/${g}.2.html,,man ${g}}"
42 echo $f not documented among the man pages
45 if test -n "$glibc_link"; then
46 if test -n "$manpages_link"; then
47 documentation
="Documentation:\n\
60 documentation
="Documentation:@*\n\
69 if test -n "$manpages_link"; then
70 documentation
="Documentation:@* $manpages_link"
75 if test -n "$documentation"; then
77 if cat ${f}~ |
sed -e '/^Documentation:/,/^$/d' |
sed -e "s|^Gnulib module|$documentation\n\
79 Gnulib module|" > ${f}; then
87 *) echo "invalid argument: $1" 1>&2 ;;