diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2018-10-31 15:15:02 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2018-11-01 15:07:05 +0000 |
commit | eafad93c3da9fae0e0445393a5a8d90348ae2e13 (patch) | |
tree | 818e1d0cda623717252c6d1f67688eb432246c6f /util/lexgen/generator.cpp | |
parent | c03803b9b37572b79a73dc33eb9f1efc9254d9da (diff) |
Make util/lexgen/ mention itself in its auto-gen line
In the process, update the README's e-mail address for Simon and
mention all recognized command-line options in the usage message. The
generated CSS scanner was also out of sync with our source, so update
it. Also fixed handling of FileHeader to cope with running from a
shadow build by handling paths relative to __FILE__; and revised the
CSS3 config to use the same copyright header as was already in use by
the existing generated file.
Change-Id: I918ff84dbdc95d0478fd6aa4ea74e9a221d1a476
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'util/lexgen/generator.cpp')
-rw-r--r-- | util/lexgen/generator.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/util/lexgen/generator.cpp b/util/lexgen/generator.cpp index edd2b603e7..481d586e73 100644 --- a/util/lexgen/generator.cpp +++ b/util/lexgen/generator.cpp @@ -29,6 +29,7 @@ #include "generator.h" #include <QFile> +#include <QDir> void Function::printDeclaration(CodeBlock &block, const QString &funcNamePrefix) const { @@ -505,14 +506,16 @@ QString Generator::generate() klass.addMember(Class::PublicMember, lexFunc); QString header; - QFile headerFile(headerFileName); - if (!headerFileName.isEmpty() - && headerFile.exists() - && headerFile.open(QIODevice::ReadOnly)) { - header = QString::fromUtf8(headerFile.readAll()); + if (!headerFileName.isEmpty()) { + QString self(QDir::fromNativeSeparators(QStringLiteral(__FILE__))); + int lastSep = self.lastIndexOf(QChar('/')); + QDir here(lastSep < 0 ? QStringLiteral(".") : self.left(lastSep)); + QFile headerFile(QDir::cleanPath(here.filePath(headerFileName))); + if (headerFile.exists() && headerFile.open(QIODevice::ReadOnly)) + header = QString::fromUtf8(headerFile.readAll()); } - header += QLatin1String("// auto generated. DO NOT EDIT.\n"); + header += QLatin1String("// auto generated by qtbase/util/lexgen/. DO NOT EDIT.\n"); return header + klass.declaration() + klass.definition(); } |