diff options
author | Jim Meyering <meyering@redhat.com> | 2011-05-09 19:28:11 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-05-09 19:28:11 +0200 |
commit | 91fd934273607a4a395917d5230bd8dd5c866d94 (patch) | |
tree | 6c8d330afdd2b5eadcd2fde4d00b69f62c4e36f9 /top | |
parent | 2e0a37197dcbe3565dbacf2872a175d1029d12ce (diff) | |
download | gnulib-91fd934273607a4a395917d5230bd8dd5c866d94.tar.gz |
maint.mk: change semantics/name of tight_scope variables
* top/maint.mk (_gl_TS_var_match, _gl_TS_function_match):
Rename variables to align with semantics that make them more useful.
Diffstat (limited to 'top')
-rw-r--r-- | top/maint.mk | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/top/maint.mk b/top/maint.mk index 6e810bae82..346fe0068c 100644 --- a/top/maint.mk +++ b/top/maint.mk @@ -1351,13 +1351,22 @@ ifeq (a,b) # and `usage' are exceptions: they're always extern, but # do not need to be marked. _gl_TS_unmarked_extern_functions ?= main usage -_gl_TS_function_regex ?= \ - ^(?:extern|XTERN) +(?:void|(?:struct |const |enum )?\S+) +\**(\S+) +\( +_gl_TS_function_match ?= \ + /^(?:extern|XTERN) +(?:void|(?:struct |const |enum )?\S+) +\**(\S+) +\(/ # The second nm|grep checks for file-scope variables with `extern' scope. # Without gnulib's progname module, you might put program_name here. _gl_TS_unmarked_extern_vars ?= -_gl_TS_var_regex ?= ^(?:extern|XTERN) .*?\**(\w+)(\[.*?\])?; + +# NOTE: the _match variables are perl expressions -- not mere regular +# expressions -- so that you can extend them to match other patterns +# and easily extract matched variable names. +# For example, if your project declares some global variables via +# a macro like this: GLOBAL(type, var_name, initializer), then you +# can override this definition to automatically extract those names: +# export _gl_TS_var_match = \ +# /^(?:extern|XTERN) .*?\**(\w+)(\[.*?\])?;/ || /\bGLOBAL\(.*?,\s*(.*?),/ +_gl_TS_var_match ?= /^(?:extern|XTERN) .*?\**(\w+)(\[.*?\])?;/ .PHONY: _gl_tight_scope _gl_tight_scope: $(bin_PROGRAMS) t=exceptions-$$$$; \ @@ -1372,14 +1381,14 @@ _gl_tight_scope: $(bin_PROGRAMS) ( printf '^%s$$\n' $(_gl_TS_unmarked_extern_functions); \ grep -h -A1 '^extern .*[^;]$$' $$src \ | grep -vE '^(extern |--)' | sed 's/ .*//'; \ - perl -lne '/$(_gl_TS_function_regex)/' \ + perl -lne '$(_gl_TS_function_match)' \ -e 'and print $$1' $$hdr; \ ) | sort -u | sed 's/^/^/;s/$$/$$/' > $$t; \ nm -e *.$(OBJEXT) | sed -n 's/.* T //p' | grep -Ev -f $$t \ && { echo the above functions should have static scope >&2; \ exit 1; } || : ; \ ( printf '^%s$$\n' $(_gl_TS_unmarked_extern_vars); \ - perl -lne '/$(_gl_TS_var_regex)/ and print "^$$1\$$"' \ + perl -lne '$(_gl_TS_var_match) and print "^$$1\$$"' \ $$hdr *.h ) | sort -u > $$t; \ nm -e *.$(OBJEXT) | sed -n 's/.* [BCDGRS] //p' \ | sort -u | grep -Ev -f $$t \ |