[tz] [PROPOSED 2/9] Fix ‘make check_character_set’ false positive

Paul Eggert eggert at cs.ucla.edu
Thu Dec 21 01:29:48 UTC 2023


The false positive occurs on Solaris 10 when $(UTF_LOCALE)
does not work.
* Makefile (UTF8_LOCALE_MISSING): New macro.
(check_character_set, check_white_space): Use it.
(check_white_space): Simplify two ‘grep’s into one.
---
 Makefile | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index cc5af634..4e45f93b 100644
--- a/Makefile
+++ b/Makefile
@@ -829,11 +829,16 @@ check_mild:	check_character_set check_white_space check_links \
 		  check_slashed_abbrs check_sorted \
 		  check_tables check_web check_ziguard check_zishrink check_tzs
 
+# True if UTF8_LOCALE does not work;
+# otherwise, false but with LC_ALL set to $(UTF8_LOCALE).
+UTF8_LOCALE_MISSING = \
+  { test ! '$(UTF8_LOCALE)' \
+    || ! printf 'A\304\200B\n' \
+         | LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 \
+    || { LC_ALL='$(UTF8_LOCALE)'; export LC_ALL; false; }; }
+
 check_character_set: $(ENCHILADA)
-	test ! '$(UTF8_LOCALE)' || \
-	! printf 'A\304\200B\n' | \
-	  LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 || { \
-		LC_ALL='$(UTF8_LOCALE)' && export LC_ALL && \
+	$(UTF8_LOCALE_MISSING) || { \
 		sharp='#' && \
 		! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \
 			$(MISC) $(SOURCES) $(WEB_PAGES) \
@@ -848,12 +853,12 @@ check_character_set: $(ENCHILADA)
 	touch $@
 
 check_white_space: $(ENCHILADA)
+	$(UTF8_LOCALE_MISSING) || { \
 		patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \
-		! grep -En "$$pat" \
-			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list)
-		! grep -n '[$s]$$' \
-			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list)
-		touch $@
+		! grep -En "$$pat|[$s]\$$" \
+			$$(ls $(ENCHILADA) | grep -Fvx leap-seconds.list); \
+	}
+	touch $@
 
 PRECEDES_FILE_NAME = ^(Zone|Link[$s]+[^$s]+)[$s]+
 FILE_NAME_COMPONENT_TOO_LONG = $(PRECEDES_FILE_NAME)[^$s]*[^/$s]{15}
-- 
2.43.0




More information about the tz mailing list