r185423 - Fix ranges computed by git clang-format.
Nico Weber
thakis at chromium.org
Tue Jul 2 08:20:23 PDT 2013
Thanks!
Do you happen to know if this does the right thing for windows-style line
endings (\r\n) too? Maybe clang-format doesn't format the next line if the
last char covered by offset is \r?
On Tue, Jul 2, 2013 at 6:20 AM, Daniel Jasper <djasper at google.com> wrote:
> Author: djasper
> Date: Tue Jul 2 08:20:35 2013
> New Revision: 185423
>
> URL: http://llvm.org/viewvc/llvm-project?rev=185423&view=rev
> Log:
> Fix ranges computed by git clang-format.
>
> Before, the computed byte range would include the trailing newline.
> clang-format on the other hand counts whitespace as belonging to the
> following token, so that git-clang-format inadvertendly reformats the
> first unmodified line as well.
>
> It is not entirely clear whether clang-format's behavior itself should
> be modified, but for now this seems to be a safe change.
>
> Modified:
> cfe/trunk/tools/clang-format/git-clang-format
>
> Modified: cfe/trunk/tools/clang-format/git-clang-format
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=185423&r1=185422&r2=185423&view=diff
>
> ==============================================================================
> --- cfe/trunk/tools/clang-format/git-clang-format (original)
> +++ cfe/trunk/tools/clang-format/git-clang-format Tue Jul 2 08:20:35 2013
> @@ -329,13 +329,13 @@ def lines_to_bytes_single_file(file, lin
> if linenum == r.start:
> byte_start = byte_idx
> if linenum == r.start + r.count:
> - byte_ranges.append(Range(byte_start, byte_idx - byte_start))
> + byte_ranges.append(Range(byte_start, byte_idx - byte_start - 1))
> r = next(line_ranges_iter)
> linenum += 1
> byte_idx += len(line)
> if r is not None:
> # FIXME: Detect and warn if line ranges go past the end of file?
> - byte_ranges.append(Range(byte_start, byte_idx - byte_start))
> + byte_ranges.append(Range(byte_start, byte_idx - byte_start - 1))
> return byte_ranges
>
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130702/d0401f95/attachment.html>
More information about the cfe-commits
mailing list