diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/pvscheck.sh | 55 | ||||
-rwxr-xr-x | scripts/vim-patch.sh | 6 |
2 files changed, 43 insertions, 18 deletions
diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh index 2e4f990693..32d63646aa 100755 --- a/scripts/pvscheck.sh +++ b/scripts/pvscheck.sh @@ -12,20 +12,28 @@ help() { echo 'Usage:' echo ' pvscheck.sh [target-directory [branch]]' echo ' pvscheck.sh [--recheck] [target-directory]' + echo ' pvscheck.sh --patch [--only-build]' echo - echo ' --recheck: run analysis on a prepared target directory' + echo ' --patch: patch sources in the current directory.' + echo ' Does not patch already patched files.' + echo ' Does not run analysis.' echo - echo ' target-directory: Directory where build should occur' + echo ' --only-build: Only patch files in ./build directory.' + echo + echo ' --recheck: run analysis on a prepared target directory.' + echo + echo ' target-directory: Directory where build should occur.' echo ' Default: ../neovim-pvs' echo - echo ' branch: Branch to check' - echo ' Default: master' + echo ' branch: Branch to check.' + echo ' Default: master.' } get_pvs_comment() { cat > pvs-comment << EOF -// This is an open source non-commercial project. Dear PVS-Studio, please check it. -// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + EOF } @@ -62,19 +70,27 @@ patch_sources() { get_pvs_comment local sh_script=' - cat pvs-comment "$1" > "$1.tmp" - mv "$1.tmp" "$1" + pvs_comment="$(cat pvs-comment ; echo -n EOS)" + filehead="$(head -c $(( ${#pvs_comment} - 3 )) "$1" ; echo -n EOS)" + if test "x$filehead" != "x$pvs_comment" ; then + cat pvs-comment "$1" > "$1.tmp" + mv "$1.tmp" "$1" + fi ' - find \ - src/nvim test/functional/fixtures test/unit/fixtures \ - -name '*.[ch]' \ - -exec /bin/sh -c "$sh_script" - '{}' \; + if test "x$1" != "x--only-build" ; then + find \ + src/nvim test/functional/fixtures test/unit/fixtures \ + -name '*.c' \ + -exec /bin/sh -c "$sh_script" - '{}' \; + fi find \ build/src/nvim/auto build/config \ - -name '*.[ch]' -not -name '*.test-include.c' \ + -name '*.c' -not -name '*.test-include.c' \ -exec /bin/sh -c "$sh_script" - '{}' \; + + rm pvs-comment } run_analysis() { @@ -103,8 +119,6 @@ do_check() { create_compile_commands - patch_sources - run_analysis } @@ -128,6 +142,17 @@ main() { set -x + if test "x$1" = "x--patch" ; then + shift + if test "x$1" = "x--only-build" ; then + shift + patch_sources --only-build + else + patch_sources + fi + exit $? + fi + local recheck= if test "x$1" = "x--recheck" ; then recheck=1 diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index c8ae36cc3b..3ade90a65b 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -137,18 +137,18 @@ preprocess_patch() { # Remove channel.txt, netbeans.txt, os_*.txt, todo.txt, version*.txt, tags local na_doc='channel\.txt\|netbeans\.txt\|os_\w\+\.txt\|todo\.txt\|version\d\.txt\|tags' - 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/runtime/doc/\%('${na_doc}'\)@norm! d/\v(^diff)|%$
' +w +q "$file" + 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/runtime/doc/\<\%('${na_doc}'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove "Last change ..." changes in doc files. 2>/dev/null $nvim --cmd 'set dir=/tmp' +'%s/^@@.*\n.*For Vim version.*Last change.*\n.*For Vim version.*Last change.*//' +w +q "$file" # Remove some testdir/Make_*.mak files local na_src_testdir='Make_amiga.mak\|Make_dos.mak\|Make_ming.mak\|Make_vms.mms' - 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/testdir/\%('${na_src_testdir}'\)@norm! d/\v(^diff)|%$
' +w +q "$file" + 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/testdir/\<\%('${na_src_testdir}'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove some *.po files. #5622 local na_po='sjiscorr.c\|ja.sjis.po\|ko.po\|pl.cp1250.po\|pl.po\|ru.cp1251.po\|uk.cp1251.po\|zh_CN.cp936.po\|zh_CN.po\|zh_TW.po' - 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/po/\%('${na_po}'\)@norm! d/\v(^diff)|%$
' +w +q "$file" + 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/po/\<\%('${na_po}'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Rename src/ paths to src/nvim/ LC_ALL=C sed -e 's/\( [ab]\/src\)/\1\/nvim/g' \ |