yelp-3.20.0-man-compatibility.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. From b7f00d9fc5f4c948b3b412fa22488517e71a2987 Mon Sep 17 00:00:00 2001
  2. From: Alexandre Rostovtsev <tetromino@gmail.com>
  3. Date: Sun, 27 Mar 2016 17:11:59 +0200
  4. Subject: [PATCH] Enable compatibility with traditional man (#648854)
  5. As of commit 46a82ade3e6f0fac8f08b18e7fc23d8665f6f728, Yelp runs
  6. "man -Z -Tutf8 -EUTF-8 [FILE]" to obtain the groff intermediate format
  7. of the man page. However, the only implementation of man that accepts
  8. these options is man-db (used by Debian, Fedora, SUSE & Ubuntu).
  9. The traditional Linux man used by other distros and man implementations
  10. on non-Linux Unixes (FreeBSD, Solaris) do not have command-line options
  11. for outputting groff intermediate format.
  12. Therefore, on systems that do not use man-db, we need to manually
  13. uncompress the nroff source file and feed it to groff. This is best done
  14. using a small shell script (/usr/libexec/yelp-groff), both for for
  15. clarity and for ease of modification on systems with weird man setups.
  16. Signed-off-by: Alexandre Rostovtsev <tetromino@gmail.com>
  17. Signed-off-by: Ole Reifschneider <tranquility@gentoo.org>
  18. ---
  19. Makefile.am | 2 ++
  20. libyelp/yelp-groff | 49 +++++++++++++++++++++++++++++++++++++++++++++++
  21. libyelp/yelp-man-parser.c | 2 +-
  22. 3 files changed, 52 insertions(+), 1 deletion(-)
  23. create mode 100755 libyelp/yelp-groff
  24. diff --git a/Makefile.am b/Makefile.am
  25. index 30eba2c..b87f2b2 100644
  26. --- a/Makefile.am
  27. +++ b/Makefile.am
  28. @@ -6,6 +6,7 @@ BUILT_SOURCES = \
  29. $(nodist_libyelp_libyelp_la_SOURCES)
  30. lib_LTLIBRARIES = libyelp/libyelp.la
  31. +libexec_SCRIPTS = libyelp/yelp-groff
  32. libyelp_libyelp_la_SOURCES = \
  33. libyelp/yelp-bookmarks.c \
  34. @@ -58,6 +59,7 @@ libyelp_libyelp_la_CFLAGS = \
  35. libyelp_libyelp_la_CPPFLAGS = \
  36. -DDATADIR=\""$(datadir)"\" \
  37. + -DLIBEXECDIR=\"$(libexecdir)\" \
  38. -DYELP_ICON_PATH=\"$(YELP_ICON_PATH)\" \
  39. -DYELP_WEB_EXTENSIONS_DIR=\""$(pkglibdir)/"web-extensions\" \
  40. -I$(top_builddir)/libyelp
  41. diff --git a/libyelp/yelp-groff b/libyelp/yelp-groff
  42. new file mode 100755
  43. index 0000000..5348024
  44. --- /dev/null
  45. +++ b/libyelp/yelp-groff
  46. @@ -0,0 +1,49 @@
  47. +#!/bin/sh
  48. +#
  49. +# Copyright (c) 2011 Alexandre Rostovtsev <tetromino@gmail.com>
  50. +#
  51. +# This program is free software; you can redistribute it and/or
  52. +# modify it under the terms of the GNU General Public License as
  53. +# published by the Free Software Foundation; either version 2 of the
  54. +# License, or (at your option) any later version.
  55. +#
  56. +# This program is distributed in the hope that it will be useful,
  57. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  58. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  59. +# General Public License for more details.
  60. +#
  61. +# You should have received a copy of the GNU General Public
  62. +# License along with this program; if not, write to the
  63. +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  64. +# Boston, MA 02110-1301, USA.
  65. +#
  66. +###
  67. +#
  68. +# Process the requested compressed source nroff file and output groff
  69. +# intermediate format.
  70. +#
  71. +
  72. +filename=$1
  73. +
  74. +if [ -z ${filename} ] ; then
  75. + echo "Usage: yelp-groff [FILE]" >&2
  76. + echo "Process a man FILE and output groff intermediate format."
  77. + exit 1
  78. +fi
  79. +
  80. +# If "man -Z -Tutf8 -EUTF-8" works (i.e. if man is man-db), use that.
  81. +man -Z -Tutf8 -EUTF-8 ${filename} 2>/dev/null && exit 0
  82. +
  83. +# Otherwise, manually uncompress the file ...
  84. +cat="cat"
  85. +case ${filename} in
  86. + *.bz2) cat="bzip2 -c -d" ;;
  87. + *.gz) cat="gunzip -c" ;;
  88. + *.lzma) cat="unlzma -c -d" ;;
  89. + *.xz) cat="unxz -c" ;;
  90. + *.Z) cat="zcat" ;;
  91. +esac
  92. +
  93. +# ... and run groff to get the intermediate format; preprocess with tbl
  94. +# unless MANROFFSEQ is defined.
  95. +${cat} ${filename} | groff -${MANROFFSEQ:-t} -man -Z -Tutf8
  96. diff --git a/libyelp/yelp-man-parser.c b/libyelp/yelp-man-parser.c
  97. index 46073a2..792e695 100644
  98. --- a/libyelp/yelp-man-parser.c
  99. +++ b/libyelp/yelp-man-parser.c
  100. @@ -369,7 +369,7 @@ get_troff (gchar *path, GError **error)
  101. {
  102. gint ystdout;
  103. GError *err = NULL;
  104. - const gchar *argv[] = { "man", "-Z", "-Tutf8", "-EUTF-8", path, NULL };
  105. + const gchar *argv[] = { LIBEXECDIR "/yelp-groff", path, NULL };
  106. gchar **my_argv;
  107. /* g_strdupv() should accept a "const gchar **". */
  108. --
  109. 2.7.4