]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: augment syntax checks to cater for more "error" functions
authorPádraig Brady <P@draigBrady.com>
Wed, 31 May 2023 16:12:52 +0000 (17:12 +0100)
committerPádraig Brady <P@draigBrady.com>
Wed, 31 May 2023 16:20:09 +0000 (17:20 +0100)
src/cfg.mk (sc_error_quotes, sc_error_shell_quotes,
sc_error_shell_always_quotes): Include "die" and "diagnose"
in the class of error functions to check arguments for.

cfg.mk

diff --git a/cfg.mk b/cfg.mk
index 263bc0cfd1076c0cced6f68cc20e7bc4f2f98e97..64db2bec48c59f6a6f42f4c29b567135cd1123a7 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -189,12 +189,15 @@ sc_prohibit_quotes_notation:
               exit 1; }  \
          || :
 
+error_fns = (error|die|diagnose)
+
 # Files in src/ should quote all strings in error() output, so that
 # unexpected input chars like \r etc. don't corrupt the error.
 # In edge cases this can be avoided by putting the format string
 # on a separate line to the arguments, or the arguments in parenthesis.
 sc_error_quotes:
-       @cd $(srcdir)/src && GIT_PAGER= git grep -n 'error *(.*%s.*, [^(]*);$$'\
+       @cd $(srcdir)/src \
+         && GIT_PAGER= git grep -E -n '${error_fns} *\(.*%s.*, [^(]*\);$$' \
          *.c | grep -v ', q' \
          && { echo '$(ME): '"Use quote() for error string arguments" 1>&2; \
               exit 1; }  \
@@ -206,7 +209,7 @@ sc_error_quotes:
 sc_error_shell_quotes:
        @cd $(srcdir)/src && \
          { GIT_PAGER= git grep -E \
-           'error \(.*%s[:"], .*(name|file)[^"]*\);$$' *.c; \
+           '${error_fns} \(.*%s[:"], .*(name|file)[^"]*\);$$' *.c; \
            GIT_PAGER= git grep -E \
            ' quote[ _].*file' *.c; } \
          | grep -Ev '(quotef|q[^ ]*name)' \
@@ -220,13 +223,13 @@ sc_error_shell_quotes:
 # to provide better support for copy and paste.
 sc_error_shell_always_quotes:
        @cd $(srcdir)/src && GIT_PAGER= git grep -E \
-           'error \(.*[^:] %s[ "].*, .*(name|file)[^"]*\);$$' \
+           '${error_fns} \(.*[^:] %s[ "].*, .*(name|file)[^"]*\);$$' \
            *.c | grep -Ev '(quoteaf|q[^ ]*name)' \
          && { echo '$(ME): '"Use quoteaf() for space delimited names" 1>&2; \
               exit 1; }  \
          || :
        @cd $(srcdir)/src && GIT_PAGER= git grep -E -A1 \
-           'error \([^%]*[^:] %s[ "]' *.c | grep 'quotef' \
+           '${error_fns} \([^%]*[^:] %s[ "]' *.c | grep 'quotef' \
          && { echo '$(ME): '"Use quoteaf() for space delimited names" 1>&2; \
               exit 1; }  \
          || :