Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82fd2d21c7 | ||
|
|
3675f954b6 | ||
|
|
5551b2b25b | ||
|
|
221457c348 | ||
|
|
21a892b5b5 | ||
|
|
a372130733 | ||
|
|
69c8c34f43 | ||
|
|
8e66ef8de3 | ||
|
|
e0963a5233 | ||
|
|
8f421ab582 | ||
|
|
28f2c87919 | ||
|
|
90232de96e | ||
|
|
c03fe1133f |
@@ -10,7 +10,7 @@ endif()
|
||||
|
||||
# Linux Soname Version
|
||||
set(MAJORVER 3)
|
||||
set(MINORVER 3)
|
||||
set(MINORVER 4)
|
||||
set(PATCHVER 0)
|
||||
set(SOLIBVER ${MAJORVER}.${MINORVER}.${PATCHVER})
|
||||
|
||||
|
||||
@@ -139,6 +139,8 @@
|
||||
<a class="contents" href="#_indent-col1-comments">indent-col1-comments</a>
|
||||
<a class="contents" href="#_min-conditional-indent">min-conditional-indent</a>
|
||||
<a class="contents" href="#_max-continuation-indent">max-continuation-indent</a>
|
||||
<a class="contents" href="#_lambda_indent">lambda-indent</a>
|
||||
|
||||
</p>
|
||||
<p class="contents1">
|
||||
<a href="#_Padding_Options">Padding Options</a></p>
|
||||
@@ -1513,6 +1515,7 @@ if (a < b
|
||||
</div>
|
||||
<p>
|
||||
</p>
|
||||
|
||||
<p id="_max-continuation-indent">
|
||||
<code class="title">--max-continuation-indent=<span class="option">#</span> / -M<span class="option">#</span></code><br />
|
||||
Set the maximum of <span class="option">#</span> spaces to indent a continuation line. The
|
||||
@@ -1540,6 +1543,38 @@ fooFunction(barArg1,
|
||||
barArg3);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p id="_lambda_indent">
|
||||
<code class="title">--lambda-indent</code><br />
|
||||
This option improves indentation of C++ lambda functions. As it currently does not work well with complex lambda function bodies, this feature is not enabled by default.
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>void abssort (float* x, unsigned n)
|
||||
{
|
||||
std::sort (x, x + n,
|
||||
[] (float a, float b) {
|
||||
return (std::abs (a) < std::abs (b));
|
||||
}
|
||||
);
|
||||
}</pre>
|
||||
</div>
|
||||
|
||||
<p class="code">
|
||||
becomes:</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>void abssort (float* x, unsigned n)
|
||||
{
|
||||
std::sort (x, x + n,
|
||||
[] (float a, float b) {
|
||||
return (std::abs (a) < std::abs (b));
|
||||
}
|
||||
);
|
||||
}</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
|
||||
+11
-2
@@ -58,6 +58,9 @@
|
||||
<p class="contents1">
|
||||
<a class="contents" href="#_Compiler_Options">Compiler Options</a></p>
|
||||
|
||||
<p class="contents2">
|
||||
<a class="contents" href="#_PIP">Python PIP</a></p>
|
||||
|
||||
<h3 id="_Artistic_Style_Versions">Artistic Style Versions</h3>
|
||||
|
||||
<p>
|
||||
@@ -585,8 +588,14 @@ mingw32-make</pre>
|
||||
option that allows inline function expansion. Runtime Type Information (RTTI) is NOT needed and exceptions are
|
||||
NOT used. Use whole program optimization if your compiler supports it. There may be other options you can use
|
||||
depending on the compiler. </p>
|
||||
<p>
|
||||
</p>
|
||||
|
||||
<h3 id="_PIP">Python PIP</h3>
|
||||
|
||||
<p>
|
||||
There are two projects which enable astyle installation using PIP: <a href="https://github.com/Freed-Wu/astyle-wheel/">astyle-wheel</a> and <a href="https://github.com/igrr/astyle_py">astyle_py (using WASM)</a>.<br>
|
||||
These are useful to be included in git pre-commit hooks.
|
||||
</p>
|
||||
|
||||
|
||||
<p style="margin-left: -0.4in; text-align: center;">
|
||||
<a href="http://sourceforge.net/projects/astyle">
|
||||
|
||||
@@ -14,7 +14,14 @@
|
||||
|
||||
<h1>Artistic Style News</h1>
|
||||
|
||||
<h3>Artistic Style 3.3 (ongoing)</h3>
|
||||
<h3>Artistic Style 3.4 (ongoing)</h3>
|
||||
|
||||
<p>
|
||||
A new option "--indent-lambda" was added to apply the lambda recognition only if applicable.
|
||||
Currently complex lambda functions are not intended properly.
|
||||
</p>
|
||||
|
||||
<h3>Artistic Style 3.3</h3>
|
||||
|
||||
<p>
|
||||
The source code has been refactored to no longer use the std namespace globally.
|
||||
|
||||
@@ -14,6 +14,17 @@
|
||||
|
||||
<h1>Artistic Style Release Notes</h1>
|
||||
|
||||
<h3>Artistic Style 3.4 (June 2023)</h3>
|
||||
|
||||
<ul>
|
||||
<li>fixed formatting of CS interpolation literals (https://gitlab.com/saalen/astyle/-/issues/8).</li>
|
||||
<li>fixed false lambda recognition (https://gitlab.com/saalen/astyle/-/issues/11)</li>
|
||||
<li>fixed indentation of member declarations (https://gitlab.com/saalen/astyle/-/issues/10)</li>
|
||||
<li>fixed indentation of struct assignments (https://gitlab.com/saalen/astyle/-/issues/12)</li>
|
||||
<li>added new option "--indent-lambda" to to enable new lambda recognition (https://gitlab.com/saalen/astyle/-/issues/7)</li>
|
||||
<li>added link to astyle Python distribution projects (https://gitlab.com/saalen/astyle/-/issues/6)</li>
|
||||
</ul>
|
||||
|
||||
<h3>Artistic Style 3.3 (May 2023)</h3>
|
||||
|
||||
<ul>
|
||||
|
||||
@@ -268,6 +268,9 @@ parser:option "--squeeze-lines"
|
||||
parser:flag "--squeeze-ws"
|
||||
:description "Remove superfluous whitespace"
|
||||
|
||||
parser:flag "--indent-lambda"
|
||||
:description "Indent C++ lambda functions (experimental, broken for complex fct bodies)"
|
||||
|
||||
local p = argparse "gen-completions"
|
||||
p:argument "shell"
|
||||
:choices {"bash", "zsh", "fish"}
|
||||
|
||||
@@ -60,6 +60,7 @@ ASBeautifier::ASBeautifier()
|
||||
setSwitchIndent(false);
|
||||
setCaseIndent(false);
|
||||
setSqueezeWhitespace(false);
|
||||
setLambdaIndentation(false);
|
||||
setBlockIndent(false);
|
||||
setBraceIndent(false);
|
||||
setBraceIndentVtk(false);
|
||||
@@ -207,6 +208,7 @@ ASBeautifier::ASBeautifier(const ASBeautifier& other) : ASBase(other)
|
||||
switchIndent = other.switchIndent;
|
||||
caseIndent = other.caseIndent;
|
||||
squeezeWhitespace = other.squeezeWhitespace;
|
||||
attemptLambdaIndentation = other.attemptLambdaIndentation;
|
||||
namespaceIndent = other.namespaceIndent;
|
||||
braceIndent = other.braceIndent;
|
||||
braceIndentVtk = other.braceIndentVtk;
|
||||
@@ -1120,6 +1122,18 @@ void ASBeautifier::setSqueezeWhitespace(bool state)
|
||||
squeezeWhitespace = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the state of the lambda indentation option. If true,
|
||||
* the parser tries to recognize lambda code. Indentation
|
||||
* is bad if the lambda code is more complex (if/switch etc)
|
||||
*
|
||||
* @param state state of option.
|
||||
*/
|
||||
void ASBeautifier::setLambdaIndentation(bool state)
|
||||
{
|
||||
attemptLambdaIndentation = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the file type.
|
||||
*/
|
||||
@@ -2846,7 +2860,8 @@ void ASBeautifier::parseCurrentLine(const std::string& line)
|
||||
{
|
||||
headerStack->pop_back();
|
||||
isInClassHeader = false;
|
||||
if ( !findKeyword(line, i, AS_STRUCT) ) // if not on this line #526
|
||||
|
||||
if (line.find("struct ", 0) > i) // if not on this line #526, GH #12
|
||||
indentCount -= classInitializerIndents;
|
||||
if (indentCount < 0)
|
||||
indentCount = 0;
|
||||
@@ -2870,8 +2885,13 @@ void ASBeautifier::parseCurrentLine(const std::string& line)
|
||||
}
|
||||
|
||||
// #121
|
||||
if (!isLegalNameChar(prevNonSpaceCh) && prevNonSpaceCh != ']' && prevNonSpaceCh != ')' && line.find(AS_AUTO, 0 ) == std::string::npos) {
|
||||
lambdaIndicator = true;
|
||||
if (attemptLambdaIndentation // GH #7
|
||||
&& !isLegalNameChar(prevNonSpaceCh)
|
||||
&& prevNonSpaceCh != ']'
|
||||
&& prevNonSpaceCh != ')'
|
||||
&& prevNonSpaceCh != '*' // GH #11
|
||||
&& line.find(AS_AUTO, 0 ) == std::string::npos) {
|
||||
lambdaIndicator = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2945,7 +2965,7 @@ void ASBeautifier::parseCurrentLine(const std::string& line)
|
||||
|| isSharpDelegate
|
||||
|| isInExternC
|
||||
|| isInAsmBlock
|
||||
//|| (getNextWord(line, i) == AS_NEW // #487
|
||||
//|| getNextWord(line, i) == AS_NEW // #487
|
||||
|| (isInDefine
|
||||
&& (prevNonSpaceCh == '('
|
||||
|| isLegalNameChar(prevNonSpaceCh))));
|
||||
@@ -3265,6 +3285,12 @@ void ASBeautifier::parseCurrentLine(const std::string& line)
|
||||
if (isObjCStyle() && findKeyword(line, i, AS_NS_HANDLER))
|
||||
foundPreCommandMacro = true;
|
||||
|
||||
//https://sourceforge.net/p/astyle/bugs/353/
|
||||
// new is ending the line?
|
||||
if (isJavaStyle() && findKeyword(line, i, AS_NEW) && line.length()-3 == i) {
|
||||
headerStack->emplace_back(&AS_FIXED); // needs to be something which will not match - need to define a token which will never match
|
||||
}
|
||||
|
||||
//https://sourceforge.net/p/astyle/bugs/550/
|
||||
//enum can be function return value
|
||||
if (parenDepth == 0 && findKeyword(line, i, AS_ENUM) && line.find_first_of(AS_OPEN_PAREN, i) == std::string::npos)
|
||||
@@ -3808,7 +3834,8 @@ void ASBeautifier::parseCurrentLine(const std::string& line)
|
||||
&& prevNonSpaceCh != ']' // an array
|
||||
&& statementEndsWithComma(line, i))
|
||||
{
|
||||
if (!haveAssignmentThisLine) // only one assignment indent per line
|
||||
// only one assignment indent per line + GH #10
|
||||
if (!haveAssignmentThisLine && line.find(AS_SCOPE_RESOLUTION) == std::string::npos)
|
||||
{
|
||||
// register indent at previous word
|
||||
haveAssignmentThisLine = true;
|
||||
|
||||
@@ -6254,7 +6254,7 @@ void ASFormatter::formatQuoteBody()
|
||||
checkInterpolation = false;
|
||||
}
|
||||
}
|
||||
else if (isSharpStyle())
|
||||
else if (isSharpStyle() && !checkInterpolation )
|
||||
{
|
||||
if ((int) currentLine.length() > charNum + 1
|
||||
&& currentLine[charNum + 1] == '"') // check consecutive quotes
|
||||
|
||||
@@ -371,6 +371,7 @@ public:
|
||||
void setPreprocDefineIndent(bool state);
|
||||
void setPreprocConditionalIndent(bool state);
|
||||
void setSqueezeWhitespace(bool state);
|
||||
void setLambdaIndentation(bool state);
|
||||
int getBeautifierFileType() const;
|
||||
int getFileType() const;
|
||||
int getIndentLength() const;
|
||||
@@ -556,6 +557,7 @@ private: // variables
|
||||
bool shouldIndentPreprocConditional;
|
||||
bool lambdaIndicator;
|
||||
bool squeezeWhitespace;
|
||||
bool attemptLambdaIndentation;
|
||||
int indentCount;
|
||||
int spaceIndentCount;
|
||||
int spaceIndentObjCMethodAlignment;
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace astyle {
|
||||
jmethodID g_mid;
|
||||
#endif
|
||||
|
||||
const char* g_version = "3.3";
|
||||
const char* g_version = "3.4";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ASStreamIterator class
|
||||
@@ -431,69 +431,6 @@ void ASConsole::convertLineEnds(std::ostringstream& out, int lineEnd)
|
||||
out.str(outStr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void ASConsole::convertLineEnds(std::ostringstream& out, int lineEnd) {
|
||||
assert(lineEnd == LINEEND_WINDOWS || lineEnd == LINEEND_LINUX || lineEnd == LINEEND_MACOLD);
|
||||
|
||||
const std::string inStr = out.str();
|
||||
std::ostringstream outStream;
|
||||
|
||||
for (std::string::size_type i = 0; i < inStr.length(); ++i) {
|
||||
const char currChar = inStr[i];
|
||||
const char nextChar = i < inStr.length() - 1 ? inStr[i + 1] : 0;
|
||||
|
||||
if (currChar == '\r') {
|
||||
if (nextChar == '\n') {
|
||||
// CRLF
|
||||
if (lineEnd == LINEEND_CR) {
|
||||
outStream << currChar; // Delete the LF
|
||||
++i;
|
||||
}
|
||||
else if (lineEnd == LINEEND_LF) {
|
||||
outStream << nextChar; // Delete the CR
|
||||
++i;
|
||||
}
|
||||
else {
|
||||
outStream << currChar << nextChar; // Do not change
|
||||
++i;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// CR
|
||||
if (lineEnd == LINEEND_CRLF) {
|
||||
outStream << currChar << '\n'; // Insert the LF
|
||||
}
|
||||
else if (lineEnd == LINEEND_LF) {
|
||||
outStream << '\n'; // Insert the LF
|
||||
}
|
||||
else {
|
||||
outStream << currChar; // Do not change
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (currChar == '\n') {
|
||||
// LF
|
||||
if (lineEnd == LINEEND_CRLF) {
|
||||
outStream << '\r' << currChar; // Insert the CR and LF
|
||||
}
|
||||
else if (lineEnd == LINEEND_CR) {
|
||||
outStream << '\r'; // Insert the CR
|
||||
}
|
||||
else {
|
||||
outStream << currChar; // Do not change
|
||||
}
|
||||
}
|
||||
else {
|
||||
outStream << currChar; // Write the current character
|
||||
}
|
||||
}
|
||||
|
||||
out.str(outStream.str()); // Replace the stream
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
void ASConsole::correctMixedLineEnds(std::ostringstream& out)
|
||||
{
|
||||
LineEndFormat lineEndFormat = LINEEND_DEFAULT;
|
||||
@@ -1504,7 +1441,7 @@ std::string ASConsole::getNumberFormat(int num, size_t /*lcid*/) const
|
||||
// The C locale should be set but not the C++.
|
||||
// This function is not necessary if the C++ locale is set.
|
||||
// The locale().name() return value is not portable to all compilers.
|
||||
assert(locale().name() == "C");
|
||||
assert(std::locale().name() == "C");
|
||||
#endif
|
||||
|
||||
// get the locale info
|
||||
@@ -2114,6 +2051,9 @@ void ASConsole::printHelp() const
|
||||
std::cout << " --indent-col1-comments OR -Y\n";
|
||||
std::cout << " Indent line comments that start in column one.\n";
|
||||
std::cout << std::endl;
|
||||
std::cout << " --indent-lambda\n";
|
||||
std::cout << " Indent C++ lambda functions (experimental, broken for complex fct bodies)\n";
|
||||
std::cout << std::endl;
|
||||
std::cout << " --min-conditional-indent=# OR -m#\n";
|
||||
std::cout << " Indent a minimal # spaces in a continuous conditional\n";
|
||||
std::cout << " belonging to a conditional header.\n";
|
||||
@@ -3820,6 +3760,10 @@ bool ASOptions::parseOptionContinued(const std::string& arg, const std::string&
|
||||
{
|
||||
formatter.setBracketsUnPaddingMode(true);
|
||||
}
|
||||
else if (isOption(arg, "indent-lambda"))
|
||||
{
|
||||
formatter.setLambdaIndentation(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user