diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2024-01-02 14:13:25 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2024-02-07 20:50:18 -0800 |
| commit | b0dafd8b6f3402621b074f1d934f0ba9eb9843a8 (patch) | |
| tree | c6b2f339cb800b8565809236b9f6ddbb3bbf9186 /ninja.lua | |
| parent | ba6a0c0e2e49dd16ffbaf4184e02faad7cc96266 (diff) | |
replace tail component of src with srcsection in man()
This is useful when man() is called with the optional 'section'
parameter and can be used to replace components such as '.nro'
with a '.(section)'.
This was always the intention and fixes man page names for pciutils.
Co-authored-by: Michael Forney <mforney@mforney.org>
Diffstat (limited to 'ninja.lua')
| -rw-r--r-- | ninja.lua | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -486,14 +486,20 @@ end function man(srcs, section) for _, src in ipairs(srcs) do + local out = src..'.gz' if not src:match('^[$/]') then src = '$srcdir/'..src + out = '$outdir/'..out end - local i = src:find('/', 1, true) - local gz = '$outdir'..src:sub(i)..'.gz' - build('gzip', gz, src) - local srcsection = section or src:match('[^.]*$') - file('share/man/man'..srcsection..'/'..gz:match('[^/]*$'), '644', gz) + + local base = src:match('[^/]*$') + local ext = base:match('%.([^.]*)$') + if section then + if ext then base = base:sub(1, -(#ext + 2)) end + ext = section + end + build('gzip', out, src) + file('share/man/man'..ext..'/'..base..'.'..ext, '644', out) end end |
