pkuthss/utils/qa

63 lines
2.3 KiB
Makefile
Executable File

#!/usr/bin/make -f
#
# Copyright (c) 2012,2014,2018 Casper Ti. Vector
# Public domain.
FIND_GBK = '(' -name '*gbk*' -o -name '*.bat*' ')'
FIND_CRLF = -name '*.bat*'
FIND_VCS = '(' -type d -name '.git' -prune ')'
# IGNORE "error"s intentionally.
.IGNORE qa: enc lt sync spell blank tail
enc:
@echo '======================================================================'
@echo '$@: check file encodings'
@echo '----------------------------------------------------------------------'
! find . -not $(FIND_VCS) $(FIND_GBK) \
-type f -exec file '{}' '+' | grep -vE 'GB|ISO-8859|ASCII'
! find . -not $(FIND_VCS) -not $(FIND_GBK) \
-type f -exec file '{}' '+' | grep -E 'GB|ISO-8859'
@echo
lt:
@echo '======================================================================'
@echo '$@: check line terminators'
@echo '----------------------------------------------------------------------'
! find . -not $(FIND_VCS) $(FIND_CRLF) \
-type f -exec file '{}' '+' | grep -vE 'CRLF'
! find . -not $(FIND_VCS) -not $(FIND_CRLF) \
-type f -exec file '{}' '+' | grep -E 'CRLF'
@echo
sync:
@echo '======================================================================'
@echo '$@: keep GBK and UTF-8 files synchronised'
@echo '----------------------------------------------------------------------'
iconv -f GBK tex/pkuthss-gbk.def | diff - tex/pkuthss-utf8.def
@echo
spell:
@echo '======================================================================'
@echo '$@: "模板" -> "模版"; "绪言" -> "序言"; maybe "需" -> "须"'
@echo '----------------------------------------------------------------------'
grep -rE --exclude-dir=.git '需|模板|绪言' .
@echo
blank:
@echo '======================================================================'
@echo '$@: check for trailing spaces and tabs'
@echo '----------------------------------------------------------------------'
! grep -r --exclude-dir=.git '[ ]\+$$' --exclude '*.patch' .
@echo
tail:
@echo '======================================================================'
@echo '$@: remember to update documentation after modifications'
@echo '$@: remember to update patch(es)'
@echo '$@: remember to update copyright lines'
@echo '$@: remember to review `git diff`'
@echo '======================================================================'
# vim:ts=4:sw=4