From: Alejandro Colomar Date: Mon, 22 Sep 2025 21:28:33 +0000 (+0200) Subject: share/mk/: lint-man-dash: Diagnose unescaped dashes X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=733f8b465c5ba636de218d2d8ba1dd5825b5911b;p=thirdparty%2Fman-pages.git share/mk/: lint-man-dash: Diagnose unescaped dashes Signed-off-by: Alejandro Colomar --- diff --git a/share/mk/lint/man/_.mk b/share/mk/lint/man/_.mk index ba25943d8..850f03302 100644 --- a/share/mk/lint/man/_.mk +++ b/share/mk/lint/man/_.mk @@ -9,6 +9,7 @@ MAKEFILE_LINT_MAN_INCLUDED := 1 .PHONY: lint-man lint-man: \ lint-man-blank \ + lint-man-dash \ lint-man-mandoc \ lint-man-poems \ lint-man-quote \ diff --git a/share/mk/lint/man/dash.mk b/share/mk/lint/man/dash.mk new file mode 100644 index 000000000..6573b6d9a --- /dev/null +++ b/share/mk/lint/man/dash.mk @@ -0,0 +1,49 @@ +# Copyright, the authors of the Linux man-pages project +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_MAN_DASH_INCLUDED +MAKEFILE_LINT_MAN_DASH_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.dash.touch +regexf := $(MAKEFILEDIR)/lint/man/dash.pcre2grep + +tgts := $(patsubst %, %$(ext), $(_NONSO)) + + +$(tgts): %$(ext): % $(regexf) $(MK) | $$(@D)/ + $(info $(INFO_)PCRE2GREP $@) + $(CAT) <$< \ + | if $(PCRE2GREP) -f '$(filter %.pcre2grep, $^)' >/dev/null; then \ + >&2 $(ECHO) "lint-man-dash: $<: Unescaped dash:"; \ + $(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) $@ + + +.PHONY: lint-man-dash +lint-man-dash: $(tgts); + + +undefine ext +undefine regexf +undefine tgts + + +endif # include guard diff --git a/share/mk/lint/man/dash.pcre2grep b/share/mk/lint/man/dash.pcre2grep new file mode 100644 index 000000000..1ab6926d8 --- /dev/null +++ b/share/mk/lint/man/dash.pcre2grep @@ -0,0 +1,4 @@ +^[^.](?:(?!\\").)* --*[[:alnum:]] +^\.(BI|IB|BR|RB|IR|RI|SS|B|I|UR|MT|MR|SY)\b(?:(?!\\").)*~--*[[:alnum:]] +^(?:(?!\\").)*\(--*[[:alnum:]] +^(?:(?!\\").)*[,=] --*[[:alnum:]]