summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2018-10-31 15:15:02 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2018-11-01 15:07:05 +0000
commiteafad93c3da9fae0e0445393a5a8d90348ae2e13 (patch)
tree818e1d0cda623717252c6d1f67688eb432246c6f /util
parentc03803b9b37572b79a73dc33eb9f1efc9254d9da (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')
-rw-r--r--util/lexgen/README3
-rw-r--r--util/lexgen/css3-simplified.lexgen2
-rw-r--r--util/lexgen/generator.cpp15
-rw-r--r--util/lexgen/main.cpp2
4 files changed, 12 insertions, 10 deletions
diff --git a/util/lexgen/README b/util/lexgen/README
index 435c7f31ee..005b77b81c 100644
--- a/util/lexgen/README
+++ b/util/lexgen/README
@@ -11,6 +11,5 @@ you want. But I like that it generates code that operates on QChar and friends.
Use at your own risk ;-)
-
--
-Simon Hausmann <simon.hausmann@digia.com>
+Simon Hausmann <simon.hausmann@qt.io>
diff --git a/util/lexgen/css3-simplified.lexgen b/util/lexgen/css3-simplified.lexgen
index 99463d524e..d86a4786be 100644
--- a/util/lexgen/css3-simplified.lexgen
+++ b/util/lexgen/css3-simplified.lexgen
@@ -5,7 +5,7 @@ classname = QCssScanner_Generated
[Code Generator Options]
MapToCode[a-z] = (ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256
TokenPrefix = QCss::
-FileHeader = ../../src/tools/moc/util/licenseheader.txt
+FileHeader = ../../header.LGPL
[Macros]
escape = \\[^\r\n\f0-9a-f]
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();
}
diff --git a/util/lexgen/main.cpp b/util/lexgen/main.cpp
index 22b99b633c..517629f4c1 100644
--- a/util/lexgen/main.cpp
+++ b/util/lexgen/main.cpp
@@ -256,7 +256,7 @@ int main(int argc, char **argv)
}
if (ruleFile.isEmpty()) {
- qWarning("usage: lexgen [-test rulefile");
+ qWarning("usage: lexgen [-debug] [-cache] [-test] rulefile");
qWarning(" ");
qWarning(" the -test option will cause lexgen to interpret standard input");
qWarning(" according to the specified rules and print out pairs of token and");