]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
share/mk/: lint-man-poems: Align output
authorAlejandro Colomar <alx@kernel.org>
Sun, 24 Aug 2025 15:51:45 +0000 (17:51 +0200)
committerAlejandro Colomar <alx@kernel.org>
Sun, 21 Sep 2025 14:26:15 +0000 (16:26 +0200)
pcre2grep(1) doesn't have a -T flag, so we need to script a bit to do
something similar.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
share/mk/lint/man/poems.mk

index 239a973e0d21fee420d031f912be81ee0e86dc5e..38492b1d3a415f917f4ecf540b1b14d71f711ba4 100644 (file)
@@ -7,10 +7,12 @@ MAKEFILE_LINT_MAN_POEMS_INCLUDED := 1
 
 
 include $(MAKEFILEDIR)/build/man/nonso.mk
+include $(MAKEFILEDIR)/configure/build-depends/awk/awk.mk
 include $(MAKEFILEDIR)/configure/build-depends/coreutils/cat.mk
 include $(MAKEFILEDIR)/configure/build-depends/coreutils/echo.mk
 include $(MAKEFILEDIR)/configure/build-depends/coreutils/touch.mk
 include $(MAKEFILEDIR)/configure/build-depends/pcre2-utils/pcre2grep.mk
+include $(MAKEFILEDIR)/configure/build-depends/sed/sed.mk
 
 
 ext := .lint-man.poems.touch
@@ -28,7 +30,12 @@ $(tgts): %$(ext): % $(regexf) $(MK) | $$(@D)/
        $(CAT) <$< \
        | if $(PCRE2GREP) -f '$(filter %.pcre2grep, $^)' >/dev/null; then \
                >&2 $(ECHO) "lint-man-poems: $<: Use semantic newlines (see man-pages(7)):"; \
-               >&2 $(PCRE2GREP) -n -f '$(filter %.pcre2grep, $^)' <$<; \
+               $(PCRE2GREP) -n -f '$(filter %.pcre2grep, $^)' <$< \
+               | $(SED) -E 's/([^:]+:)(.*)/\1\n\t\2/' \
+               | $(AWK) -F: \
+                       '/^[^\t]/{ printf("%7d:", $$1); }; \
+                        /^\t/{ print($$0); };' \
+               >&2; \
                exit 1; \
        fi;
        $(TOUCH) $@