diff -u -r rcomp-7.0.1-orig/src/main.cpp rcomp-7.0.1/src/main.cpp --- rcomp-7.0.1-orig/src/main.cpp 2003-12-27 22:33:24.000000000 +0200 +++ rcomp-7.0.1/src/main.cpp 2005-02-20 21:11:05.000000000 +0200 @@ -26,6 +26,8 @@ extern NameIdMap* pResourceNameIds; extern long CurrentId; +int symbianV6hack = 0; + void WriteHeaderFile(FILE* aRSG, IndexTable& aIndex) { IndexTableIterator next(aIndex); @@ -74,7 +76,7 @@ } } -void WriteBinaryResourceData(RCBinaryStream& aRSC, IndexTable& aIndex, int& aSizeOfLargestResourceWhenUncompressed) +int WriteBinaryResourceData(RCBinaryStream& aRSC, IndexTable& aIndex, int& aSizeOfLargestResourceWhenUncompressed) { IndexTableIterator next(aIndex); IndexTableItem * p; @@ -83,10 +85,32 @@ p->SetOffset(aRSC.GetPosition()); // record start of this resource in the index p->Resource().StreamOut(aRSC, aSizeOfLargestResourceWhenUncompressed); // write out binary form of resource } + return aRSC.GetPosition(); } void WriteResourceFile(RCBinaryStream& aRSC, IndexTable& aIndex, LinkArray& aLinks, bool aThirdUidIsOffset) { + if (symbianV6hack) { + const int positionToOverWriteFrom=aRSC.GetPosition(); + NumericValue twoByteSizeOfLargestResourceWhenUncompressed(L_WORD); + aRSC << twoByteSizeOfLargestResourceWhenUncompressed; + WriteBitArrayOfResourcesContainingCompressedUnicode(aRSC, aIndex); // simply makes space for the bit-array without writing anything sensible in it (as we don't yet know which resources will contain compressed Unicode) + int sizeOfLargestResourceWhenUncompressed=0; + int offs = WriteBinaryResourceData(aRSC, aIndex, sizeOfLargestResourceWhenUncompressed); + aIndex.SetIndexOffset(aRSC.GetPosition()); + aRSC << aIndex; + int endPos = aRSC.GetPosition(); + aRSC.SetPosition(positionToOverWriteFrom); + NumericValue startPositionOfOffset(L_WORD); + NumericValue indexLengthInBytes(L_WORD); + startPositionOfOffset = offs; + indexLengthInBytes = (1 + endPos - offs); + aRSC << startPositionOfOffset; + aRSC << indexLengthInBytes; + WriteBitArrayOfResourcesContainingCompressedUnicode(aRSC, aIndex); // overwrites the bit array with correct data + aLinks.OverwriteLinks(aRSC); // this jumps about all over the place, overwriting anywhere where there is a LINK or LLINK + + } else { char flags=0; if (aThirdUidIsOffset) { @@ -106,7 +130,7 @@ aRSC << twoByteSizeOfLargestResourceWhenUncompressed; WriteBitArrayOfResourcesContainingCompressedUnicode(aRSC, aIndex); // overwrites the bit array with correct data aLinks.OverwriteLinks(aRSC); // this jumps about all over the place, overwriting anywhere where there is a LINK or LLINK - + } if(verbose) { MOFF; cout << aIndex; cout << endl; MON; @@ -121,6 +145,7 @@ cerr << "\tp" << "\tParser debugging" << endl; cerr << endl; cerr << "\tu" << "\tGenerate Unicode resource binary" << endl; + cerr << "\t6" << "\tGenerate Symbian OS V6 binary" << endl; cerr << endl; cerr << "If no source file is specified, the source will be read from standard input." << endl; cerr << "(-i is used to specify the file given to the preprocessor this " << endl; @@ -227,6 +252,13 @@ TargetCharacterSet = String::Unicode; } + if(strchr(settings, '6')) + { + SourceCharacterSet = String::CP1252; + TargetCharacterSet = String::Unicode; + symbianV6hack = 1; + } + if(strchr(settings, 'v') || strchr(settings, 'V') ) vParam = 1; if(strchr(settings, 'p') || strchr(settings, 'P')) @@ -291,14 +323,20 @@ } char uidcrc_params[256]; - const int ret = snprintf(uidcrc_params, - sizeof(uidcrc_params), - "%s %s %s %s %s", - uidcrcTool, - uidcrcUIDs[0], - uidcrcUIDs[1], - uidcrcUIDs[2], - DataOutputFileName.GetBuffer()); + int ret; + if (symbianV6hack) { + ret = snprintf(uidcrc_params, sizeof(uidcrc_params), + "touch %s", DataOutputFileName.GetBuffer()); + } else { + ret = snprintf(uidcrc_params, + sizeof(uidcrc_params), + "%s %s %s %s %s", + uidcrcTool, + uidcrcUIDs[0], + uidcrcUIDs[1], + uidcrcUIDs[2], + DataOutputFileName.GetBuffer()); + } if(ret <= 0) { cerr << "Failed to write UIDs to " << DataOutputFileName << endl; exit(ret); diff -u -r rcomp-7.0.1-orig/src/rcbinstr.cpp rcomp-7.0.1/src/rcbinstr.cpp --- rcomp-7.0.1-orig/src/rcbinstr.cpp 2005-02-07 08:36:01.000000000 +0200 +++ rcomp-7.0.1/src/rcbinstr.cpp 2005-02-20 20:39:33.000000000 +0200 @@ -15,6 +15,8 @@ extern long CurrentId; extern RCTypeArray gTypes; +extern int symbianV6hack; + RCBinaryStream::RCBinaryStream() {} @@ -30,7 +32,7 @@ void RCBinaryStream::OpenForAppend(const String& FileName) { assert( !IsOpen()); - iOs.open( FileName.GetBuffer(), ios::out | ios::in | ios::binary | ios::ate); + iOs.open( FileName.GetBuffer(), ios::out | ios::binary | ios::ate); } int RCBinaryStream::IsOpen() @@ -283,9 +285,11 @@ ++i; // skip a loop iteration - we know that EMarkType_StartOfCompressedUnicodeRun marks are always followed by a EMarkType_EndOfCompressedUnicodeRun mark Mark& nextMark=iArrayOfMarks.MarkAt(i); assert(nextMark.iMarkType==EMarkType_EndOfCompressedUnicodeRun); - const int numberOfBytesWhenCompressed=nextMark.iBufferPosition-mark.iBufferPosition; + const int numberOfBytesWhenCompressed= (symbianV6hack) ? (numberOfBytesWhenUncompressed + 100) : (nextMark.iBufferPosition-mark.iBufferPosition); assert((numberOfBytesWhenCompressed>0) || !encounteredCompressedUnicode[pass]); // compressed-Unicode runs are of non-zero size apart from the compulsory initial compressed-Unicode run if the resource does not actually start with compressed Unicode - assert((numberOfBytesWhenCompressed