From 7e565ccc658c16c660b57f59556f83dcd24594c3 Mon Sep 17 00:00:00 2001 From: saalen Date: Sat, 1 Apr 2023 15:24:33 +0000 Subject: [PATCH] updated version; fixed indent of struct initializer lists git-svn-id: https://svn.code.sf.net/p/astyle/code/trunk@685 1fe3c263-5997-42ff-936f-87a7378ef0cd --- AStyle/src/ASBeautifier.cpp | 12 +++++----- AStyle/src/astyle_main.cpp | 44 +++++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/AStyle/src/ASBeautifier.cpp b/AStyle/src/ASBeautifier.cpp index 21e3842..9f69957 100644 --- a/AStyle/src/ASBeautifier.cpp +++ b/AStyle/src/ASBeautifier.cpp @@ -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; } @@ -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)) @@ -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 diff --git a/AStyle/src/astyle_main.cpp b/AStyle/src/astyle_main.cpp index a1537b8..28bd246 100644 --- a/AStyle/src/astyle_main.cpp +++ b/AStyle/src/astyle_main.cpp @@ -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 @@ -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 @@ -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)