From 6ea57f2f17169babe378d37a5e4753397fb69d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Skowro=C5=84ski?= Date: Sun, 17 Apr 2016 19:39:25 +0200 Subject: 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. --- pyrcc/rcc.cpp | 26 ++++++++++++++++++-------- 1 file 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 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 names; QStack 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 pending; if (!root) @@ -518,7 +528,7 @@ RCCResourceLibrary::writeDataStructure(FILE *out) pending.push(child); } } - fprintf(out, "\"\n"); + fprintf(out, "\"\n\n"); return true; } -- cgit v1.2.3