Simplify license header

This commit is contained in:
Hackerpilot 2015-03-19 23:36:51 -07:00
parent 4b1c64fd9e
commit 8cb320c544
1 changed files with 17 additions and 40 deletions

View File

@ -1,30 +1,9 @@
/******************************************************************************* // Copyright Brian Schott 2015.
* Boost Software License - Version 1.0 - August 17th, 2003 // Distributed under the Boost Software License, Version 1.0.
* // (See accompanying file LICENSE.txt or copy at
* Permission is hereby granted, free of charge, to any person or organization // http://www.boost.org/LICENSE_1_0.txt)
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************/
module dfmt; module dfmt.main;
import std.stdio; import std.stdio;
@ -631,7 +610,7 @@ private:
{ {
// Silly hack to format enums better. // Silly hack to format enums better.
if (peekBackIsLiteralOrIdent() || peekBackIs(tok!")", true) if (peekBackIsLiteralOrIdent() || peekBackIs(tok!")", true)
||(peekBackIs(tok!",", true) && !peekBackIsSlashSlash)) || (peekBackIs(tok!",", true) && !peekBackIsSlashSlash))
newline(); newline();
write("}"); write("}");
if (index < tokens.length - 1 if (index < tokens.length - 1
@ -940,8 +919,8 @@ private:
void regenLineBreakHints(immutable size_t i) void regenLineBreakHints(immutable size_t i)
{ {
immutable size_t j = expressionEndIndex(i); immutable size_t j = expressionEndIndex(i);
linebreakHints = chooseLineBreakTokens(i, tokens[i .. j], linebreakHints = chooseLineBreakTokens(i, tokens[i .. j], depths[i .. j],
depths[i .. j], config, currentLineLength, indentLevel); config, currentLineLength, indentLevel);
} }
void regenLineBreakHintsIfNecessary(immutable size_t i) void regenLineBreakHintsIfNecessary(immutable size_t i)
@ -1163,9 +1142,8 @@ private:
immutable bool hasCurrent = index + 1 < tokens.length; immutable bool hasCurrent = index + 1 < tokens.length;
if (niBraceDepth > 0 && !peekBackIsSlashSlash() && hasCurrent if (niBraceDepth > 0 && !peekBackIsSlashSlash() && hasCurrent
&& tokens[index].type == tok!"}" && tokens[index].type == tok!"}" && !assumeSorted(
&& !assumeSorted(astInformation.funLitEndLocations).equalRange( astInformation.funLitEndLocations).equalRange(tokens[index].index).empty)
tokens[index].index).empty)
{ {
write(" "); write(" ");
return; return;
@ -1225,8 +1203,8 @@ private:
if (l != -1) if (l != -1)
indentLevel = l; indentLevel = l;
} }
else if (currentIs(tok!"{") && !astInformation.structInitStartLocations.canFindIndex( else if (currentIs(tok!"{")
tokens[index].index) && !astInformation.structInitStartLocations.canFindIndex(tokens[index].index)
&& !astInformation.funLitStartLocations.canFindIndex(tokens[index].index)) && !astInformation.funLitStartLocations.canFindIndex(tokens[index].index))
{ {
while (indents.length && isWrapIndent(indents.top)) while (indents.length && isWrapIndent(indents.top))
@ -1856,7 +1834,7 @@ struct State
int ll = currentLineLength; int ll = currentLineLength;
size_t breakIndex = 0; size_t breakIndex = 0;
size_t i = 0; size_t i = 0;
bool s = true; this._solved = true;
if (breaks.length == 0) if (breaks.length == 0)
{ {
immutable int l = currentLineLength + tokens.map!(a => tokenLength(a)).sum(); immutable int l = currentLineLength + tokens.map!(a => tokenLength(a)).sum();
@ -1865,10 +1843,10 @@ struct State
{ {
immutable longPenalty = (l - formatterConfig.columnSoftLimit) * remainingCharsMultiplier; immutable longPenalty = (l - formatterConfig.columnSoftLimit) * remainingCharsMultiplier;
_cost += longPenalty; _cost += longPenalty;
s = longPenalty < newlinePenalty; this._solved = longPenalty < newlinePenalty;
} }
else else
s = true; this._solved = true;
} }
else else
{ {
@ -1878,7 +1856,7 @@ struct State
ll += tokens[i .. j].map!(a => tokenLength(a)).sum(); ll += tokens[i .. j].map!(a => tokenLength(a)).sum();
if (ll > formatterConfig.columnHardLimit) if (ll > formatterConfig.columnHardLimit)
{ {
s = false; this._solved = false;
break; break;
} }
else if (ll > formatterConfig.columnSoftLimit) else if (ll > formatterConfig.columnSoftLimit)
@ -1890,7 +1868,6 @@ struct State
while (i + 1 < tokens.length); while (i + 1 < tokens.length);
} }
this._cost += breaks.length * newlinePenalty; this._cost += breaks.length * newlinePenalty;
this._solved = s;
} }
int cost() const pure nothrow @safe @property int cost() const pure nothrow @safe @property
@ -1991,7 +1968,7 @@ State[] validMoves(const Token[] tokens, immutable short[] depths, ref const Sta
State[] states; State[] states;
foreach (i, token; tokens) foreach (i, token; tokens)
{ {
if (current.breaks.canFind(i) || !isBreakToken(token.type)) if (!isBreakToken(token.type) || current.breaks.canFind(i))
continue; continue;
size_t[] breaks; size_t[] breaks;
breaks ~= current.breaks; breaks ~= current.breaks;