]> Savannah Git Hosting - gnulib.git/commitdiff
maint.mk: speed up sc_po_check
authorJán Tomko <jtomko@redhat.com>
Sat, 30 Jul 2016 05:39:31 +0000 (22:39 -0700)
committerJim Meyering <meyering@fb.com>
Mon, 1 Aug 2016 14:38:06 +0000 (07:38 -0700)
sc_po_check would skip files based on their names, or on the
existence of files with derived names. Rewrite it to use perl
instead of shell to make the check faster.
* top/maint.mk (perl_translatable_files_list_): Define.
(sc_po_check): Use it.

ChangeLog
top/maint.mk

index 2414e8e7d3f8abea692ee66e67811457a28204c1..dda0e504ce205f8107b12b49fa16ed017dee8a3c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-07-26  Ján Tomko  <jtomko@redhat.com>
+
+       maint.mk: speed up sc_po_check
+       sc_po_check would skip files based on their names, or on the
+       existence of files with derived names. Rewrite it to use perl
+       instead of shell to make the check faster.
+       * top/maint.mk (perl_translatable_files_list_): Define.
+       (sc_po_check): Use it.
+
 2016-07-15  Paul Eggert  <eggert@cs.ucla.edu>
 
        obstack: pacify GCC 6 with -Wnull-dereference
index aa23364a1b677c3a1cae07848a10e700fec8a071..c82afbef4ef16d59ce1dd8d316ca5b7e0fdd8e3c 100644 (file)
@@ -1123,6 +1123,21 @@ fix_po_file_diag = \
 'you have changed the set of files with translatable diagnostics;\n\
 apply the above patch\n'
 
+# Generate a list of files in which to search for translatable strings.
+perl_translatable_files_list_ =                                                \
+  -e 'foreach $$file (@ARGV) {'                                                \
+  -e ' \# Consider only file extensions with one or two letters'       \
+  -e ' $$file =~ /\...?$$/ or next;'                                   \
+  -e ' \# Ignore m4 and mk files'                                      \
+  -e ' $$file =~ /\.m[4k]$$/ and next;'                                \
+  -e ' \# Ignore a .c or .h file with a corresponding .l or .y file'   \
+  -e ' $$file =~ /(.+)\.[ch]$$/ && (-e "$${1}.l" || -e "$${1}.y")'     \
+  -e '   and next;'                                                    \
+  -e ' \# Skip unreadable files'                                       \
+  -e ' -r $$file or next;'                                             \
+  -e ' print "$$file ";'                                               \
+  -e '}'
+
 # Verify that all source files using _() (more specifically, files that
 # match $(_gl_translatable_string_re)) are listed in po/POTFILES.in.
 po_file ?= $(srcdir)/po/POTFILES.in
@@ -1132,21 +1147,8 @@ sc_po_check:
        @if test -f $(po_file); then                                    \
          grep -E -v '^(#|$$)' $(po_file)                               \
            | grep -v '^src/false\.c$$' | sort > $@-1;                  \
-         files=;                                                       \
-         for file in $$($(VC_LIST_EXCEPT)) $(generated_files); do      \
-           test -r $$file || continue;                                 \
-           case $$file in                                              \
-             *.m4|*.mk) continue ;;                                    \
-             *.?|*.??) ;;                                              \
-             *) continue;;                                             \
-           esac;                                                       \
-           case $$file in                                              \
-           *.[ch])                                                     \
-             base=`expr " $$file" : ' \(.*\)\..'`;                     \
-             { test -f $$base.l || test -f $$base.y; } && continue;;   \
-           esac;                                                       \
-           files="$$files $$file";                                     \
-         done;                                                         \
+         files=$$(perl $(perl_translatable_files_list_)                \
+           $$($(VC_LIST_EXCEPT)) $(generated_files));                  \
          grep -E -l '$(_gl_translatable_string_re)' $$files            \
            | $(SED) 's|^$(_dot_escaped_srcdir)/||' | sort -u > $@-2;   \
          diff -u -L $(po_file) -L $(po_file) $@-1 $@-2                 \