diff options
author | Paulo Alcantara <pcacjr@gmail.com> | 2011-12-13 14:33:47 -0300 |
---|---|---|
committer | Paulo Alcantara <pcacjr@gmail.com> | 2011-12-14 14:36:29 -0300 |
commit | 47b5467dc4f39954154a522d7f1b3ed2c2507f02 (patch) | |
tree | 9bde4712c0aacbadb07cba295c88a9503d209498 | |
parent | 23e0712360442e50f34be0d6e4651b8c4c806d47 (diff) |
Handle filenames that contain whitespaces properly.
Fixes bug #1053.
http://bugs.pyside.org/show_bug.cgi?id=1053
Signed-off-by: Paulo Alcantara <pcacjr@gmail.com>
Reviewed-by: Luciano Wolf <luciano.wolf@openbossa.org>
Reviewed-by: Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r-- | pylupdate/main.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/pylupdate/main.cpp b/pylupdate/main.cpp index 453f41e..8bcb15b 100644 --- a/pylupdate/main.cpp +++ b/pylupdate/main.cpp @@ -101,6 +101,34 @@ static void updateTsFiles( const MetaTranslator& fetchedTor, } } +/* The filename may contain double quotes when passing filenames with + * whitespaces. So we need to make it proper to be called with fopen() + * function. Handle them properly. +*/ +static inline const QStringList parseFileNames(const QString& line) +{ + QStringList retval; + + QString s; + unsigned int count = 0; + foreach(QChar c, line) { + if (c == '"') { /* we're still walking through the path... */ + count++; + } else if (c.isSpace() && !(count % 2)) { /* path is done! */ + /* append it to our list */ + retval << s; + s.clear(); + } else { + s += c; + } + } + + if (s.size()) + retval << s; /* append the last path to our list */ + + return retval; +} + int main( int argc, char **argv ) { QString defaultContext = "@default"; @@ -180,9 +208,9 @@ int main( int argc, char **argv ) QMap<QString, QString>::Iterator it; for ( it = tagMap.begin(); it != tagMap.end(); ++it ) { - QStringList toks = it.value().split(' '); - QStringList::Iterator t; + QStringList toks = parseFileNames(it.value()); + QStringList::Iterator t; for ( t = toks.begin(); t != toks.end(); ++t ) { if ( it.key() == "SOURCES" ) { fetchtr_py( (*t).toAscii(), &fetchedTor, defaultContext.toAscii(), true, codecForSource ); |