From: Paul Eggert Date: Tue, 21 Jun 2022 03:19:59 +0000 (-0500) Subject: maint: prefer POSIX-compatible EREs X-Git-Tag: v9.2~182 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa7ed969c30f9300fb989b196d61d09d8b8cce6f;p=thirdparty%2Fcoreutils.git maint: prefer POSIX-compatible EREs * cfg.mk (begword, endword): New macros. (sc_prohibit_stat_macro_address, sc_prohibit_fail_0) (sc_prohibit_short_facl_mode_spec, sc_require_stdio_safer) (sc_prohibit_sleep, sc_prohibit_framework_failure) (sc_marked_devdiagnostics): * build-aux/gen-single-binary.sh: Prefer POSIX-compatible EREs to GNU extensions like \w and \<. --- diff --git a/build-aux/gen-single-binary.sh b/build-aux/gen-single-binary.sh index 6570615355..1e8f495b4a 100755 --- a/build-aux/gen-single-binary.sh +++ b/build-aux/gen-single-binary.sh @@ -41,7 +41,7 @@ done # Load actual values from src/local.mk. This will read all the variables from # the local.mk matching the src_${cmd}_... case. while read l; do - if echo "$l" | grep -E '^src_\w+ +\+?=' > /dev/null; then + if echo "$l" | grep -E '^src_[_[:alnum:]]+ +\+?=' > /dev/null; then var=$(echo $l | cut -f 1 -d ' ') value=$(echo $l | cut -f 2- -d =) if [ "$value" != " \$(LDADD)" ]; then diff --git a/cfg.mk b/cfg.mk index 7d9f40d67b..8957cca34b 100644 --- a/cfg.mk +++ b/cfg.mk @@ -441,9 +441,13 @@ sc_prohibit_operator_at_end_of_line: halt='found operator at end of line' \ $(_sc_search_regexp) +# Partial substitutes for GNU extensions \< and \> in regexps. +begword = (^|[^_[:alnum:]]) +endword = ($$|[^_[:alnum:]]) + # Don't use address of "stat" or "lstat" functions sc_prohibit_stat_macro_address: - @prohibit='\' \ + @prohibit='$(begword)l?stat '':|&l?stat$(endword)' \ halt='stat() and lstat() may be function-like macros' \ $(_sc_search_regexp) @@ -508,7 +512,7 @@ sc_prohibit_emacs__indent_tabs_mode__setting: # Ensure that tests don't include a redundant fail=0. sc_prohibit_fail_0: - @prohibit='\' \ + @prohibit='$(begword)fail=0$(endword)' \ halt='fail=0 initialization' \ $(_sc_search_regexp) @@ -545,14 +549,14 @@ sc_prohibit_env_returns: # setfacl reject it with: "Unrecognized character found in mode field". # Use hyphens to give it a length of 3: "...:rw-" or "...:r--". sc_prohibit_short_facl_mode_spec: - @prohibit='\ /dev/null; then \ - files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT) \ + files=$$(grep -l '$(begword)freopen \?(' $$($(VC_LIST_EXCEPT) \ | grep '\.[ch]$$')); \ test -n "$$files" && grep -LE 'include "stdio--.h"' $$files \ | grep . && \ @@ -568,7 +572,7 @@ sc_prohibit_perl_hash_quotes: # Prefer xnanosleep over other less-precise sleep methods sc_prohibit_sleep: - @prohibit='\<(nano|u)?sleep \(' \ + @prohibit='$(begword)(nano|u)?sleep \(' \ halt='prefer xnanosleep over other sleep interfaces' \ $(_sc_search_regexp) @@ -594,7 +598,7 @@ sc_env_test_dependencies: # Use framework_failure_, not the old name without the trailing underscore. sc_prohibit_framework_failure: - @prohibit='\' \ + @prohibit='$(begword)framework_''failure$(endword)' \ halt='use framework_failure_ instead' \ $(_sc_search_regexp) @@ -778,7 +782,7 @@ sc_THANKS_in_sorted: # Look for developer diagnostics that are marked for translation. # This won't find any for which devmsg's format string is on a separate line. sc_marked_devdiagnostics: - @prohibit='\