summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2010-12-13 18:47:23 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2010-12-13 18:47:23 (GMT)
commitc4e5d784609533e26ee9ea6459cd315bd9c3c0a4 (patch)
tree2d880770f0d854881655d69734f4112e22593017
parent485ac91fd7e1243fad8809c0664130b52c5fa0bb (diff)
downloadQt-c4e5d784609533e26ee9ea6459cd315bd9c3c0a4.zip
Qt-c4e5d784609533e26ee9ea6459cd315bd9c3c0a4.tar.gz
Qt-c4e5d784609533e26ee9ea6459cd315bd9c3c0a4.tar.bz2
Fixed macro argument handling.
Fixed macro definition parsing that confused someone into thinking that single backslashes would appear in macro definitions instead of control codes. Fixed a bug that caused only arguments in general macros to be handled. Enabled arguments in HTML macros.
-rw-r--r--tools/qdoc3/doc.cpp47
1 files changed, 42 insertions, 5 deletions
diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp
index f153dfb..a6e42c6 100644
--- a/tools/qdoc3/doc.cpp
+++ b/tools/qdoc3/doc.cpp
@@ -374,6 +374,7 @@ class DocParser
void leaveTableRow();
CodeMarker *quoteFromFile();
void expandMacro(const QString& name, const QString& def, int numParams);
+ QString expandMacroToString(const QString &name, const QString &def, int numParams);
Doc::SectioningUnit getSectioningUnit();
QString getArgument(bool verbatim = false);
QString getOptionalArgument();
@@ -1228,7 +1229,7 @@ void DocParser::parse(const QString& source,
}
else {
location().push(macro.defaultDefLocation.filePath());
- in.insert(pos, macro.defaultDef);
+ in.insert(pos, expandMacroToString(cmdStr, macro.defaultDef, macro.numParams));
len = in.length();
openedInputs.push(pos + macro.defaultDef.length());
}
@@ -1968,15 +1969,14 @@ void DocParser::expandMacro(const QString &name,
int j = 0;
while (j < def.size()) {
int paramNo;
- if ((def[j] == '\\') && (j < def.size() - 1) &&
- ((paramNo = def[j + 1].digitValue()) >= 1) &&
+ if (((paramNo = def[j].unicode()) >= 1) &&
(paramNo <= numParams)) {
if (!rawString.isEmpty()) {
append(Atom::RawString, rawString);
rawString = "";
}
append(Atom::String, args[paramNo - 1]);
- j += 2;
+ j += 1;
}
else {
rawString += def[j++];
@@ -1987,6 +1987,43 @@ void DocParser::expandMacro(const QString &name,
}
}
+QString DocParser::expandMacroToString(const QString &name, const QString &def, int numParams)
+{
+ if (numParams == 0) {
+ return def;
+ }
+ else {
+ QStringList args;
+ QString rawString;
+
+ for (int i = 0; i < numParams; i++) {
+ if (numParams == 1 || isLeftBraceAhead()) {
+ args << getArgument(true);
+ }
+ else {
+ location().warning(tr("Macro '\\%1' invoked with too few"
+ " arguments (expected %2, got %3)")
+ .arg(name).arg(numParams).arg(i));
+ break;
+ }
+ }
+
+ int j = 0;
+ while (j < def.size()) {
+ int paramNo;
+ if (((paramNo = def[j].unicode()) >= 1) &&
+ (paramNo <= numParams)) {
+ rawString += args[paramNo - 1];
+ j += 1;
+ }
+ else {
+ rawString += def[j++];
+ }
+ }
+ return rawString;
+ }
+}
+
Doc::SectioningUnit DocParser::getSectioningUnit()
{
QString name = getOptionalArgument();
@@ -2866,7 +2903,7 @@ void Doc::initialize(const Config& config)
QString def = config.getString(macroDotName + Config::dot + *f);
if (!def.isEmpty()) {
macro.otherDefs.insert(*f, def);
- int m = Config::numParams(macro.defaultDef);
+ int m = Config::numParams(def);
if (macro.numParams == -1) {
macro.numParams = m;
}