Skip to content

Commit

Permalink
updated version; fixed indent of struct initializer lists
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/astyle/code/trunk@685 1fe3c263-5997-42ff-936f-87a7378ef0cd
  • Loading branch information
saalen committed Apr 1, 2023
1 parent 4c73565 commit 7e565cc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
12 changes: 6 additions & 6 deletions AStyle/src/ASBeautifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3229,7 +3229,7 @@ void ASBeautifier::parseCurrentLine(const string& line)
if (parenDepth == 0 && findKeyword(line, i, AS_ENUM) && line.find_first_of(AS_OPEN_PAREN, i) == string::npos)
isInEnum = true;

if (parenDepth == 0 && (findKeyword(line, i, AS_TYPEDEF_STRUCT) || findKeyword(line, i, AS_STRUCT)))
if (parenDepth == 0 && (findKeyword(line, i, AS_TYPEDEF_STRUCT) || findKeyword(line, i, AS_STRUCT)) && line.find_first_of(AS_SEMICOLON, i) == string::npos)
{
isInStruct = true;
}
Expand Down Expand Up @@ -3272,11 +3272,6 @@ void ASBeautifier::parseCurrentLine(const string& line)
if (i == 0)
indentCount += classInitializerIndents;
}
else if (isInStruct && !isInCase)
{
if (i == 0)
indentCount += classInitializerIndents;
}
else if ((isCStyle() || isSharpStyle())
&& !isInCase
&& (prevNonSpaceCh == ')' || foundPreCommandHeader))
Expand All @@ -3287,6 +3282,11 @@ void ASBeautifier::parseCurrentLine(const string& line)
if (i == 0)
indentCount += classInitializerIndents;
}
else if (isInStruct && !isInCase)
{
if (i == 0)
indentCount += classInitializerIndents;
}
else if (isInClassHeader || isInObjCInterface)
{
// is in a 'class A : public B' definition
Expand Down
44 changes: 30 additions & 14 deletions AStyle/src/astyle_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace astyle {
jmethodID g_mid;
#endif

const char* g_version = "3.2";
const char* g_version = "3.2.1";

//-----------------------------------------------------------------------------
// ASStreamIterator class
Expand Down Expand Up @@ -511,20 +511,35 @@ void ASConsole::correctMixedLineEnds(ostringstream& out)
// NOTE: some string functions don't work with NULLs (e.g. length())
FileEncoding ASConsole::detectEncoding(const char* data, size_t dataSize) const
{
FileEncoding encoding = ENCODING_8BIT;

if (dataSize >= 3 && memcmp(data, "\xEF\xBB\xBF", 3) == 0)
encoding = UTF_8BOM;
else if (dataSize >= 4 && memcmp(data, "\x00\x00\xFE\xFF", 4) == 0)
encoding = UTF_32BE;
else if (dataSize >= 4 && memcmp(data, "\xFF\xFE\x00\x00", 4) == 0)
encoding = UTF_32LE;
else if (dataSize >= 2 && memcmp(data, "\xFE\xFF", 2) == 0)
encoding = UTF_16BE;
else if (dataSize >= 2 && memcmp(data, "\xFF\xFE", 2) == 0)
encoding = UTF_16LE;
if (dataSize >= 3 && memcmp(data, "\xEF\xBB\xBF", 3) == 0)
{
return UTF_8BOM;
}

return encoding;
if (dataSize >= 4)
{
if (memcmp(data, "\x00\x00\xFE\xFF", 4) == 0)
{
return UTF_32BE;
}
else if (memcmp(data, "\xFF\xFE\x00\x00", 4) == 0)
{
return UTF_32LE;
}
}

if (dataSize >= 2)
{
if (memcmp(data, "\xFE\xFF", 2) == 0)
{
return UTF_16BE;
}
else if (memcmp(data, "\xFF\xFE", 2) == 0)
{
return UTF_16LE;
}
}
return ENCODING_8BIT;
}

// error exit without a message
Expand Down Expand Up @@ -996,6 +1011,7 @@ FileEncoding ASConsole::readFile(const string& fileName_, stringstream& in) cons
error(_("Cannot process UTF-32 encoding"), fileName_.c_str());
bool firstBlock = true;
bool isBigEndian = (encoding == UTF_16BE);

while (dataSize != 0)
{
if (encoding == UTF_16LE || encoding == UTF_16BE)
Expand Down

0 comments on commit 7e565cc

Please sign in to comment.