Skip to content

Commit

Permalink
Update AStyle to 2.06
Browse files Browse the repository at this point in the history
Update version 0.2.5
  • Loading branch information
ywx committed Jan 2, 2017
1 parent 2065239 commit de988f2
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 26 deletions.
14 changes: 9 additions & 5 deletions AStyleLib/ASBeautifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@ string ASBeautifier::beautify(const string& originalLine)
lineOpensWithComment = false;
lineStartsInComment = isInComment;
previousLineProbationTab = false;
haveLineContinuationChar = false;
lineOpeningBlocksNum = 0;
lineClosingBlocksNum = 0;
if (isImmediatelyPostObjCMethodDefinition)
Expand Down Expand Up @@ -2464,12 +2463,10 @@ string ASBeautifier::getIndentedSpaceEquivalent(const string& line_) const
string convertedLine = spaceIndent + line_;
for (size_t i = spaceIndent.length(); i < convertedLine.length(); i++)
{
size_t tabCount_ = 0;
if (convertedLine[i] == '\t')
{
size_t numSpaces = indentLength - ((tabCount_ + i) % indentLength);
size_t numSpaces = indentLength - (i % indentLength);
convertedLine.replace(i, 1, numSpaces, ' ');
++tabCount_;
i += indentLength - 1;
}
}
Expand All @@ -2490,6 +2487,12 @@ void ASBeautifier::parseCurrentLine(const string& line)
bool previousLineProbation = (probationHeader != NULL);
char ch = ' ';
int tabIncrementIn = 0;
if (isInQuote
&& !haveLineContinuationChar
&& !isInVerbatimQuote
&& !isInAsm)
isInQuote = false; // missing closing quote
haveLineContinuationChar = false;

for (size_t i = 0; i < line.length(); i++)
{
Expand Down Expand Up @@ -2570,12 +2573,13 @@ void ASBeautifier::parseCurrentLine(const string& line)
}
else if (isSharpStyle())
{
if (peekNextChar(line, i) == '"') // check consecutive quotes
if (line.compare(i, 2, "\"\"") == 0)
i++;
else
{
isInQuote = false;
isInVerbatimQuote = false;
continue;
}
}
}
Expand Down
36 changes: 23 additions & 13 deletions AStyleLib/ASFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1145,17 +1145,14 @@ string ASFormatter::nextLine()

if (newHeader != NULL)
{
// recognize closing headers of do..while, if..else, try..catch..finally
if ((newHeader == &AS_ELSE && currentHeader == &AS_IF)
|| (newHeader == &AS_WHILE && currentHeader == &AS_DO)
|| (newHeader == &AS_CATCH && currentHeader == &AS_TRY)
|| (newHeader == &AS_CATCH && currentHeader == &AS_CATCH)
|| (newHeader == &AS_FINALLY && currentHeader == &AS_TRY)
|| (newHeader == &AS_FINALLY && currentHeader == &AS_CATCH)
|| (newHeader == &_AS_FINALLY && currentHeader == &_AS_TRY)
|| (newHeader == &_AS_EXCEPT && currentHeader == &_AS_TRY)
|| (newHeader == &AS_SET && currentHeader == &AS_GET)
|| (newHeader == &AS_REMOVE && currentHeader == &AS_ADD))
foundClosingHeader = isClosingHeader(newHeader);

if (!foundClosingHeader
&& ((newHeader == &AS_WHILE && currentHeader == &AS_DO)
|| (newHeader == &_AS_FINALLY && currentHeader == &_AS_TRY)
|| (newHeader == &_AS_EXCEPT && currentHeader == &_AS_TRY)
|| (newHeader == &AS_SET && currentHeader == &AS_GET)
|| (newHeader == &AS_REMOVE && currentHeader == &AS_ADD)))
foundClosingHeader = true;

const string* previousHeader = currentHeader;
Expand Down Expand Up @@ -4596,7 +4593,10 @@ void ASFormatter::formatOpeningBracket(BracketType bracketType)
breakLine();
}
else if (!isBracketType(bracketType, SINGLE_LINE_TYPE))
{
formattedLine = rtrim(formattedLine);
breakLine();
}
else if ((shouldBreakOneLineBlocks || isBracketType(bracketType, BREAK_BLOCK_TYPE))
&& !isBracketType(bracketType, EMPTY_BLOCK_TYPE))
breakLine();
Expand Down Expand Up @@ -5502,7 +5502,12 @@ void ASFormatter::formatCommentOpener()
&& !isImmediatelyPostComment
&& !isImmediatelyPostLineComment)
{
if (bracketFormatMode == NONE_MODE)
if (isBracketType(bracketTypeStack->back(), NAMESPACE_TYPE))
{
// namespace run-in is always broken.
isInLineBreak = true;
}
else if (bracketFormatMode == NONE_MODE)
{
// should a run-in statement be attached?
if (currentLineBeginsWithBracket)
Expand Down Expand Up @@ -5776,7 +5781,8 @@ void ASFormatter::formatQuoteBody()
}
else if (isSharpStyle())
{
if (peekNextChar() == '"') // check consecutive quotes
if ((int) currentLine.length() > charNum + 1
&& currentLine[charNum + 1] == '"') // check consecutive quotes
{
appendSequence("\"\"");
goForward(1);
Expand Down Expand Up @@ -5805,6 +5811,10 @@ void ASFormatter::formatQuoteBody()
appendCurrentChar();
}
}
if (charNum + 1 >= (int) currentLine.length()
&& currentChar != '\\'
&& !isInVerbatimQuote)
isInQuote = false; // missing closing quote
}

/**
Expand Down
4 changes: 2 additions & 2 deletions AStyleLib/astyle_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace astyle {
jmethodID g_mid;
#endif

const char* g_version = "2.06 beta";
const char* g_version = "2.06";

//-----------------------------------------------------------------------------
// ASStreamIterator class
Expand Down Expand Up @@ -1734,7 +1734,7 @@ void ASConsole::printHelp() const
cout << " Insert space padding around operators.\n";
cout << endl;
cout << " --pad-comma OR -xg\n";
cout << " Insert space padding around commas and semicolons.\n";
cout << " Insert space padding after commas.\n";
cout << endl;
cout << " --pad-paren OR -P\n";
cout << " Insert space padding around parenthesis on both the outside\n";
Expand Down
8 changes: 4 additions & 4 deletions NppAStyle/NppAStyleVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#define NPPASTYLE_NAME_STRING "NppAStyle"
#define NPPASTYLE_FULLNAME_STRING "Artistic Style plugin for Notepad++"
#define NPPASTYLE_AUTHOR_STRING "YWX"
#define NPPASTYLE_VERSION_STRING "0.2.4"
#define NPPASTYLE_VERSION_DIGITALVALUE 0,2,4
#define NPPASTYLE_VERSION_RELEASEDATE "December 2016"
#define NPPASTYLE_VERSION_ASTYLE "Artistic Style 2.06 beta"
#define NPPASTYLE_VERSION_STRING "0.2.5"
#define NPPASTYLE_VERSION_DIGITALVALUE 0,2,5
#define NPPASTYLE_VERSION_RELEASEDATE "January 2017"
#define NPPASTYLE_VERSION_ASTYLE "Artistic Style 2.06"

#endif // _NPP_ASTYLE_VERSION_H
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ An Artistic Style plugin for Notepad++ to Format C, C++, C++/CLI, Objective-C, C

Thanks to developers of Artistic Style, Scintilla and Notepad++.

NOTE: Artistic Style Version 2.06 beta
NOTE: Artistic Style Version 2.06
For information on Artistic Style, please see http://sourceforge.net/projects/astyle/
For information on Scintilla, please see http://www.scintilla.org/ or http://sourceforge.net/projects/scintilla/
For information on Notepad++, please see https://notepad-plus-plus.org/ or https://github.com/notepad-plus-plus/notepad-plus-plus
Expand Down Expand Up @@ -178,7 +178,7 @@ Padding Options:
Insert space padding around operators.

pad comma
Insert space padding around commas and semicolons.
Insert space padding after commas.

pad parenthesis outside
Insert space padding around parenthesis on the outside only.
Expand Down

0 comments on commit de988f2

Please sign in to comment.