diff options
author | Mateusz SkowroĊski <skowri@gmail.com> | 2016-04-17 19:39:25 +0200 |
---|---|---|
committer | Thomas Karl Pietrowski <thopiekar@googlemail.com> | 2016-04-17 19:39:25 +0200 |
commit | 6ea57f2f17169babe378d37a5e4753397fb69d5f (patch) | |
tree | c5887827d1cfa68ce7b4ef9f633c6cc841892d0a | |
parent | 077a860c8b34f6c6a0d6438503164447a8561a12 (diff) |
Fix generating of resource files (#6)
* Format resource files similar to the C++ version.
* Fix generating of resource files for Qt5.
Use qt_hash() function instead of qHash() which guarantees the results will always be the same.
-rw-r--r-- | pyrcc/rcc.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/pyrcc/rcc.cpp b/pyrcc/rcc.cpp index 7d380b0..aa7451e 100644 --- a/pyrcc/rcc.cpp +++ b/pyrcc/rcc.cpp @@ -100,6 +100,7 @@ bool RCCFileInfo::writeDataInfo(FILE *out) //data offset qt_rcc_write_number(out, dataOffset, 4); } + fprintf(out, "\\\n"); return true; } @@ -131,15 +132,19 @@ qint64 RCCFileInfo::writeDataBlob(FILE *out, qint64 offset) //write the length qt_rcc_write_number(out, data.size(), 4); + fprintf(out, "\\\n"); offset += 4; //write the payload for (int i=0; i<data.size(); i++) { qt_rcc_write_number(out, data.at(i), 1); + if(!(i % 16)) + fprintf(out, "\\\n"); } offset += data.size(); //done + fprintf(out, "\\\n"); return offset; } @@ -150,20 +155,25 @@ qint64 RCCFileInfo::writeDataName(FILE *out, qint64 offset) //write the length qt_rcc_write_number(out, name.length(), 2); + fprintf(out, "\\\n"); offset += 2; //write the hash - qt_rcc_write_number(out, qHash(name), 4); + qt_rcc_write_number(out, qt_hash(name), 4); + fprintf(out, "\\\n"); offset += 4; //write the name const QChar *unicode = name.unicode(); for (int i=0; i<name.length(); i++) { qt_rcc_write_number(out, unicode[i].unicode(), 2); + if(!(i % 16)) + fprintf(out, "\\\n"); } offset += name.length()*2; //done + fprintf(out, "\\\n"); return offset; } @@ -411,7 +421,7 @@ RCCResourceLibrary::writeHeader(FILE *out) bool RCCResourceLibrary::writeDataBlobs(FILE *out) { - fprintf(out, "qt_resource_data = %s\"", mPrefix); + fprintf(out, "qt_resource_data = %s\"\\\n", mPrefix); QStack<RCCFileInfo*> pending; if (!root) @@ -430,14 +440,14 @@ RCCResourceLibrary::writeDataBlobs(FILE *out) offset = child->writeDataBlob(out, offset); } } - fprintf(out, "\"\n"); + fprintf(out, "\"\n\n"); return true; } bool RCCResourceLibrary::writeDataNames(FILE *out) { - fprintf(out, "qt_resource_name = %s\"", mPrefix); + fprintf(out, "qt_resource_name = %s\"\\\n", mPrefix); QHash<QString, int> names; QStack<RCCFileInfo*> pending; @@ -462,19 +472,19 @@ RCCResourceLibrary::writeDataNames(FILE *out) } } } - fprintf(out, "\"\n"); + fprintf(out, "\"\n\n"); return true; } static bool qt_rcc_compare_hash(const RCCFileInfo *left, const RCCFileInfo *right) { - return qHash(left->name) < qHash(right->name); + return qt_hash(left->name) < qt_hash(right->name); } bool RCCResourceLibrary::writeDataStructure(FILE *out) { - fprintf(out, "qt_resource_struct = %s\"", mPrefix); + fprintf(out, "qt_resource_struct = %s\"\\\n", mPrefix); QStack<RCCFileInfo*> pending; if (!root) @@ -518,7 +528,7 @@ RCCResourceLibrary::writeDataStructure(FILE *out) pending.push(child); } } - fprintf(out, "\"\n"); + fprintf(out, "\"\n\n"); return true; } |