8 Commits

Author SHA256 Message Date
faae54ec78 Improve .gitignore 2025-04-09 15:48:14 +02:00
a3e219da52 Accepting request 1173641 from Documentation
- Add /usr/lib/rpm/lua/mandoc.lua and use it for processing man
  pages in the trigger scripts, making processing of packages
  with many man pages (see OpenSSL for an example) significantly
  faster.

OBS-URL: https://build.opensuse.org/request/show/1173641
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/mandoc?expand=0&rev=10
2024-05-14 11:37:26 +00:00
1430f5bedf - Add /usr/lib/rpm/lua/mandoc.lua and use it for processing man
pages in the trigger scripts, making processing of packages
  with many man pages (see OpenSSL for an example) significantly
  faster.

OBS-URL: https://build.opensuse.org/package/show/Documentation/mandoc?expand=0&rev=22
2024-05-13 11:45:38 +00:00
8b57b63b4c Accepting request 1173636 from home:lnussel:branches:Documentation
ok

OBS-URL: https://build.opensuse.org/request/show/1173636
OBS-URL: https://build.opensuse.org/package/show/Documentation/mandoc?expand=0&rev=21
2024-05-13 11:18:25 +00:00
9605b1b5bc Accepting request 1103482 from Documentation
Automatic submission by obs-autosubmit

OBS-URL: https://build.opensuse.org/request/show/1103482
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/mandoc?expand=0&rev=9
2023-08-11 13:55:22 +00:00
e405521c75 Add missing #
OBS-URL: https://build.opensuse.org/package/show/Documentation/mandoc?expand=0&rev=19
2023-08-04 11:55:31 +00:00
ad11f4b37b Accepting request 1091826 from Documentation
- Add boo1209830-endless-loop.patch (boo1209830) avoid endless
  loop on processing some mandoc files.

OBS-URL: https://build.opensuse.org/request/show/1091826
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/mandoc?expand=0&rev=8
2023-06-11 17:52:44 +00:00
2175b7cd4e - Add boo1209830-endless-loop.patch (boo1209830) avoid endless
loop on processing some mandoc files.

OBS-URL: https://build.opensuse.org/package/show/Documentation/mandoc?expand=0&rev=17
2023-06-09 17:41:39 +00:00
5 changed files with 182 additions and 45 deletions

4
.gitignore vendored
View File

@@ -1 +1,5 @@
.osc
_scmsync.obsinfo
.assets/
_buildconfig-*
_buildinfo-*.xml

View File

@@ -0,0 +1,80 @@
===================================================================
RCS file: /cvsrepo/anoncvs/cvs/a/out.c,v
retrieving revision 1.54
retrieving revision 1.55
---
out.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
--- a/out.c
+++ b/out.c
@@ -1,4 +1,4 @@
-/* $Id: out.c,v 1.82 2021/09/07 17:07:58 schwarze Exp $ */
+/* $OpenBSD: out.c,v 1.55 2021/09/28 17:06:17 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2014, 2015, 2017, 2018, 2019, 2021
@@ -123,6 +123,7 @@ tblcalc(struct rofftbl *tbl, const struc
const struct tbl_dat *dp;
struct roffcol *col;
struct tbl_colgroup *first_group, **gp, *g;
+ size_t *colwidth;
size_t ewidth, min1, min2, wanted, width, xwidth;
int done, icol, maxcol, necol, nxcol, quirkcol;
@@ -256,16 +257,28 @@ tblcalc(struct rofftbl *tbl, const struc
gp = &(*gp)->next;
}
+ colwidth = mandoc_reallocarray(NULL, maxcol + 1, sizeof(*colwidth));
while (first_group != NULL) {
/*
+ * Rebuild the array of the widths of all columns
+ * participating in spans that require expansion.
+ */
+
+ for (icol = 0; icol <= maxcol; icol++)
+ colwidth[icol] = SIZE_MAX;
+ for (g = first_group; g != NULL; g = g->next)
+ for (icol = g->startcol; icol <= g->endcol; icol++)
+ colwidth[icol] = tbl->cols[icol].width;
+
+ /*
* Find the smallest and second smallest column width
* among the columns which may need expamsion.
*/
min1 = min2 = SIZE_MAX;
for (icol = 0; icol <= maxcol; icol++) {
- width = tbl->cols[icol].width;
+ width = colwidth[icol];
if (min1 > width) {
min2 = min1;
min1 = width;
@@ -283,7 +296,7 @@ tblcalc(struct rofftbl *tbl, const struc
for (g = first_group; g != NULL; g = g->next) {
necol = 0;
for (icol = g->startcol; icol <= g->endcol; icol++)
- if (tbl->cols[icol].width == min1)
+ if (colwidth[icol] == min1)
necol++;
if (necol == 0)
continue;
@@ -300,7 +313,7 @@ tblcalc(struct rofftbl *tbl, const struc
while ((g = *gp) != NULL) {
done = 0;
for (icol = g->startcol; icol <= g->endcol; icol++) {
- if (tbl->cols[icol].width != min1)
+ if (colwidth[icol] != min1)
continue;
if (g->wanted <= wanted - min1) {
tbl->cols[icol].width += g->wanted;
@@ -317,6 +330,7 @@ tblcalc(struct rofftbl *tbl, const struc
gp = &(*gp)->next;
}
}
+ free(colwidth);
/*
* Align numbers with text.

View File

@@ -1,3 +1,17 @@
-------------------------------------------------------------------
Mon May 13 11:37:57 UTC 2024 - Matej Cepl <mcepl@cepl.eu>
- Add /usr/lib/rpm/lua/mandoc.lua and use it for processing man
pages in the trigger scripts, making processing of packages
with many man pages (see OpenSSL for an example) significantly
faster.
-------------------------------------------------------------------
Fri Jun 9 16:23:30 UTC 2023 - Matej Cepl <mcepl@suse.com>
- Add boo1209830-endless-loop.patch (boo#1209830) avoid endless
loop on processing some mandoc files.
-------------------------------------------------------------------
Fri Dec 2 09:23:26 UTC 2022 - Dominique Leuenberger <dimstar@opensuse.org>

52
mandoc.lua Normal file
View File

@@ -0,0 +1,52 @@
mandoc = { debug = nil, todo = {}, count = 0, limit = 16 } -- package
function _log(...)
if mandoc.debug and posix.getenv("VERBOSE_FILETRIGGERS") then
print(mandoc.debug .. ": ", ...)
end
end
function mandoc._run(add, file)
if add then op = "-d" else op = "-u" end
_log("calling makewhatis " .. op .. " " .. file)
rpm.execute("/usr/sbin/makewhatis", op, "/usr/share/man", file)
end
function mandoc._handle(add, file)
if not string.match(file, "/usr/share/man/man[^/]+/[^/]+.gz$") then
return
end
if not posix.access(file) then
return
end
-- if mandoc.count < mandoc.limit then
if add then
_log("adding " .. file)
else
_log("removing " .. file)
end
mandoc.todo[file] = add
-- elseif mandoc.count == mandoc.limit then
-- _log("too many files, using makewhatis for batch processing")
-- end
mandoc.count = mandoc.count + 1
end
function mandoc.add(fn)
mandoc._handle(true, fn)
end
function mandoc.remove(fn)
mandoc._handle(false, fn)
end
function mandoc.done()
if mandoc.count < mandoc.limit and posix.access("/usr/share/man/mandoc.db") then
for file, what in pairs(mandoc.todo) do
mandoc._run(what, file)
end
else
_log("calling makewhatis")
rpm.execute("/usr/sbin/makewhatis")
end
end

View File

@@ -1,7 +1,7 @@
#
# spec file for package mandoc
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -25,6 +25,10 @@ License: ISC
Group: Productivity/Publishing/Troff
URL: http://mandoc.bsd.lv/
Source: http://mandoc.bsd.lv/snapshots/mandoc-%{version}.tar.gz
Source1: mandoc.lua
# PATCH-FIX-UPSTREAM boo1209830-endless-loop.patch bsc#1209830 mcepl@suse.com
# Fix endless loop
Patch0: boo1209830-endless-loop.patch
BuildRequires: less
BuildRequires: zlib-devel
Requires: %{name}-bin = %{version}
@@ -68,62 +72,43 @@ export CFLAGS="%optflags"
%make_install MANDIR=%{_mandir} BINDIR=%{_bindir} SBINDIR=%{_sbindir}
cp -fv %{buildroot}%{_bindir}/apropos %{_tmppath}/
mv -fv %{_tmppath}/apropos %{buildroot}%{_sbindir}/makewhatis
install -D -m 644 %{SOURCE1} %{buildroot}%{_rpmconfigdir}/lua/mandoc.lua
# ghost
: > %{buildroot}%{_mandir}/mandoc.db
%post
%{_sbindir}/makewhatis
%posttrans
/usr/sbin/makewhatis || :
%filetriggerin -p <lua> -- %{_mandir}
-- no point registering individual files if we can call
-- makewhatis in %%post to catch all if
if posix.getenv("VERBOSE_FILETRIGGERS") then
print("%{nvr}: running file install trigger")
end
if posix.access("%{_mandir}/mandoc.db") then
if not posix.access("/usr/share/man/mandoc.db") then return end
require("mandoc")
mandoc.debug = "%{nvr}(fin)"
file = rpm.next_file()
while file do
mandoc.add(file)
file = rpm.next_file()
while file do
if string.match(file, "%{_mandir}/man[^/]+/[^/]+%{?ext_man}$") then
if posix.access(file) then
if posix.getenv("VERBOSE_FILETRIGGERS") then
print("%{nvr}: adding " .. file)
end
rpm.execute("%{_sbindir}/makewhatis", "-d", "%{_mandir}", file)
else
io.stderr:write("%{nvr}: missing " .. file .. "\n")
end
end
file = rpm.next_file()
end
elseif posix.getenv("VERBOSE_FILETRIGGERS") then
print("%{nvr}: missing mandoc.db, skipped")
end
io.flush()
%transfiletriggerin -p <lua> -- %{_mandir}
require("mandoc")
mandoc.debug = "%{nvr}(tfin)"
mandoc.done()
%filetriggerun -p <lua> -- %{_mandir}
if posix.getenv("VERBOSE_FILETRIGGERS") then
print("%{nvr}: running file remove trigger")
end
if posix.access("%{_mandir}/mandoc.db") then
if not posix.access("/usr/share/man/mandoc.db") then return end
require("mandoc")
mandoc.debug = "%{nvr}(fun)"
file = rpm.next_file()
while file do
mandoc.remove(file)
file = rpm.next_file()
while file do
if string.match(file, "%{_mandir}/man[^/]+/[^/]+%{?ext_man}$") then
if posix.access(file) then
if posix.getenv("VERBOSE_FILETRIGGERS") then
print("%{nvr}: removing " .. file)
end
rpm.execute("%{_sbindir}/makewhatis", "-u", "%{_mandir}", file)
else
io.stderr:write("%{nvr}: missing " .. file .. "\n")
end
end
file = rpm.next_file()
end
elseif posix.getenv("VERBOSE_FILETRIGGERS") then
print("%{nvr}: missing mandoc.db, skipped")
end
io.flush()
%transfiletriggerpostun -p <lua> -- %{_mandir}
require("mandoc")
mandoc.debug = "%{nvr}(tfpun)"
mandoc.done()
%files
%license LICENSE
@@ -134,6 +119,8 @@ io.flush()
%{_bindir}/soelim
%{_bindir}/whatis
%{_sbindir}/makewhatis
%dir %{_rpmconfigdir}/lua
%{_rpmconfigdir}/lua/mandoc.lua
%{_mandir}/man1/*.1%{?ext_man}
%{_mandir}/man5/*.5%{?ext_man}
%{_mandir}/man7/*.7%{?ext_man}