On 17/05/11 15:23, Pádraig Brady wrote:
> Given '^__.*' names are reserved by the compiler,
> perhaps the happy medium is to to allow single underscores,
> but exclude double underscores, with something like:

I'm going with the following, so as to not put the
onus on users configuring an exclude list, to include
the __.* pattern.

cheers,
Pádraig.
>From d4e05013a2824dcaae7bc87e76e9f128746a3231 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Tue, 17 May 2011 19:08:14 +0100
Subject: [PATCH] maint.mk: exclude compiler symbols from sc_tight_scope

---
 ChangeLog    |    5 +++++
 top/maint.mk |    9 ++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2fb40f2..a81a791 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-17  Pádraig Brady <p...@draigbrady.com>
+
+	* top/maint.mk (_gl_tight_scope:): Automatically exclude compiler
+	reserved symbols starting with double underscore from the check.
+
 2011-05-16  Paul Eggert  <egg...@cs.ucla.edu>
 
 	* build-aux/bootstrap (gnulib_tool): Handle symlink timestamps better.
diff --git a/top/maint.mk b/top/maint.mk
index 0f097d1..d0d33e4 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -1362,13 +1362,16 @@ ifeq (a,b)
 # Most functions should have static scope.
 # Any that don't must be marked with `extern', but `main'
 # and `usage' are exceptions: they're always extern, but
-# do not need to be marked.
+# do not need to be marked.  Symbols matching `__.*' are
+# reserved by the compiler, so are automatically excluded below.
 _gl_TS_unmarked_extern_functions ?= main usage
 _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.
+# Symbols matching `__.*' are reserved by the compiler,
+# so are automatically excluded below.
 _gl_TS_unmarked_extern_vars ?=
 
 # NOTE: the _match variables are perl expressions -- not mere regular
@@ -1391,7 +1394,7 @@ _gl_tight_scope: $(bin_PROGRAMS)
 	       test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`;	\
 	hdr=`for f in $(noinst_HEADERS); do				\
 	       test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`;	\
-	( printf '^%s$$\n' $(_gl_TS_unmarked_extern_functions);		\
+	( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_functions);	\
 	  grep -h -A1 '^extern .*[^;]$$' $$src				\
 	    | grep -vE '^(extern |--)' | sed 's/ .*//';			\
 	  perl -lne '$(_gl_TS_function_match)'				\
@@ -1400,7 +1403,7 @@ _gl_tight_scope: $(bin_PROGRAMS)
 	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);		\
+	( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_vars);	\
 	  perl -lne '$(_gl_TS_var_match) and print "^$$1\$$"'		\
 	    $$hdr *.h ) | sort -u > $$t;				\
 	nm -e *.$(OBJEXT) | sed -n 's/.* [BCDGRS] //p'			\
-- 
1.7.4

Reply via email to