]> git.ipfire.org Git - thirdparty/squid.git/commit
Avoid corruption of source files when astyle cannot start (#668)
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 18 Jun 2020 16:30:28 +0000 (16:30 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 19 Jun 2020 13:50:31 +0000 (13:50 +0000)
commitd357f109d76dd9aa6c1569720023ed63148fd6ea
tree17d0b6ffdc6a378643323f4778ef047ac892ae9d
parent25d2603fc361912cf7c38ce0789ce07254d73b0f
Avoid corruption of source files when astyle cannot start (#668)

    $ export ASTYLE=/no/such/file
    $ ./scripts/formater.pl src/tunnel.cc
    open2: exec of /no/such/file ... failed: No such file or directory

    # for debugging; most admins will just fix the ASTYLE value
    $ file src/tunnel.cc
    src/tunnel.cc: cannot open `src/tunnel.cc' (No such file or ...)

    $ export ASTYLE=/usr/bin/astyle
    $ ./scripts/formater.pl src/tunnel.cc
    Can not open input file: src/tunnel.cc.astylebak.2

    $ xxd -C src/tunnel.cc
    00000000: 00

Also avoids creation of new source files, as (poorly) illustrated by the
single-byte src/tunnel.cc file created (after being removed) above.

Also improves diagnostic when dealing with misspelled file names:

    $ ./scripts/formater.pl src/tunnel.ccsrc/FwdState.cc
    Can not open input file: src/tunnel.ccsrc/FwdState.cc.astylebak
    Can't open output file: src/tunnel.ccsrc/FwdState.cc
scripts/formater.pl