From b11317a64339f5a4bcffc8234ecaf15c7fb416f2 Mon Sep 17 00:00:00 2001 From: Axel Waggershauser Date: Fri, 15 Mar 2013 00:42:15 +0100 Subject: Whitespace cleanup: remove trailing whitespace Remove all trailing whitespace from the following list of files: *.cpp *.h *.conf *.qdoc *.pro *.pri *.mm *.rc *.pl *.qps *.xpm *.txt *README excluding 3rdparty, test-data and auto generated code. Note A): the only non 3rdparty c++-files that still have trailing whitespace after this change are: * src/corelib/codecs/cp949codetbl_p.h * src/corelib/codecs/qjpunicode.cpp * src/corelib/codecs/qbig5codec.cpp * src/corelib/xml/qxmlstream_p.h * src/tools/qdoc/qmlparser/qqmljsgrammar.cpp * src/tools/uic/ui4.cpp * tests/auto/other/qtokenautomaton/tokenizers/* * tests/benchmarks/corelib/tools/qstring/data.cpp * util/lexgen/tokenizer.cpp Note B): in about 30 files some overlapping 'leading tab' and 'TAB character in non-leading whitespace' issues have been fixed to make the sanity bot happy. Plus some general ws-fixes here and there as asked for during review. Change-Id: Ia713113c34d82442d6ce4d93d8b1cf545075d11d Reviewed-by: Oswald Buddenhagen --- util/lexgen/generator.cpp | 48 ++++++++++++++++++++-------------------- util/lexgen/generator.h | 36 +++++++++++++++--------------- util/lexgen/main.cpp | 4 ++-- util/lexgen/nfa.cpp | 4 ---- util/lexgen/nfa.h | 4 ++-- util/lexgen/tests/tst_lexgen.cpp | 2 +- 6 files changed, 47 insertions(+), 51 deletions(-) (limited to 'util/lexgen') diff --git a/util/lexgen/generator.cpp b/util/lexgen/generator.cpp index a6fc93c0ca..06ba586c1f 100644 --- a/util/lexgen/generator.cpp +++ b/util/lexgen/generator.cpp @@ -48,7 +48,7 @@ void Function::printDeclaration(CodeBlock &block, const QString &funcNamePrefix) block << (iline ? "inline " : "") << signature(funcNamePrefix) << (iline ? QLatin1String(" {") : QLatin1String(";")); if (!iline) return; - + block.indent(); QString tmp = body; if (tmp.endsWith(QLatin1Char('\n'))) @@ -81,7 +81,7 @@ QString Function::definition() const QString result; result += signature(); result += QLatin1String("\n{\n"); - + QString tmp = body; if (tmp.endsWith(QLatin1Char('\n'))) @@ -92,7 +92,7 @@ QString Function::definition() const tmp.replace(QLatin1Char('\n'), QLatin1String("\n ")); result += tmp; - + result += QLatin1String("\n}\n"); return result; @@ -102,16 +102,16 @@ void Class::Section::printDeclaration(const Class *klass, CodeBlock &block) cons { foreach (Function ctor, constructors) ctor.printDeclaration(block, klass->name()); - + if (!constructors.isEmpty()) block.addNewLine(); - + foreach (Function func, functions) func.printDeclaration(block); - + if (!functions.isEmpty()) block.addNewLine(); - + foreach (QString var, variables) block << var << ';'; } @@ -133,13 +133,13 @@ void Class::addConstructor(Access access, const QString &body, const QString &_a QString Class::Section::definition(const Class *klass) const { QString result; - + foreach (Function ctor, constructors) { ctor.setName(klass->name() + "::" + klass->name() + ctor.name()); result += ctor.definition(); result += QLatin1Char('\n'); } - + foreach (Function func, functions) { if (!func.hasBody()) continue; func.setName(klass->name() + "::" + func.name()); @@ -153,10 +153,10 @@ QString Class::Section::definition(const Class *klass) const QString Class::declaration() const { CodeBlock block; - + block << QLatin1String("class ") << cname; block << "{"; - + if (!sections[PublicMember].isEmpty()) { block << "public:"; block.indent(); @@ -170,7 +170,7 @@ QString Class::declaration() const sections[ProtectedMember].printDeclaration(this, block); block.outdent(); } - + if (!sections[PrivateMember].isEmpty()) { block << "private:"; block.indent(); @@ -180,7 +180,7 @@ QString Class::declaration() const block << "};"; block.addNewLine(); - + return block.toString(); } @@ -406,12 +406,12 @@ void Generator::generateTransitions(CodeBlock &body, const TransitionMap &transi QString Generator::generate() { Class klass(cfg.className); - + klass.addMember(Class::PublicMember, "QString input"); klass.addMember(Class::PublicMember, "int pos"); klass.addMember(Class::PublicMember, "int lexemStart"); klass.addMember(Class::PublicMember, "int lexemLength"); - + { CodeBlock body; body << "input = inp;"; @@ -420,7 +420,7 @@ QString Generator::generate() body << "lexemLength = 0;"; klass.addConstructor(Class::PublicMember, body, "const QString &inp"); } - + { Function next("QChar", "next()"); next.setInline(true); @@ -430,7 +430,7 @@ QString Generator::generate() next.addBody("return (pos < input.length()) ? input.at(pos++).toLower() : QChar();"); klass.addMember(Class::PublicMember, next); } - + /* { Function lexem("QString", "lexem()"); @@ -450,7 +450,7 @@ QString Generator::generate() Function lexFunc; lexFunc.setReturnType("int"); lexFunc.setName("lex()"); - + CodeBlock body; body << "lexemStart = pos;"; body << "lexemLength = 0;"; @@ -487,14 +487,14 @@ QString Generator::generate() body.outdent(); body.indent(); - + if (!dfa.at(i).transitions.isEmpty()) { body << "ch = next();"; generateTransitions(body, dfa.at(i).transitions); } - + body << "goto out;"; - + body.outdent(); } @@ -512,9 +512,9 @@ QString Generator::generate() body.outdent(); body << "}"; body << "return token;"; - + lexFunc.addBody(body); - + klass.addMember(Class::PublicMember, lexFunc); QString header; @@ -526,7 +526,7 @@ QString Generator::generate() } header += QLatin1String("// auto generated. DO NOT EDIT.\n"); - + return header + klass.declaration() + klass.definition(); } diff --git a/util/lexgen/generator.h b/util/lexgen/generator.h index 7037f13018..c56ee20756 100644 --- a/util/lexgen/generator.h +++ b/util/lexgen/generator.h @@ -82,11 +82,11 @@ public: delete shared; } } - + template LineStream &operator<<(const T &value) { (*shared->stream) << value; return *this; } - + SharedStream *shared; }; @@ -101,11 +101,11 @@ public: template LineStream operator<<(const T &value) { stream << indentStr; stream << value; return LineStream(&stream); } - + inline void addNewLine() { stream << endl; } - + inline QString toString() const { stream.flush(); return output; } - + private: QString output; mutable QTextStream stream; @@ -121,20 +121,20 @@ public: inline void setName(const QString &name) { fname = name; } inline QString name() const { return fname; } - + inline void setInline(bool i) { iline = i; } inline bool isInline() const { return iline; } - + inline void setReturnType(const QString &type) { rtype = type; } inline QString returnType() const { return rtype; } - + inline void addBody(const QString &_body) { body += _body; } inline void addBody(const CodeBlock &block) { body += block.toString(); } inline bool hasBody() const { return !body.isEmpty(); } - + inline void setConst(bool konst) { cnst = konst; } inline bool isConst() const { return cnst; } - + void printDeclaration(CodeBlock &block, const QString &funcNamePrefix = QString()) const; QString definition() const; @@ -157,19 +157,19 @@ public: inline void setName(const QString &name) { cname = name; } inline QString name() const { return cname; } - + inline void addMember(Access access, const QString &name) { sections[access].variables.append(name); } inline void addMember(Access access, const Function &func) { sections[access].functions.append(func); } - + void addConstructor(Access access, const QString &body, const QString &args = QString()); inline void addConstructor(Access access, const CodeBlock &body, const QString &args = QString()) { addConstructor(access, body.toString(), args); } - + QString declaration() const; QString definition() const; - + private: QString cname; struct Section @@ -177,10 +177,10 @@ private: QVector functions; QStringList variables; QVector constructors; - + inline bool isEmpty() const { return functions.isEmpty() && variables.isEmpty() && constructors.isEmpty(); } - + void printDeclaration(const Class *klass, CodeBlock &block) const; QString definition(const Class *klass) const; }; @@ -192,9 +192,9 @@ class Generator { public: Generator(const DFA &dfa, const Config &config); - + QString generate(); - + private: void generateTransitions(CodeBlock &body, const TransitionMap &transitions); bool isSingleReferencedFinalState(int i) const; diff --git a/util/lexgen/main.cpp b/util/lexgen/main.cpp index 7fdf587ae9..a6cd6ee94f 100644 --- a/util/lexgen/main.cpp +++ b/util/lexgen/main.cpp @@ -149,7 +149,7 @@ static QSet determineMaxInputSet(const ConfigFile::Section §ion) if (inputTypeName == "quint8") { for (int i = 1; i < 256; ++i) set.insert(i); - } /* else if ### */ + } /* else if ### */ else { qWarning("Error: Unknown input type '%s'", qPrintable(inputTypeName)); return QSet(); @@ -313,7 +313,7 @@ int main(int argc, char **argv) qDebug() << "Error while tokenizing!"; } else { Generator gen(machine, cfg); - QTextStream(stdout) + QTextStream(stdout) << gen.generate(); } diff --git a/util/lexgen/nfa.cpp b/util/lexgen/nfa.cpp index 5ae3beade5..1414d1eedd 100644 --- a/util/lexgen/nfa.cpp +++ b/util/lexgen/nfa.cpp @@ -288,7 +288,6 @@ DFA NFA::toDFA() const if (transition.key() == Epsilon && epsilonStates.contains(transition.value())) epsilonStates.insert(i, epsilonStates.value(transition.value())); } - } while (lastCount != epsilonStates.count()); for (int i = 0; i < states.count(); ++i) { @@ -313,7 +312,6 @@ DFA NFA::toDFA() const */ } - QSet validInput; foreach (const State &s, states) for (TransitionMap::ConstIterator it = s.transitions.constBegin(), @@ -504,5 +502,3 @@ DFA DFA::minimize() const return *this; } - - diff --git a/util/lexgen/nfa.h b/util/lexgen/nfa.h index 3eae9bcef8..0d8394a926 100644 --- a/util/lexgen/nfa.h +++ b/util/lexgen/nfa.h @@ -92,7 +92,7 @@ public: static NFA applyQuantity(const NFA &a, int minOccurrences, int maxOccurrences); void setTerminationSymbol(const QString &symbol); - + DFA toDFA() const; inline bool isEmpty() const { return states.isEmpty(); } @@ -113,7 +113,7 @@ private: inline void assertValidState(int state) { Q_UNUSED(state); Q_ASSERT(state >= 0); Q_ASSERT(state < states.count()); } - + #if defined(AUTOTEST) public: #endif diff --git a/util/lexgen/tests/tst_lexgen.cpp b/util/lexgen/tests/tst_lexgen.cpp index a3741d2373..f45d295633 100644 --- a/util/lexgen/tests/tst_lexgen.cpp +++ b/util/lexgen/tests/tst_lexgen.cpp @@ -227,7 +227,7 @@ void tst_LexGen::lexgen_data() d.cd("testdata"); foreach (QString test, d.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { QString dir = d.absoluteFilePath(test) + '/'; - QTest::newRow(qPrintable(test)) + QTest::newRow(qPrintable(test)) << dir + "rules.lexgen" << dir + "input" << dir + "output" -- cgit v1.2.3