[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
update to latest gnulib and clean-up
From: |
Jim Meyering |
Subject: |
update to latest gnulib and clean-up |
Date: |
Thu, 28 Apr 2011 10:52:39 +0200 |
These changes fix typos, add explicit "extern" keywords
(preparing for...), add a syntax check to enforce scoping policy,
and update to the latest from gnulib:
>From 802f411c5c04a38dd5fa7bb2a3c2d9085a8669cc Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 10 Apr 2011 09:49:22 +0200
Subject: [PATCH 1/4] maint: fix doubled-word typos in comments
* src/dfa.c (SUCCEEDS_IN_CONTEXT): Remove doubled "a".
* src/dfa.c (BACKREF): s/it it/it is/
---
src/dfa.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/dfa.c b/src/dfa.c
index bdc3a7f..5f95ac9 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -104,7 +104,7 @@ typedef int charclass[CHARCLASS_INTS];
Word-constituent characters are those that satisfy isalnum().
- The macro SUCCEEDS_IN_CONTEXT determines whether a a given constraint
+ The macro SUCCEEDS_IN_CONTEXT determines whether a given constraint
succeeds in a particular context. Prevn is true if the previous character
was a newline, currn is true if the lookahead character is a newline.
Prevl and currl similarly depend upon whether the previous and current
@@ -152,7 +152,7 @@ typedef enum
the empty string. */
BACKREF, /* BACKREF is generated by \<digit>; it
- it not completely handled. If the scanner
+ is not completely handled. If the scanner
detects a transition on backref, it returns
a kind of "semi-success" indicating that
the match will have to be verified with
--
1.7.5.421.g9d34e
>From abcb2b51a6ecd30134074277a611f2dea71421c9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 28 Apr 2011 10:12:11 +0200
Subject: [PATCH 2/4] maint: mark some function declarations as extern
* src/search.h: Add "extern" keyword to each function declaration.
---
src/search.h | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/search.h b/src/search.h
index 5a05909..c48bbab 100644
--- a/src/search.h
+++ b/src/search.h
@@ -36,24 +36,23 @@
#include "xalloc.h"
/* searchutils.c */
-void kwsinit (kwset_t *);
+extern void kwsinit (kwset_t *);
#if MBS_SUPPORT
-char * mbtolower (const char *, size_t *);
-bool is_mb_middle(const char **, const char *, const char *, size_t);
+extern char *mbtolower (const char *, size_t *);
+extern bool is_mb_middle (const char **, const char *, const char *, size_t);
#endif
/* dfasearch.c */
-void GEAcompile (char const *, size_t, reg_syntax_t);
-size_t EGexecute (char const *, size_t, size_t *, char const *);
+extern void GEAcompile (char const *, size_t, reg_syntax_t);
+extern size_t EGexecute (char const *, size_t, size_t *, char const *);
/* kwsearch.c */
-void Fcompile (char const *, size_t);
-size_t Fexecute (char const *, size_t, size_t *, char const *);
+extern void Fcompile (char const *, size_t);
+extern size_t Fexecute (char const *, size_t, size_t *, char const *);
/* pcresearch.c */
-void Pcompile (char const *, size_t);
-size_t Pexecute (char const *, size_t, size_t *, char const *);
-
+extern void Pcompile (char const *, size_t);
+extern size_t Pexecute (char const *, size_t, size_t *, char const *);
#endif /* GREP_SEARCH_H */
--
1.7.5.421.g9d34e
>From 5468f6034610bb108d89e13dc24c833202ee7388 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 28 Apr 2011 10:20:43 +0200
Subject: [PATCH 3/4] maint: add the tight_scope syntax-checking rule
This ensures that the only externally scoped symbols are ones
that are explicitly marked as "extern" or white-listed like "main".
* src/Makefile.am (sc_tight_scope): New rule, copied from coreutils.
* cfg.mk (sc_tight_scope): Define, to hook to it from the top level.
---
cfg.mk | 4 ++++
src/Makefile.am | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 9b7b93d..035a299 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -54,6 +54,10 @@ sc_prohibit_emacs__indent_tabs_mode__setting:
halt='use of emacs indent-tabs-mode: setting' \
$(_sc_search_regexp)
+ALL_RECURSIVE_TARGETS = sc_tight_scope
+sc_tight_scope:
+ @$(MAKE) -s -C src $@
+
update-copyright-env = \
UPDATE_COPYRIGHT_USE_INTERVALS=1 \
UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
diff --git a/src/Makefile.am b/src/Makefile.am
index 257472b..ec3e176 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,3 +45,43 @@ localedir = $(datadir)/locale
AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib
EXTRA_DIST = dosbuf.c
+
+# The following rule is not designed to be portable,
+# and relies on tools that not everyone has.
+
+# Most functions in src/*.c 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. Also functions starting with __
+# are exempted due to possibly being added by the compiler
+# (when compiled as a shared library for example).
+#
+# The second nm|grep checks for file-scope variables with `extern' scope.
+.PHONY: sc_tight_scope
+sc_tight_scope: $(bin_PROGRAMS)
+ @t=exceptions-$$$$; \
+ trap 's=$$?; rm -f $$t; exit $$s' 0; \
+ for sig in 1 2 3 13 15; do \
+ eval "trap 'v=`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \
+ done; \
+ src=`for f in $(SOURCES); do \
+ 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 'main\nusage\n_.*\n'; \
+ grep -h -A1 '^extern .*[^;]$$' $$src \
+ | grep -vE '^(extern |--)' | sed 's/ .*//'; \
+ perl -lne '/^extern (?:struct |const |enum )?\S+ \**(\S*) \(/'\
+ -e 'and print $$1' $$hdr; \
+ ) | sort -u | sed 's/^/^/;s/$$/$$/' > $$t; \
+ nm -e *.$(OBJEXT) | sed -n 's/.* T //p' \
+ | sed 's/^_//' | grep -Ev -f $$t \
+ && { echo the above functions should have static scope >&2; \
+ exit 1; } || : ; \
+ ( printf '^program_name$$\n'; \
+ perl -lne '/^extern .*?\**(\w+);/ and print "^$$1\$$"' \
+ $$hdr *.h ) | sort -u > $$t; \
+ nm -e *.$(OBJEXT) | sed -n 's/.* [BD] //p' \
+ | sed 's/^_//' | grep -Ev -f $$t \
+ && { echo the above variables should have static scope >&2; \
+ exit 1; } || :
--
1.7.5.421.g9d34e
>From 39761fdca7562c6229349fecde32b2989eddfd61 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 28 Apr 2011 10:21:03 +0200
Subject: [PATCH 4/4] build: update gnulib submodule to latest
---
gnulib | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gnulib b/gnulib
index 739321e..8585ce2 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 739321ef60661c7b51a4c7a3fa23957a4d9dbbc3
+Subproject commit 8585ce2ff5698c650ba5d5e3bb99763654ad62e8
--
1.7.5.421.g9d34e