The following function will ignore trailing empty lines.
on line_count_without_trailing_empty_lines(_source)
set _lines to (length of _source)
if _lines = 0 then return 0
repeat with _index from _lines to 1 by -1
if item _index of _source � "" then
return _index
end if
end repeat
return 1
end line_count_without_trailing_empty_lines
But when the following setting is set in .clang-format:
MaxEmptyLinesToKeep: 2
Then clang-format will fail to trim empty trailing lines.
This means that using clang-foramt --dry-run -Werror to validate if a source file was properly formatted then it will fail.
And then using the xcode-clang-format.applescript to format the file wont fix this.
The following function will ignore trailing empty lines.
https://github.com/sean-parent/tools/blob/be6d4a78404473935dea0d37bbed4509a19a548a/xcode-clang-format.applescript#L78
But when the following setting is set in
.clang-format
:Then
clang-format
will fail to trim empty trailing lines. This means that usingclang-foramt --dry-run -Werror
to validate if a source file was properly formatted then it will fail. And then using thexcode-clang-format.applescript
to format the file wont fix this.