forked from qt-creator/qt-creator
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -701,11 +701,10 @@ const QtInfo &QtInfo::get(const SymbolGroupValueContext &ctx)
|
||||
}
|
||||
rc.libInfix = qualifiedSymbol.substr(libPos + 4, exclPos - libPos - 4);
|
||||
// 'Qt5Cored!qstrdup' or 'QtCored4!qstrdup'.
|
||||
if (isdigit(qualifiedSymbol.at(2))) {
|
||||
if (isdigit(qualifiedSymbol.at(2)))
|
||||
rc.version = qualifiedSymbol.at(2) - '0';
|
||||
} else {
|
||||
else
|
||||
rc.version = qualifiedSymbol.at(exclPos - 1) - '0';
|
||||
}
|
||||
// Any namespace? 'QtCored4!nsp::qstrdup'
|
||||
const std::string::size_type nameSpaceStart = exclPos + 1;
|
||||
const std::string::size_type colonPos = qualifiedSymbol.find(':', nameSpaceStart);
|
||||
@@ -1585,11 +1584,10 @@ static inline bool dumpQString(const SymbolGroupValue &v, std::wostream &str,
|
||||
} else {
|
||||
str << L"\"\"";
|
||||
}
|
||||
if (memoryHandle) {
|
||||
if (memoryHandle)
|
||||
*memoryHandle = new MemoryHandle(memory, size);
|
||||
} else {
|
||||
else
|
||||
delete [] memory;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1691,11 +1689,10 @@ static inline bool dumpQByteArray(const SymbolGroupValue &v, std::wostream &str,
|
||||
} else {
|
||||
str << L"<empty>";
|
||||
}
|
||||
if (memoryHandle) {
|
||||
if (memoryHandle)
|
||||
*memoryHandle = new MemoryHandle(reinterpret_cast<unsigned char *>(memory), size);
|
||||
} else {
|
||||
else
|
||||
delete [] memory;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2012,13 +2009,12 @@ static inline bool dumpQFlags(const SymbolGroupValue &v, std::wostream &str)
|
||||
|
||||
static bool dumpJulianDate(int julianDay, std::wostream &str)
|
||||
{
|
||||
if (julianDay < 0) {
|
||||
if (julianDay < 0)
|
||||
return false;
|
||||
} else if (!julianDay) {
|
||||
else if (!julianDay)
|
||||
str << L"<null>";
|
||||
} else {
|
||||
else
|
||||
formatJulianDate(str, julianDay);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2292,11 +2288,10 @@ static bool dumpStd_W_String(const SymbolGroupValue &v, int type, std::wostream
|
||||
str << (type == KT_StdString ?
|
||||
quotedWStringFromCharData(memory, memSize) :
|
||||
quotedWStringFromWCharData(memory, memSize));
|
||||
if (memoryHandle) {
|
||||
if (memoryHandle)
|
||||
*memoryHandle = new MemoryHandle(memory, memSize);
|
||||
} else {
|
||||
else
|
||||
delete [] memory;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2403,9 +2398,8 @@ static bool dumpQVariant(const SymbolGroupValue &v, std::wostream &str, void **s
|
||||
break;
|
||||
case 10: // String
|
||||
str << L"(QString) ";
|
||||
if (const SymbolGroupValue sv = dataV.typeCast(qtInfo.prependQtCoreModule("QString *").c_str())) {
|
||||
if (const SymbolGroupValue sv = dataV.typeCast(qtInfo.prependQtCoreModule("QString *").c_str()))
|
||||
dumpQString(sv, str);
|
||||
}
|
||||
break;
|
||||
case 11: //StringList: Dump container size
|
||||
str << L"(QStringList) ";
|
||||
|
||||
Reference in New Issue
Block a user