Re: [RFC PATCH] tools: add perltidy to the syntax checker/fixer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 30, 2017 at 9:52 AM, Stephen Smalley <sds@xxxxxxxxxxxxx> wrote:
> On Fri, 2017-05-26 at 11:58 -0400, Paul Moore wrote:
>> From: Paul Moore <paul@xxxxxxxxxxxxxx>
>>
>> Signed-off-by: Paul Moore <paul@xxxxxxxxxxxxxx>
>> ---
>>  tools/check-syntax |   86 ++++++++++++++++++++++++++++++++++++++++
>> ------------
>>  1 file changed, 66 insertions(+), 20 deletions(-)

...

>>  #
>> -# Fix the formatting on a C source/header file
>> +# Fix the formatting on a file
>>  #
>>  # Arguments:
>> -#     1    File to fix
>> +#     1    Language
>> +#     2    File to check
>>  #
>> -function tool_c_style_fix() {
>> -     [[ -z "$1" || ! -r "$1" ]] && return
>> +function style_fix() {
>> +     [[ -z "$1" ]] && return
>> +     [[ -z "$2" || ! -w "$2" ]] && return
>>
>> -     tmp="$(mktemp --tmpdir=$(dirname "$1"))"
>> -     tool_c_style "$1" > "$tmp"
>> -     mv "$tmp" "$1"
>> +     tmp="$(mktemp --tmpdir=$(dirname "$2"))"
>> +     case "$1" in
>> +     c|C)
>> +             tool_c_style "$2" > "$tmp"
>> +             ;;
>> +     perl|Perl)
>> +             tool_perl_style "$2" > "$tmp"
>> +             ;;
>> +     esac
>> +     mv "$tmp" "$2"
>
> This approach doesn't preserve mode or other attributes on the file,
> and therefore leaves the perl scripts non-executable after running
> ./tools/check_syntax -f.

Yes, good point.  I'll replace that final mv command with the following:

  cat "$tmp" > "$2"
  rm "$tmp"

-- 
paul moore
www.paul-moore.com



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux