summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2014-10-23 10:51:22 +0100
committerPádraig Brady <P@draigBrady.com>2014-10-23 11:29:05 +0100
commit414a8cf52ff2315e60a86007ffafd1513e5f55c7 (patch)
treef3d1b4171d3e6c1b37130d5e7d53177c0b9db170
parent193560790ce99061cec50869f79bdcc787ed7783 (diff)
downloadcoreutils-414a8cf52ff2315e60a86007ffafd1513e5f55c7.tar.xz
maint: improve sc_long_lines syntax-check speed
sc_long_lines was the slowest syntax check before$ time make sc_long_lines long_lines real 0m2.740s after $ time make sc_long_lines long_lines real 0m0.677s * src/cfg.mk (sc_dd_max_sym_length): s/--max-line-length/-L/ for compat with BSDs. (sc_long_lines): Prefilter with wc -L to only identify lines in files that have lines longer than 80 characters.
-rw-r--r--cfg.mk13
1 files changed, 6 insertions, 7 deletions
diff --git a/cfg.mk b/cfg.mk
index d95bfacb4..4bc379219 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -74,10 +74,9 @@ sc_dd_max_sym_length:
ifneq ($(wildcard $(dd_c)),)
@len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
- |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
- | wc --max-line-length); \
+ |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p'| wc -L);\
max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
- |tr -d '"' | wc --max-line-length); \
+ |tr -d '"' | wc -L); \
if test "$$len" = "$$max"; then :; else \
echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
exit 1; \
@@ -239,17 +238,17 @@ sc_prohibit-gl-attributes:
# - the help2man script copied from upstream,
# - tests involving long checksum lines, and
# - the 'pr' test cases.
-LINE_LEN_MAX = 80
FILTER_LONG_LINES = \
/^[^:]*\.diff:[^:]*:@@ / d; \
\|^[^:]*man/help2man:| d; \
\|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d; \
\|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
sc_long_lines:
- @files=$$($(VC_LIST_EXCEPT)) \
- halt='line(s) with more than $(LINE_LEN_MAX) characters; reindent'; \
+ @files=$$($(VC_LIST_EXCEPT) | xargs wc -L | sed -rn '/ total$$/d;\
+ s/^ *(8[1-9]|9[0-9]|[0-9]\{3,\}) //p'); \
+ halt='line(s) with more than 80 characters; reindent'; \
for file in $$files; do \
- expand $$file | grep -nE '^.{$(LINE_LEN_MAX)}.' | \
+ expand $$file | grep -nE '^.{80}.' | \
sed -e "s|^|$$file:|" -e '$(FILTER_LONG_LINES)'; \
done | grep . && { msg="$$halt" $(_sc_say_and_exit) } || :