]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
share/mk/: lint-man-quote: Diagnose an unmatched quote
authorAlejandro Colomar <alx@kernel.org>
Sat, 23 Aug 2025 19:14:14 +0000 (21:14 +0200)
committerAlejandro Colomar <alx@kernel.org>
Sun, 7 Sep 2025 09:14:34 +0000 (11:14 +0200)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
share/mk/lint/man/_.mk
share/mk/lint/man/quote.Pgrep [new file with mode: 0644]
share/mk/lint/man/quote.mk [new file with mode: 0644]

index a15b503990b7d597ad26681a21cc2c90256077e5..0bf60eaa6aa52e7bebcad80ec0bd64baa2c155a3 100644 (file)
@@ -10,6 +10,7 @@ MAKEFILE_LINT_MAN_INCLUDED := 1
 lint-man: \
        lint-man-blank \
        lint-man-mandoc \
+       lint-man-quote \
        lint-man-so \
        lint-man-tbl \
        lint-man-ws;
diff --git a/share/mk/lint/man/quote.Pgrep b/share/mk/lint/man/quote.Pgrep
new file mode 100644 (file)
index 0000000..d14de9f
--- /dev/null
@@ -0,0 +1 @@
+^\.[[:alpha:]][^"]*(?:\\"|(?!\\")(?:[^"]*"){2})*[^"]*(?<!\\)"[^"]*$
diff --git a/share/mk/lint/man/quote.mk b/share/mk/lint/man/quote.mk
new file mode 100644 (file)
index 0000000..201ec85
--- /dev/null
@@ -0,0 +1,46 @@
+# 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_QUOTE_INCLUDED
+MAKEFILE_LINT_MAN_QUOTE_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/man/man.mk
+include $(MAKEFILEDIR)/build/man/mdoc.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/grep/grep.mk
+
+
+_XFAIL_LINT_man_quote := \
+       $(_MANDIR)/man8/tzselect.8.lint-man.quote.touch \
+       $(_MANDIR)/man8/zic.8.lint-man.quote.touch
+
+
+_LINT_man_quote := $(patsubst %, %.lint-man.quote.touch, $(_NONSO_MAN) $(_NONSO_MDOC))
+ifeq ($(SKIP_XFAIL),yes)
+_LINT_man_quote := $(filter-out $(_XFAIL_LINT_man_quote), $(_LINT_man_quote))
+endif
+
+
+quote_Pgrep := $(MAKEFILEDIR)/lint/man/quote.Pgrep
+
+
+$(_LINT_man_quote): %.lint-man.quote.touch: % $(quote_Pgrep) $(MK) | $$(@D)/
+       $(info  $(INFO_)GREP            $@)
+       $(CAT) <$< \
+       | if $(GREP) -Pf $(quote_Pgrep) >/dev/null; then \
+               >&2 $(ECHO) "lint-man-quote: $<: Unmatched quote:"; \
+               >&2 $(GREP) -PTnf '$(quote_Pgrep)' <$<; \
+               exit 1; \
+       fi;
+       $(TOUCH) $@
+
+
+.PHONY: lint-man-quote
+lint-man-quote: $(_LINT_man_quote);
+
+
+endif  # include guard