pkuthss/utils/qa

62 lines
2.2 KiB
Makefile
Executable File

#!/usr/bin/make -f
# vim:ts=4:sw=4
#
# Copyright (c) 2012,2014 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 '$@: "模版" -> "模板"; "绪言" -> "序言"'
@echo '----------------------------------------------------------------------'
grep -rE --exclude-dir=.git '模板|绪言' .
@echo
blank:
@echo '======================================================================'
@echo '$@: check for spaces and tabs on blank lines'
@echo '----------------------------------------------------------------------'
! grep -r --exclude-dir=.git '[ ]\+$$' .
@echo
tail:
@echo '======================================================================'
@echo '$@: remember to update documentation after modifications'
@echo '$@: remember to update copyright lines'
@echo '$@: remember to review `git diff`'
@echo '======================================================================'