<div dir="ltr"><font face="arial, helvetica, sans-serif">clang-format works penalty-based. It considers both versions of this format (wrapping or not wrapping after the "(") correct. It prefers not to wrap, i.e. keep "<span style="font-size:13px;white-space:pre-wrap">&</span><span style="font-size:13px;white-space:pre-wrap">czString" on the same line. However, it also prefers not to automatically split string literals and that has a higher penalty. The reason is that it is more likely that the author has split or not split the string literal in a way that is preferable knowing the string's content. So the two short strings actually fit on a line if the line is wrapped before </span>"<span style="font-size:13px;white-space:pre-wrap">&</span><span style="font-size:13px;white-space:pre-wrap">czString". For the second statement, however, the string needs to be split either way, as the string would not fit onto a line by itself anyway. Thus, clang-format can wrap it in a way to prefer keeping </span>"<span style="font-size:13px;white-space:pre-wrap">&</span><span style="font-size:13px;white-space:pre-wrap">czString" on the same line.</span></font><div><span style="font-size:13px;white-space:pre-wrap"><font face="arial, helvetica, sans-serif"><br></font></span></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:13px;white-space:pre-wrap">To work around this, you can manually break the strings the way you think they should be broken or reduce the penalty for breaking string literals (</span><span style="white-space:pre-wrap">PenaltyBreakString - <a href="http://clang.llvm.org/docs/ClangFormatStyleOptions.html">http://clang.llvm.org/docs/ClangFormatStyleOptions.html</a>). The latter might lead to "interesting" behavior in some cases, though.</span></font></div><div><font face="arial, helvetica, sans-serif"><span style="white-space:pre-wrap"><br></span></font></div><div><font face="arial, helvetica, sans-serif"><span style="white-space:pre-wrap">The content of the string literal is 63 characters plus quotes plus "L" plus closing parentheses plus semicolon makes 68 characters. Assuming the 12 character indent from your first snippet is correct that put the string right up onto the 80 column limit. Adding a single character means that clang-format hast to line-wrap the string.</span></font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 29, 2014 at 2:39 PM, Arvind Dalvi <span dir="ltr"><<a href="mailto:arvind.dalvi@outlook.com" target="_blank">arvind.dalvi@outlook.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr">Hi Csaba,<div><br></div><div>Yes, it was a single string which was then broken by formatting.</div><div><br></div><div>Original:</div><div><span style="font-family:Consolas;font-size:13px;background-color:white">RtlInitUnicodeString(&czString, L</span><span style="font-family:Consolas;font-size:13px;color:rgb(163,21,21)">"I am going to type a string that will be 63 characters only..\n"</span><span style="font-family:Consolas;font-size:13px;background-color:white">);</span></div><div><br></div><div>I have not tried with lesser characters.</div><div><br></div><div>And one more thing, is there a way to format entire document while saving it ?</div><div><br></div><div>Thanks,</div><div>Arvind </div><div><br><div><hr>Date: Sat, 29 Nov 2014 13:17:42 +0100<div><div class="h5"><br>Subject: Re: [cfe-dev] odd character limit while string formatting<br>From: <a href="mailto:rcsaba@gmail.com" target="_blank">rcsaba@gmail.com</a><br>To: <a href="mailto:arvind.dalvi@outlook.com" target="_blank">arvind.dalvi@outlook.com</a><br>CC: <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br><br><div dir="ltr"><div style="font-family:courier new,monospace;font-size:large">Hi Arvind,<br><br></div><div style="font-family:courier new,monospace;font-size:large">Are you saying that in all three cases, the original string was in one piece? (you didn't show us the originals).<br><br></div><div style="font-family:courier new,monospace;font-size:large">Have you tried with other lengths?<br><br></div><div style="font-family:courier new,monospace;font-size:large">Csaba<br></div></div><div><br><div>On Sat, Nov 29, 2014 at 3:02 AM, Arvind Dalvi <span dir="ltr"><<a href="mailto:arvind.dalvi@outlook.com" target="_blank">arvind.dalvi@outlook.com</a>></span> wrote:<br><blockquote style="border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr">Hi Csaba,<br> <br>I agree. But my concern is the way formatting is done. If you look at the 2nd sample, the formatting looks correct where it has broken the string in to two and aligned it. Whereas in the case of 1st and 3rd it has not.<br> <br>Thanks,<br>Arvind<br> <br><div><hr>Date: Fri, 28 Nov 2014 18:59:40 +0100<br>Subject: Re: [cfe-dev] odd character limit while string formatting<br>From: <a href="mailto:rcsaba@gmail.com" target="_blank">rcsaba@gmail.com</a><br>To: <a href="mailto:arvind.dalvi@outlook.com" target="_blank">arvind.dalvi@outlook.com</a><br>CC: <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><div><div><br><br><div dir="ltr"><div style="font-family:courier new,monospace;font-size:large">Hi Avind,<br><br>The name of RtlInitUnicodeString is 20 characters long. That, plus a 63 character string will not fit into 80 characters, which is probably set as the maximum line length.<br><br></div><div><br><div>On Fri, Nov 28, 2014 at 1:13 PM, Arvind Dalvi <span dir="ltr"><<a href="mailto:arvind.dalvi@outlook.com" target="_blank">arvind.dalvi@outlook.com</a>></span> wrote:<br><blockquote style="padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">


<div><div dir="ltr"><div>I am assuming this list caters to clang-format tool too. If not, do let me know the concerned list.</div><div><br></div>Today I downloaded the clang-format plugin for Visual Studio and realized that when a function call contains 63-character string, the formatting of the function call changes. If you look at the samples below, you would find that 2nd function call got formatted correctly, whereas the 1st and last pulled the parameters down. Is this expected ? If not, any setting that i can set to get the 2nd format applied to the 1st and to the last call ? <div><div><pre style="background:white;font-family:Consolas;font-size:13px">RtlInitUnicodeString(
            &czString,
            L<span style="color:rgb(163,21,21)">"I am going to type a string that will be 63 characters only..\n"</span>);</pre></div><div><pre style="background:white;font-family:Consolas;font-size:13px">RtlInitUnicodeString(&czString, L<span style="color:rgb(163,21,21)">"I am going to type a string that "</span>
                                L<span style="color:rgb(163,21,21)">"will be 64 characters only...\n"</span>);</pre><pre style="background:white;font-family:Consolas;font-size:13px">RtlInitAnsiString(
    azString,
    L<span style="color:rgb(163,21,21)">"I am going to type a string that will be 63 characters only..\n"</span>);</pre></div></div>                                    </div></div></blockquote></div><br clear="all"><div style="font-family:courier new,monospace;font-size:large">Csaba</div><br>-- <br><div>GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++<br>The Tao of math: The numbers you can count are not the real numbers.<br>Life is complex, with real and imaginary parts.<br>"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds<br>"People disagree with me. I just ignore them." -- Linus Torvalds<br><br></div>
</div></div></div></div></div>                                      </div></div>
</blockquote></div><br><br clear="all"><br>-- <br><div>GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++<br>The Tao of math: The numbers you can count are not the real numbers.<br>Life is complex, with real and imaginary parts.<br>"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds<br>"People disagree with me. I just ignore them." -- Linus Torvalds<br><br></div>
</div></div></div></div></div>                                      </div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>