summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-02-23 15:45:51 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-02-24 13:41:47 -0300
commit0631e9642e7c8b615edb9bf31e3fcd95784b1eef (patch)
treea7b15ffc90c325b01a1a1e989858a63a767a2786
parent8c9f9660f04d1c5e462f6a815329bffa90327618 (diff)
Empty lines from custom code must be cropped.
This is to avoid lines composed only of irritating trailing spaces. Reviewed by Bruno Ara├║jo <bruno.araujo@openbossa.org> Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--generator.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/generator.cpp b/generator.cpp
index 376f5605..d1e89fd3 100644
--- a/generator.cpp
+++ b/generator.cpp
@@ -242,16 +242,22 @@ QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor)
}
}
+ static QRegExp emptyLine("\\s*[\\r]?[\\n]?\\s*");
+
foreach(QString line, lst) {
- while (line.end()->isSpace())
- line.chop(1);
- int limit = 0;
- for(int i = 0; i < spacesToRemove; ++i) {
- if (!line[i].isSpace())
- break;
- limit++;
+ if (!line.isEmpty() && !emptyLine.exactMatch(line)) {
+ while (line.end()->isSpace())
+ line.chop(1);
+ int limit = 0;
+ for(int i = 0; i < spacesToRemove; ++i) {
+ if (!line[i].isSpace())
+ break;
+ limit++;
+ }
+
+ s << indentor << line.remove(0, limit);
}
- s << indentor << line.remove(0, limit) << endl;
+ s << endl;
}
return s;
}