- updated the makefiles and code to allow compliation with MinGW once again (some of patch #875485 by perditionc)

- fixed errors and warnings given by gcc


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3513 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2004-03-12 20:43:54 +00:00
parent 2b3da85bae
commit f4a1f17299
43 changed files with 323 additions and 252 deletions

View file

@ -620,7 +620,7 @@ Section "NSIS Source Code" SecSrcNSIS
File ..\Source\*.cpp
File ..\Source\*.c
File ..\Source\*.h
; outdated - File ..\Source\Makefile
File ..\Source\Makefile
File ..\Source\makenssi.dsp
File ..\Source\makenssi.dsw
# zlib
@ -652,7 +652,7 @@ Section "NSIS Source Code" SecSrcNSIS
File ..\Source\exehead\*.h
File ..\Source\exehead\resource.rc
File ..\Source\exehead\*.dsp
; outdated - File ..\Source\exehead\Makefile
File ..\Source\exehead\Makefile
File ..\Source\exehead\nsis.ico
File ..\Source\exehead\uninst.ico
File ..\Source\exehead\bitmap1.bmp

View file

@ -47,7 +47,7 @@ protected:
_state.Init();
_previousByte = 0;
_peviousIsMatch = false;
for(int i = 0 ; i < kNumRepDistances; i++)
for(unsigned int i = 0 ; i < kNumRepDistances; i++)
_repDistances[i] = 0;
}
};

View file

@ -88,10 +88,10 @@ const int kDefaultDictionaryLogSize = 20;
const UINT32 kNumFastBytesDefault = 0x20;
CEncoder::CEncoder():
_dictionarySize(1 << kDefaultDictionaryLogSize),
_dictionarySizePrev(UINT32(-1)),
_numFastBytes(kNumFastBytesDefault),
_numFastBytesPrev(UINT32(-1)),
_dictionarySize(1 << kDefaultDictionaryLogSize),
_dictionarySizePrev(UINT32(-1)),
_distTableSize(kDefaultDictionaryLogSize * 2),
_posStateBits(2),
_posStateMask(4 - 1),
@ -106,7 +106,7 @@ CEncoder::CEncoder():
_maxMode = false;
_fastMode = false;
_posAlignEncoder.Create(kNumAlignBits);
for(int i = 0; i < kNumPosModels; i++)
for(unsigned int i = 0; i < kNumPosModels; i++)
_posEncoders[i].Create(((kStartPosModelIndex + i) >> 1) - 1);
}
@ -181,7 +181,7 @@ HRESULT CEncoder::Create()
return S_OK;
}
inline AreStringsEqual(const wchar_t *s, const wchar_t *testString)
inline bool AreStringsEqual(const wchar_t *s, const wchar_t *testString)
{
while (true)
{
@ -231,8 +231,9 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
return E_INVALIDARG;
int matchFinderIndexPrev = _matchFinderIndex;
_matchFinderIndex = 0;
const kNumMFs = sizeof(kMatchFinderIDs) / sizeof(kMatchFinderIDs[0]);
for (int m = 0; m < kNumMFs; m++)
const unsigned kNumMFs = sizeof(kMatchFinderIDs) / sizeof(kMatchFinderIDs[0]);
unsigned int m;
for (m = 0; m < kNumMFs; m++)
{
if (AreStringsEqual(kMatchFinderIDs[m], prop.bstrVal))
{
@ -257,7 +258,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
#endif
case NCoderPropID::kDictionarySize:
{
const int kDicLogSizeMaxCompress = 28;
const unsigned int kDicLogSizeMaxCompress = 28;
if (prop.vt != VT_UI4)
return E_INVALIDARG;
UINT32 dictionarySize = prop.ulVal;
@ -277,7 +278,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
if (prop.vt != VT_UI4)
return E_INVALIDARG;
UINT32 value = prop.ulVal;
if (value > NLength::kNumPosStatesBitsEncodingMax)
if (value > (UINT32) NLength::kNumPosStatesBitsEncodingMax)
return E_INVALIDARG;
_posStateBits = value;
_posStateMask = (1 << _posStateBits) - 1;
@ -288,7 +289,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
if (prop.vt != VT_UI4)
return E_INVALIDARG;
UINT32 value = prop.ulVal;
if (value > kNumLitPosStatesBitsEncodingMax)
if (value > (unsigned) kNumLitPosStatesBitsEncodingMax)
return E_INVALIDARG;
_numLiteralPosStateBits = value;
break;
@ -298,7 +299,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
if (prop.vt != VT_UI4)
return E_INVALIDARG;
UINT32 value = prop.ulVal;
if (value > kNumLitContextBitsMax)
if (value > (unsigned) kNumLitContextBitsMax)
return E_INVALIDARG;
_numLiteralContextBits = value;
break;
@ -325,7 +326,7 @@ STDMETHODIMP CEncoder::Init(
// RINOK(_matchFinder->Init(inStream));
_rangeEncoder.Init(outStream);
int i;
unsigned int i;
for(i = 0; i < kNumStates; i++)
{
for (UINT32 j = 0; j <= _posStateMask; j++)
@ -442,7 +443,7 @@ UINT32 CEncoder::GetOptimum(UINT32 &backRes, UINT32 position)
UINT32 reps[kNumRepDistances];
UINT32 repLens[kNumRepDistances];
UINT32 repMaxIndex = 0;
int i;
unsigned int i;
for(i = 0; i < kNumRepDistances; i++)
{
reps[i] = _repDistances[i];
@ -526,7 +527,7 @@ UINT32 CEncoder::GetOptimum(UINT32 &backRes, UINT32 position)
for (; len <= lenMain; len++)
_optimum[len].Price = kIfinityPrice;
for(i = 0; i < kNumRepDistances; i++)
for(i = 0; i < (int) kNumRepDistances; i++)
{
UINT repLen = repLens[i];
for(UINT32 lenTest = 2; lenTest <= repLen; lenTest++)
@ -880,7 +881,7 @@ UINT32 CEncoder::GetOptimumFast(UINT32 &backRes, UINT32 position)
}
UINT32 repLens[kNumRepDistances];
UINT32 repMaxIndex = 0;
for(int i = 0; i < kNumRepDistances; i++)
for(unsigned int i = 0; i < kNumRepDistances; i++)
{
repLens[i] = _matchFinder->GetMatchLen(0 - 1, _repDistances[i], kMatchMaxLen);
if (i == 0 || repLens[i] > repLens[repMaxIndex])
@ -939,7 +940,7 @@ UINT32 CEncoder::GetOptimumFast(UINT32 &backRes, UINT32 position)
backRes = UINT32(-1);
return 1;
}
for(int i = 0; i < kNumRepDistances; i++)
for(unsigned int i = 0; i < kNumRepDistances; i++)
{
UINT32 repLen = _matchFinder->GetMatchLen(0 - 1, _repDistances[i], kMatchMaxLen);
if (repLen >= 2 && repLen + 1 >= lenMain)
@ -1096,11 +1097,11 @@ HRESULT CEncoder::CodeOneBlock(UINT64 *inSize, UINT64 *outSize, INT32 *finished)
else
len = GetOptimum(pos, UINT32(nowPos64));
if(len == 1 && pos == (-1))
if(len == 1 && pos == (UINT32)(-1))
{
_mainChoiceEncoders[_state.Index][posState].Encode(&_rangeEncoder, kMainChoiceLiteralIndex);
_state.UpdateChar();
BYTE matchByte;
BYTE matchByte = 0;
if(_peviousIsMatch)
matchByte = _matchFinder->GetIndexByte(0 - _repDistances[0] - 1 - _additionalOffset);
BYTE curByte = _matchFinder->GetIndexByte(0 - _additionalOffset);
@ -1226,7 +1227,7 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
void CEncoder::FillPosSlotPrices()
{
for (int lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
for (unsigned int lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
{
UINT32 posSlot;
for (posSlot = 0; posSlot < kEndPosModelIndex && posSlot < _distTableSize; posSlot++)
@ -1239,7 +1240,7 @@ void CEncoder::FillPosSlotPrices()
void CEncoder::FillDistancesPrices()
{
for (int lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
for (unsigned int lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
{
UINT32 i;
for (i = 0; i < kStartPosModelIndex; i++)
@ -1256,7 +1257,7 @@ void CEncoder::FillDistancesPrices()
void CEncoder::FillAlignPrices()
{
for (int i = 0; i < kAlignTableSize; i++)
for (int i = 0; i < (int) kAlignTableSize; i++)
_alignPrices[i] = _posAlignEncoder.GetPrice(i);
_alignPriceCount = kAlignTableSize;
}

View file

@ -103,7 +103,10 @@ private:
bool _fastMode;
bool _maxMode;
UINT32 _numFastBytes;
UINT32 _numFastBytesPrev;
UINT32 _longestMatchLength;
UINT32 _additionalOffset;
@ -120,6 +123,9 @@ private:
UINT32 _alignPrices[kAlignTableSize];
UINT32 _alignPriceCount;
UINT32 _dictionarySize;
UINT32 _dictionarySizePrev;
UINT32 _distTableSize;
UINT32 _posStateBits;
@ -127,11 +133,6 @@ private:
UINT32 _numLiteralPosStateBits;
UINT32 _numLiteralContextBits;
UINT32 _dictionarySize;
UINT32 _dictionarySizePrev;
UINT32 _numFastBytesPrev;
UINT64 lastPosSlotFillingPos;
UINT64 nowPos64;
bool _finished;

View file

@ -615,4 +615,4 @@ int LZMACALL lzmaDecompress(CLZMAStateP lzmaState)
return lzmaState->res;
return 0;
}
}

View file

@ -18,7 +18,7 @@ LZMA SDK 4.01 Copyright (c) 1999-2004 Igor Pavlov (2004-02-15)
/* Enable local speed optimizations inside code */
#ifndef LZMACALL
# define LZMACALL stdcall
# define LZMACALL
#endif
#ifndef FORCE_INLINE

View file

@ -64,7 +64,7 @@ void ReadVarLenArr(BYTE* &seeker, char* &readInto, unsigned int uCodePage) {
if (IS_INTRESOURCE(x)) { \
*(WORD*)seeker = 0xFFFF; \
seeker += sizeof(WORD); \
*(WORD*)seeker = WORD(x); \
*(WORD*)seeker = WORD(DWORD(x)); \
seeker += sizeof(WORD); \
} \
else { \

View file

@ -1,74 +1,83 @@
#
# This makefile for mingw32 by Nels. Thanks, Nels
#
#
# -- Subdirs --
SUBDIRS = exehead
# -- Objects and source files --
SRCS = crc32.c build.cpp exedata.cpp makenssi.cpp script.cpp tokens.cpp util.cpp ResourceEditor.cpp DialogTemplate.cpp ./zlib/deflate.c ./zlib/trees.c ./bzip2/blocksort.c ./bzip2/bzlib.c ./bzip2/compress.c ./bzip2/huffman.c
OBJS = build.o exedata.o makenssi.o script.o tokens.o util.o script1.res crc32.o ResourceEditor.o DialogTemplate.o deflate.o trees.o blocksort.o bzlib.o compress.o huffman.o
LIBS = -lgdi32 -lversion
SRCS = zlib/deflate.c zlib/trees.c bzip2/blocksort.c bzip2/bzlib.c bzip2/compress.c bzip2/huffman.c 7zip/7zGuids.cpp 7zip/Common/CRC.cpp 7zip/7zip/Compress/LZ/LZInWindow.cpp 7zip/7zip/Compress/LZMA/LZMAEncoder.cpp 7zip/7zip/Compress/LZMA/LZMALen.cpp 7zip/7zip/Compress/LZMA/LZMALiteral.cpp 7zip/7zip/Common/OutBuffer.cpp 7zip/7zip/Compress/RangeCoder/RangeCoderBit.cpp build.cpp crc32.c DialogTemplate.cpp exedata.cpp lang.cpp makenssi.cpp Plugins.cpp ResourceEditor.cpp ResourceVersionInfo.cpp script.cpp tokens.cpp util.cpp
OBJS = 7zGuids.o blocksort.o build.o bzlib.o compress.o CRC.o crc32.o deflate.o DialogTemplate.o exedata.o huffman.o lang.o LZInWindow.o LZMAEncoder.o LZMALen.o LZMALiteral.o makenssi.o OutBuffer.o Plugins.o RangeCoderBit.o ResourceEditor.o ResourceVersionInfo.o script.o tokens.o trees.o util.o
LIBS = -lgdi32 -lversion -lstdc++
# -- Required .h files --
BASEINC = Platform.h exehead/config.h
# -- Programs --
MAKE = make
CC = gcc
RC = windres
RM = del
RM = rm
# -- Compilers and linker flags --
DEFINES = -DWIN32 -D_WINDOWS_
CFLAGS = -O2 $(DEFINES)
CPPFLAGS = -O2 -fvtable-thunks $(DEFINES)
CFLAGS = -Wall -O2 $(DEFINES)
CPPFLAGS = -Wall -O2 $(DEFINES)
LFLAGS = -s
RCFLAGS = --input-format rc --output-format coff
all : subdirs makensis
all : exehead_zlib exehead_bzip2 exehead_lzma exehead_resources makensis
subdirs: $(SUBDIRS)
$(SUBDIRS)::
$(MAKE) -C $@ all
exehead_zlib exehead_bzip2 exehead_lzma exehead_resources :
$(MAKE) -C exehead $@
makensis : $(OBJS)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LFLAGS) -o makensis.exe $(OBJS) $(LIBS)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LFLAGS) -o ../makensis.exe $(OBJS) $(LIBS)
# -- Dependencies --
build.o : build.cpp ./zlib/zlib.h ./exehead/config.h ./exehead/fileform.h ./exehead/resource.h exedata.h build.h util.h strlist.h lineparse.h ResourceEditor.h Makefile
exedata.o : exedata.cpp exedata.h ./exehead/Release/bitmap1.h ./exehead/Release/bitmap2.h ./exehead/Release/icon.h ./exehead/Release/unicon.h ./exehead/Release/exehead.h Makefile
makenssi.o : makenssi.cpp build.h util.h exedata.h strlist.h lineparse.h ./exehead/fileform.h ./exehead/config.h Makefile
script.o : script.cpp tokens.h build.h util.h exedata.h strlist.h lineparse.h ResourceEditor.h DialogTemplate.h ./exehead/resource.h ./exehead/fileform.h ./exehead/config.h Makefile
build.o : build.cpp ./zlib/zlib.h $(BASEINC) ./exehead/fileform.h ./exehead/resource.h exedata.h build.h util.h strlist.h lineparse.h ResourceEditor.h Makefile
exedata.o : exedata.cpp exedata.h ./exehead/Release-zlib/bitmap1.h ./exehead/Release-zlib/icon.h ./exehead/Release-zlib/unicon.h ./exehead/Release-zlib/exehead_zlib.h Makefile
makenssi.o : makenssi.cpp build.h util.h exedata.h strlist.h lineparse.h ./exehead/fileform.h $(BASEINC) Makefile
script.o : script.cpp tokens.h build.h util.h exedata.h strlist.h lineparse.h ResourceEditor.h DialogTemplate.h ./exehead/resource.h ./exehead/fileform.h $(BASEINC) Makefile
tokens.o : tokens.cpp build.h tokens.h Makefile
util.o : util.cpp ./exehead/fileform.h util.h strlist.h ResourceEditor.h Makefile
crc32.o : crc32.c ./exehead/config.h Makefile
crc32.o : crc32.c $(BASEINC) Makefile
ResourceEditor.o : ResourceEditor.cpp
DialogTemplate.o : DialogTemplate.cpp
# -- Special command line for the resource file --
script1.res : script1.rc resource.h Makefile
$(RC) $(RCFLAGS) -o script1.res -i script1.rc
# -- Special command lines for zlib --
deflate.o : ./zlib/deflate.c ./zlib/deflate.h ./zlib/zutil.h ./zlib/zlib.h ./zlib/zconf.h Makefile ./exehead/config.h
$(CC) $(CFLAGS) -c ./zlib/deflate.c -o deflate.o
trees.o : ./zlib/trees.c ./zlib/deflate.h ./zlib/zutil.h ./zlib/zlib.h ./zlib/zconf.h Makefile ./exehead/config.h
$(CC) $(CFLAGS) -c ./zlib/trees.c -o trees.o
deflate.o : zlib/deflate.c
$(CC) $(CFLAGS) -c $< -o $@
trees.o : zlib/trees.c
$(CC) $(CFLAGS) -c $< -o $@
# -- Special command lines for bzip2 --
blocksort.o : ./bzip2/blocksort.c ./bzip2/bzlib.h ./bzip2/bzlib_private.h ./exehead/config.h
$(CC) $(CFLAGS) -c ./bzip2/blocksort.c -o blocksort.o
bzlib.o : ./bzip2/bzlib.c ./bzip2/bzlib.h ./bzip2/bzlib_private.h ./exehead/config.h
$(CC) $(CFLAGS) -c ./bzip2/bzlib.c -o bzlib.o
compress.o : ./bzip2/compress.c ./bzip2/bzlib.h ./bzip2/bzlib_private.h ./exehead/config.h
$(CC) $(CFLAGS) -c ./bzip2/compress.c -o compress.o
huffman.o : ./bzip2/huffman.c ./bzip2/bzlib.h ./bzip2/bzlib_private.h ./exehead/config.h
$(CC) $(CFLAGS) -c ./bzip2/huffman.c -o huffman.o
blocksort.o : bzip2/blocksort.c
$(CC) $(CFLAGS) -c $< -o $@
bzlib.o : bzip2/bzlib.c
$(CC) $(CFLAGS) -c $< -o $@
compress.o : bzip2/compress.c
$(CC) $(CFLAGS) -c $< -o $@
huffman.o : bzip2/huffman.c
$(CC) $(CFLAGS) -c $< -o $@
# -- Special command lines for lzma --
7zGuids.o : 7zip/7zGuids.cpp
$(CC) $(CFLAGS) -c $< -o $@
CRC.o : 7zip/Common/CRC.cpp
$(CC) $(CFLAGS) -c $< -o $@
LZInWindow.o : 7zip/7zip/Compress/LZ/LZInWindow.cpp
$(CC) $(CFLAGS) -c $< -o $@
LZMAEncoder.o : 7zip/7zip/Compress/LZMA/LZMAEncoder.cpp
$(CC) $(CFLAGS) -c $< -o $@
LZMALen.o : 7zip/7zip/Compress/LZMA/LZMALen.cpp
$(CC) $(CFLAGS) -c $< -o $@
LZMALiteral.o : 7zip/7zip/Compress/LZMA/LZMALiteral.cpp
$(CC) $(CFLAGS) -c $< -o $@
OutBuffer.o : 7zip/7zip/Common/OutBuffer.cpp
$(CC) $(CFLAGS) -c $< -o $@
RangeCoderBit.o : 7zip/7zip/Compress/RangeCoder/RangeCoderBit.cpp
$(CC) $(CFLAGS) -c $< -o $@
# -- Clean script --
clean ::
$(MAKE) -C exehead clean
$(RM) *.o
$(RM) script1.res
$(RM) makensis.exe
$(RM) ../makensis.exe

View file

@ -4,6 +4,9 @@
// includes
#ifdef _WIN32
# ifndef _WIN32_IE
# define _WIN32_IE 0x0400
# endif
# include <Windows.h>
# include <commctrl.h>
#else
@ -27,6 +30,27 @@
# endif
#endif
// Added by Dave Laundon 19th August 2002
// For all internal functions, use of stdcall calling convention moves the
// responsibility for tidying the stack to callee from caller, reducing the code
// involved considerably. Gives an instant saving of 0.5K.
// NB - the zlib and bzip2 portions have been given the same treatment, but with
// project compiler-options settings and/or project-wide defines.
// NB - safer for NSIS's routines to be defined explicitly to avoid problems
// calling DLL functions.
#if defined(_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
# define NSISCALL __stdcall // Ordinary functions
# define NSISCALLV __cdecl // Variable-argument-list functions
#else
# ifdef __GNUC__
# define NSISCALL __attribute__((__stdcall__)) // Ordinary functions
# define NSISCALLV __attribute__((__cdecl__)) // Variable-argument-list functions
# else
# define NSISCALL
# define NSISCALLV
# endif
#endif
// defines
#ifndef FOF_NOERRORUI
@ -69,8 +93,15 @@
#define LVS_EX_LABELTIP 0x00004000
#endif
#ifndef INVALID_FILE_ATTRIBUTES
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
#ifdef __GNUC__ // ((DWORD)-1) may cause parsing errors with MinGW
# ifdef INVALID_FILE_ATTRIBUTES // updated win32api may also set as (DWORD)-1
# undef INVALID_FILE_ATTRIBUTES
# endif
# define INVALID_FILE_ATTRIBUTES ((unsigned long)-1)
#else
# ifndef INVALID_FILE_ATTRIBUTES
# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
# endif
#endif
#ifndef CSIDL_FLAG_CREATE

View file

@ -119,7 +119,7 @@ void Plugins::GetExports(char* pathToDll, bool displayInfo)
&& sections[i].VirtualAddress+sections[i].Misc.VirtualSize >= ExportDirVA+ExportDirSize)
{
PIMAGE_EXPORT_DIRECTORY exports = PIMAGE_EXPORT_DIRECTORY(dlldata + sections[i].PointerToRawData + ExportDirVA - sections[i].VirtualAddress);
unsigned long *names = (unsigned long*)((char*)exports + exports->AddressOfNames - ExportDirVA);
unsigned long *names = (unsigned long*)((unsigned long)exports + (char *)exports->AddressOfNames - ExportDirVA);
for (unsigned long j = 0; j < exports->NumberOfNames; j++)
{
char *name = (char*)exports + names[j] - ExportDirVA;
@ -161,4 +161,4 @@ void Plugins::SetDllDataHandle(int uninst, char* command, int dataHandle)
m_list.setDataHandle(command, dataHandle, -1);
}
#endif
#endif

View file

@ -64,4 +64,4 @@ class Plugins
void GetExports(char*,bool);
};
#endif
#endif

View file

@ -57,14 +57,18 @@ CResourceEditor::CResourceEditor(BYTE* pbPE, int iSize) {
// No check sum support yet...
if (m_ntHeaders->OptionalHeader.CheckSum)
throw runtime_error("CResourceEditor doesn't yet support check sum");
{
// clear checksum (should be [re]calculated after all changes done)
m_ntHeaders->OptionalHeader.CheckSum = 0;
//throw runtime_error("CResourceEditor doesn't yet support check sum");
}
// Get resource section virtual address
m_dwResourceSectionVA = m_ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress;
// Pointer to the sections headers array
PIMAGE_SECTION_HEADER sectionHeadersArray = IMAGE_FIRST_SECTION(m_ntHeaders);
m_dwResourceSectionIndex = -1;
m_dwResourceSectionIndex = 0xFFFFFFFF;
// Find resource section index in the array
for (int i = 0; i < m_ntHeaders->FileHeader.NumberOfSections; i++) {
@ -110,7 +114,7 @@ bool CResourceEditor::UpdateResource(char* szType, char* szName, LANGID wLanguag
CResourceDirectory* langDir = 0;
CResourceDataEntry* data = 0;
IMAGE_RESOURCE_DIRECTORY rd = {0, /*time(0),*/};
int iTypeIdx, iNameIdx, iLangIdx;
int iTypeIdx = -1, iNameIdx = -1, iLangIdx = -1;
iTypeIdx = m_cResDir->Find(szType);
if (iTypeIdx > -1) {
@ -265,7 +269,6 @@ DWORD CResourceEditor::Save(BYTE* pbBuf, DWORD &dwSize) {
ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = sectionHeadersArray[m_dwResourceSectionIndex].Misc.VirtualSize;
// Set the new virtual size of the image
DWORD old = ntHeaders->OptionalHeader.SizeOfImage;
ntHeaders->OptionalHeader.SizeOfImage = RALIGN(ntHeaders->OptionalHeader.SizeOfHeaders, ntHeaders->OptionalHeader.SectionAlignment);
for (i = 0; i < ntHeaders->FileHeader.NumberOfSections; i++)
ntHeaders->OptionalHeader.SizeOfImage += RALIGN(sectionHeadersArray[i].Misc.VirtualSize, ntHeaders->OptionalHeader.SectionAlignment);
@ -340,16 +343,16 @@ bool CResourceEditor::AddExtraVirtualSize2PESection(const char* pszSectionName,
PIMAGE_SECTION_HEADER sectionHeadersArray = IMAGE_FIRST_SECTION(m_ntHeaders);
// Refresh the headers of the sections that come after the resource section, and the data directory
for (int i =0; i < m_ntHeaders->FileHeader.NumberOfSections; i++) {
if ( !strcmp((LPCSTR)sectionHeadersArray[i].Name, pszSectionName) ) {
for (int i = 0; i < m_ntHeaders->FileHeader.NumberOfSections; i++) {
if (!strcmp((LPCSTR)sectionHeadersArray[i].Name, pszSectionName)) {
sectionHeadersArray[i].Misc.VirtualSize += addsize;
sectionHeadersArray[i].Characteristics &= ~IMAGE_SCN_MEM_DISCARDABLE;
sectionHeadersArray[i].Misc.VirtualSize = RALIGN(sectionHeadersArray[i].Misc.VirtualSize, m_ntHeaders->OptionalHeader.SectionAlignment);
// now fix any section after
for (int k=i+1; k< m_ntHeaders->FileHeader.NumberOfSections; k++, i++) {
for (int k = i + 1; k < m_ntHeaders->FileHeader.NumberOfSections; k++, i++) {
sectionHeadersArray[k].VirtualAddress = sectionHeadersArray[i].VirtualAddress + sectionHeadersArray[i].Misc.VirtualSize;
sectionHeadersArray[k].VirtualAddress = RALIGN(sectionHeadersArray[k].VirtualAddress, m_ntHeaders->OptionalHeader.SectionAlignment);
if ( m_dwResourceSectionIndex == k )
if (m_dwResourceSectionIndex == (DWORD) k)
{
// fix the resources virtual address if it changed
m_dwResourceSectionVA = m_ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = sectionHeadersArray[k].VirtualAddress;
@ -373,7 +376,7 @@ CResourceDirectory* CResourceEditor::ScanDirectory(PRESOURCE_DIRECTORY rdRoot, P
// Create CResourceDirectory from rdToScan
CResourceDirectory* rdc = new CResourceDirectory(PIMAGE_RESOURCE_DIRECTORY(rdToScan));
char* szName;
PIMAGE_RESOURCE_DATA_ENTRY rde;
PIMAGE_RESOURCE_DATA_ENTRY rde = NULL;
// Go through all entries of this resource directory
for (int i = 0; i < rdToScan->Header.NumberOfNamedEntries + rdToScan->Header.NumberOfIdEntries; i++) {
@ -438,7 +441,9 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
while (!qDirs.empty()) {
CResourceDirectory* crd = qDirs.front();
CopyMemory(seeker, &crd->GetInfo(), sizeof(IMAGE_RESOURCE_DIRECTORY));
IMAGE_RESOURCE_DIRECTORY rdDir = crd->GetInfo();
CopyMemory(seeker, &rdDir, sizeof(IMAGE_RESOURCE_DIRECTORY));
crd->m_dwWrittenAt = DWORD(seeker);
seeker += sizeof(IMAGE_RESOURCE_DIRECTORY);
@ -452,7 +457,7 @@ void CResourceEditor::WriteRsrcSec(BYTE* pbRsrcSec) {
qDataEntries2.push(crd->GetEntry(i)->GetDataEntry());
}
IMAGE_RESOURCE_DIRECTORY_ENTRY rDirE = {0,};
IMAGE_RESOURCE_DIRECTORY_ENTRY rDirE = {{0}};
rDirE.DataIsDirectory = crd->GetEntry(i)->IsDataDirectory();
rDirE.Id = (crd->GetEntry(i)->HasName()) ? 0 : crd->GetEntry(i)->GetId();
rDirE.NameIsString = (crd->GetEntry(i)->HasName()) ? 1 : 0;
@ -624,10 +629,10 @@ int CResourceDirectory::CountEntries() {
// Returns -1 if can not be found
int CResourceDirectory::Find(char* szName) {
if (IS_INTRESOURCE(szName))
return Find(WORD(szName));
return Find((WORD) (DWORD) szName);
else
if (szName[0] == '#')
return Find(WORD(atoi(szName+1)));
return Find(WORD(atoi(szName + 1)));
for (unsigned int i = 0; i < m_vEntries.size(); i++) {
if (!m_vEntries[i]->HasName())
@ -702,7 +707,7 @@ CResourceDirectoryEntry::CResourceDirectoryEntry(char* szName, CResourceDirector
if (IS_INTRESOURCE(szName)) {
m_bHasName = false;
m_szName = 0;
m_wId = WORD(szName);
m_wId = (WORD) (DWORD) szName;
}
else {
m_bHasName = true;
@ -717,7 +722,7 @@ CResourceDirectoryEntry::CResourceDirectoryEntry(char* szName, CResourceDataEntr
if (IS_INTRESOURCE(szName)) {
m_bHasName = false;
m_szName = 0;
m_wId = WORD(szName);
m_wId = (WORD) (DWORD) szName;
}
else {
m_bHasName = true;
@ -825,4 +830,4 @@ DWORD CResourceDataEntry::GetSize() {
DWORD CResourceDataEntry::GetCodePage() {
return m_dwCodePage;
}
}

View file

@ -26,9 +26,10 @@ CResourceVersionInfo::CResourceVersionInfo()
m_FixedInfo.dwFileType = VFT_APP;
// Detect local codepage and language
/*
WORD Lang = GetSystemDefaultLangID();
WORD CodePage = GetACP();
/*
SetKeyValue(Lang, CodePage, "Comments", "Portuguese");
SetKeyValue(Lang, CodePage, "FileVersion", "1.2");
SetKeyValue(Lang, CodePage, "FileDescription", "Soft");
@ -267,4 +268,4 @@ bool CResourceVersionInfo::IsValidCodePage(WORD codePage )
return false;
}
*/
#endif
#endif

View file

@ -38,7 +38,7 @@ class ConstantsStringList : public SortedStringListND<struct constantstring>
return temp;
}
int get(char *name, size_t n_chars = -1)
int get(char *name, int n_chars = -1)
{
int v=SortedStringListND<struct constantstring>::find(name, n_chars);
if (v==-1) return -1;

View file

@ -361,7 +361,7 @@ definedlist.add("NSIS_SUPPORT_LANG_IN_STRINGS");
build_langstring_num=0;
ubuild_langstring_num=0;
build_font[0]=NULL;
build_font[0]=0;
build_font_size=0;
m_unicon_data=(unsigned char *)malloc(unicondata_size+3*sizeof(DWORD));
@ -401,12 +401,13 @@ definedlist.add("NSIS_SUPPORT_LANG_IN_STRINGS");
// Register static user variables $0, $1 and so on
// with ONE of reference count, to avoid warning on this vars
char Aux[3];
for ( int i = 0; i < 10; i++ ) // 0 - 9
int i;
for (i = 0; i < 10; i++) // 0 - 9
{
sprintf(Aux, "%d", i);
m_UserVarNames.add(Aux,1);
}
for ( i = 0; i < 10; i++ ) // 10 - 19
for (i = 0; i < 10; i++) // 10 - 19
{
sprintf(Aux, "R%d", i);
m_UserVarNames.add(Aux,1);
@ -653,7 +654,7 @@ int CEXEBuild::datablock_optimize(int start_offset)
int this_len = cur_datablock->getlen() - start_offset;
int pos = 0;
if (!build_optimize_datablock || this_len < sizeof(int))
if (!build_optimize_datablock || this_len < (int) sizeof(int))
return start_offset;
MMapBuf *db = (MMapBuf *) cur_datablock;
@ -958,7 +959,7 @@ int CEXEBuild::add_label(const char *name)
}
}
section s={0,};
section s={{0}};
s.name_ptr = offs;
s.code = ce;
cur_labels->add(&s,sizeof(s));
@ -1467,7 +1468,7 @@ int CEXEBuild::resolve_coderefs(const char *str)
};
for (int i = 0; callbacks[i].name; i++) {
char *un = uninstall_mode ? "un" : "";
const char *un = uninstall_mode ? "un" : "";
char fname[1024];
wsprintf(fname, callbacks[i].name, un, un);
char cbstr[1024];
@ -1609,7 +1610,6 @@ int CEXEBuild::page_end()
int CEXEBuild::AddVersionInfo()
{
GrowBuf VerInfoStream;
bool bNeedVInfo = false;
if ( rVersionInfo.GetStringTablesCount() > 0 )
{
@ -2372,7 +2372,7 @@ int CEXEBuild::write_output(void)
fh.siginfo=FH_SIG;
int installinfo_compressed;
int fd_start;
int fd_start = 0;
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
if (build_compress_whole)
@ -3200,14 +3200,14 @@ void CEXEBuild::close_res_editor()
int CEXEBuild::DeclaredUserVar(const char *szVarName)
{
if ( m_ShellConstants.get((char*)szVarName) >= 0 )
if (m_ShellConstants.get((char*)szVarName) >= 0)
{
ERROR_MSG("Error: name \"%s\" in use by constant\n", szVarName);
return PS_ERROR;
}
int idxUserVar = m_UserVarNames.get((char*)szVarName);
if ( idxUserVar >= 0 )
if (idxUserVar >= 0)
{
ERROR_MSG("Error: variable \"%s\" already declared\n", szVarName);
return PS_ERROR;
@ -3215,21 +3215,21 @@ int CEXEBuild::DeclaredUserVar(const char *szVarName)
const char *pVarName = szVarName;
int iVarLen = strlen(szVarName);
if ( iVarLen > 60 )
if (iVarLen > 60)
{
ERROR_MSG("Error: variable name too long!\n");
return PS_ERROR;
}
else if ( !iVarLen )
else if (!iVarLen)
{
ERROR_MSG("Error: variable with empty name!\n");
return PS_ERROR;
}
else
{
while ( *pVarName )
while (*pVarName)
{
if ( !isSimpleChar(*pVarName) )
if (!isSimpleChar(*pVarName))
{
ERROR_MSG("Error: invalid charaters in variable name \"%s\", use only charaters [a-z][A-Z][0-9] and '_'\n", szVarName);
return PS_ERROR;
@ -3261,11 +3261,11 @@ int CEXEBuild::GetUserVarIndex(LineParser &line, int token)
}
else
{
int idxConst = m_ShellConstants.get((char *)p+1);
if ( idxConst >= 0 )
{
ERROR_MSG("Error: cannot change constants : %s\n", p);
}
int idxConst = m_ShellConstants.get((char *)p+1);
if (idxConst >= 0)
{
ERROR_MSG("Error: cannot change constants : %s\n", p);
}
}
}
return -1;

View file

@ -1094,4 +1094,4 @@ void BZ2_blockSort ( EState* s )
/*--- end blocksort.c ---*/
/*-------------------------------------------------------------*/
#endif
#endif

View file

@ -120,14 +120,14 @@ static void bsW ( EState* s, Int32 n, UInt32 v )
/*---------------------------------------------------*/
static
/*static
void bsPutUInt32 ( EState* s, UInt32 u )
{
bsW ( s, 8, (u >> 24) & 0xffL );
bsW ( s, 8, (u >> 16) & 0xffL );
bsW ( s, 8, (u >> 8) & 0xffL );
bsW ( s, 8, u & 0xffL );
}
}*/
/*---------------------------------------------------*/

View file

@ -227,4 +227,4 @@ void BZ2_hbCreateDecodeTables ( Int32 *limit,
/*-------------------------------------------------------------*/
/*--- end huffman.c ---*/
/*-------------------------------------------------------------*/
#endif
#endif

View file

@ -58,4 +58,4 @@ class CBzip2 : public ICompressor {
int last_ret;
};
#endif
#endif

View file

@ -50,7 +50,7 @@ public:
InitializeCriticalSection(&cs);
}
~CLZMA()
virtual ~CLZMA()
{
End();
DeleteCriticalSection(&cs);
@ -79,7 +79,7 @@ public:
NCoderPropID::kDictionarySize,
NCoderPropID::kNumFastBytes
};
const kNumProps = sizeof(propdIDs) / sizeof(propdIDs[0]);
const int kNumProps = sizeof(propdIDs) / sizeof(propdIDs[0]);
PROPVARIANT props[kNumProps];
// NCoderPropID::kAlgorithm
props[0].vt = VT_UI4;
@ -318,4 +318,4 @@ public:
const char *GetName() { return "lzma"; }
};
#endif
#endif

View file

@ -21,4 +21,4 @@ class ICompressor {
virtual const char* GetName() = 0;
};
#endif
#endif

View file

@ -1,3 +1,4 @@
#include "Platform.h"
#include "exehead/config.h"
#ifdef NSIS_CONFIG_CRC_SUPPORT

View file

@ -52,4 +52,4 @@ class CZlib : public ICompressor {
z_stream *stream;
};
#endif
#endif

View file

@ -15,4 +15,4 @@ extern unsigned char icon_data[];
extern unsigned char unicon_data[];
extern unsigned char bitmap1_data[630];
#endif //_EXEDATA_H_
#endif //_EXEDATA_H_

View file

@ -49,7 +49,6 @@ extern HANDLE dbd_hFile;
#endif
char g_caption[NSIS_MAX_STRLEN*2];
int g_filehdrsize;
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
HWND g_hwnd;
HANDLE g_hInstance;
@ -70,7 +69,7 @@ char *ValidateTempDir()
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, int nCmdShow)
{
int ret;
int ret = 2;
const char *m_Err = _LANG_ERRORWRITINGTEMP;
int cl_flags = 0;

View file

@ -1,81 +1,108 @@
# -- Objects and source files --
SRCS = bgbg.c exec.c fileform.c main.c ui.c util.c ../crc32.c ../zlib/infblock.c ../zlib/infcodes.c ../zlib/inflate.c ../zlib/inftrees.c ../zlib/infutil.c ../bzip2/bzlib.c ../bzip2/decompress.c ../bzip2/huffman.c ../bzip2/randtable.c
OBJS = bgbg.o exec.o fileform.o main.o ui.o util.o resource.res crc32.o infblock.o infcodes.o inflate.o inftrees.o infutil.o bzlib.o decompress.o huffman.o randtable.o
DEPENDS = ../Platform.h config.h
ZLIB_SRCS = bgbg.c exec.c fileform.c main.c ui.c util.c ../crc32.c resource.rc ../zlib/infblock.c
ZLIB_OBJS = Release-zlib/bgbg.o Release-zlib/exec.o Release-zlib/fileform.o Release-zlib/main.o Release-zlib/ui.o Release-zlib/util.o Release-zlib/crc32.o Release-zlib/resource.res Release-zlib/infblock.o
BZIP2_SRCS = bgbg.c exec.c fileform.c main.c ui.c util.c ../crc32.c resource.rc ../bzip2/bzlib.c ../bzip2/decompress.c ../bzip2/huffman.c
BZIP2_OBJS = Release-bzip2/bgbg.o Release-bzip2/exec.o Release-bzip2/fileform.o Release-bzip2/main.o Release-bzip2/ui.o Release-bzip2/util.o Release-bzip2/crc32.o Release-bzip2/resource.res Release-bzip2/bzlib.o Release-bzip2/decompress.o Release-bzip2/huffman.o
LZMA_SRCS = bgbg.c exec.c fileform.c main.c ui.c util.c ../crc32.c resource.rc ../7zip/LZMADecode.c
LZMA_OBJS = Release-lzma/bgbg.o Release-lzma/exec.o Release-lzma/fileform.o Release-lzma/main.o Release-lzma/ui.o Release-lzma/util.o Release-lzma/crc32.o Release-lzma/resource.res Release-lzma/LZMADecode.o
LIBS = -lole32 -lgdi32 -lversion -luuid -lcomctl32 -lkernel32 -luser32 -lshell32 -ladvapi32
# -- Programs --
CC = gcc
RC = windres
RM = del
RM = rm
MKDIR = mkdir
# -- Compilers and linker flags --
DEFINES = -DWIN32 -D_WINDOWS_ -DEXEHEAD -DWinMain=WinMainCRTStartup
CFLAGS = -Os -fomit-frame-pointer -fno-inline $(DEFINES)
LFLAGS = -s -mwindows -nostdlib -nostartfiles -Wl,--enable-stdcall-fixup
DEFINES = -DWIN32 -D_WINDOWS_ -DEXEHEAD -DWIN32_LEAN_AND_MEAN -DZEXPORT=__stdcall -DLZMACALL=__stdcall
CFLAGS = -Wall -Os -fno-common -fomit-frame-pointer -fno-inline $(DEFINES)
LFLAGS = -s -mwindows -nostdlib -nostartfiles --enable-stdcall-fixup -Wl,-Bdynamic -Wl,--file-alignment,512 -Wl,--exclude-libs,msvcrt.a -Wl,-e,_WinMain@16 -Wl,sections_script.ld
RCFLAGS = --input-format rc --output-format coff
all : exehead
all : exehead_zlib exehead_bzip2 exehead_lzma exehead_resources
exehead : $(OBJS)
$(CC) $(CFLAGS) $(LFLAGS) -o exehead.exe $(OBJS) $(LIBS)
bin2h exehead.exe Release\exehead.h header_data
bin2h bitmap1.bmp Release\bitmap1.h bitmap1_data
bin2h bitmap2.bmp Release\bitmap2.h bitmap2_data
bin2h nsis.ico Release\icon.h icon_data
bin2h uninst.ico Release\unicon.h unicon_data
missing_dirs = $(filter-out $(wildcard Release-*),Release-zlib Release-bzip2 Release-lzma)
# -- Dependencies --
bgbg.o : bgbg.c resource.h config.h Makefile
exec.o : exec.c fileform.h util.h state.h ui.h exec.h config.h lang.h Makefile
fileform.o : fileform.c fileform.h util.h state.h ../zlib/zlib.h ../zlib/zconf.h ui.h config.h Makefile
main.o : main.c resource.h util.h fileform.h state.h ui.h ../zlib/zlib.h ../zlib/zconf.h config.h lang.h Makefile
ui.o : ui.c resource.h fileform.h state.h ui.h config.h Makefile
util.o : util.c util.h state.h fileform.h ui.h config.h Makefile
ifneq ($(strip $(missing_dirs)),)
mkdirline = $(MKDIR) $(missing_dirs)
else
mkdirline =
endif
# -- Special command line for the resource file --
resource.res : resource.rc resource.h config.h Makefile
$(RC) $(RCFLAGS) -o resource.res -i resource.rc
dirs:
$(mkdirline)
crc32.o : ../crc32.c config.h Makefile
$(CC) $(CFLAGS) -c ../crc32.c -o crc32.o
exehead_zlib : dirs $(ZLIB_SRCS) $(ZLIB_OBJS) sections_script
$(CC) $(CFLAGS) $(LFLAGS) -o Release-zlib/exehead_zlib.exe $(ZLIB_OBJS) $(LIBS)
bin2h Release-zlib/exehead_zlib.exe Release-zlib/exehead_zlib.h zlib_header_data
exehead_bzip2 : dirs $(BZIP2_SRCS) $(BZIP2_OBJS) sections_script
$(CC) $(CFLAGS) $(LFLAGS) -o Release-bzip2/exehead_bzip2.exe $(BZIP2_OBJS) $(LIBS)
bin2h Release-bzip2/exehead_bzip2.exe Release-bzip2/exehead_bzip2.h bzip2_header_data
# -- Special command lines for zlib --
infblock.o : ../zlib/infblock.c ../zlib/zutil.h ../zlib/infblock.h ../zlib/inftrees.h ../zlib/infcodes.h ../zlib/infutil.h ../zlib/zlib.h ../zlib/zconf.h Makefile
$(CC) $(CFLAGS) -c ../zlib/infblock.c -o infblock.o
exehead_lzma : dirs $(LZMA_SRCS) $(LZMA_OBJS) sections_script
$(CC) $(CFLAGS) $(LFLAGS) -o Release-lzma/exehead_lzma.exe $(LZMA_OBJS) $(LIBS)
bin2h Release-lzma/exehead_lzma.exe Release-lzma/exehead_lzma.h lzma_header_data
infcodes.o : ../zlib/infcodes.c ../zlib/zutil.h ../zlib/inftrees.h ../zlib/infblock.h ../zlib/infcodes.h ../zlib/infutil.h ../zlib/zlib.h ../zlib/zconf.h Makefile
$(CC) $(CFLAGS) -c ../zlib/infcodes.c -o infcodes.o
exehead_resources : exehead_zlib
bin2h bitmap1.bmp Release-zlib/bitmap1.h bitmap1_data
bin2h nsis.ico Release-zlib/icon.h icon_data
bin2h uninst.ico Release-zlib/unicon.h unicon_data
inflate.o : ../zlib/inflate.c ../zlib/zutil.h ../zlib/infblock.h ../zlib/zlib.h ../zlib/zconf.h Makefile
$(CC) $(CFLAGS) -c ../zlib/inflate.c -o inflate.o
sections_script:
echo SECTIONS > sections_script.ld
echo { >> sections_script.ld
echo .text : { *(.text) } >> sections_script.ld
echo .data : { *(.data) } >> sections_script.ld
echo .rdata : { *(.rdata) } >> sections_script.ld
echo .bss : { *(.bss) } >> sections_script.ld
echo .idata : { *(.idata) } >> sections_script.ld
echo .ndata BLOCK(__section_alignment__) : { [ .ndata ] } >> sections_script.ld
echo .rsrc : { *(.rsrc) } >> sections_script.ld
echo } >> sections_script.ld
inftrees.o : ../zlib/inftrees.c ../zlib/zutil.h ../zlib/inftrees.h ../zlib/zlib.h ../zlib/zconf.h Makefile
$(CC) $(CFLAGS) -c ../zlib/inftrees.c -o inftrees.o
Release-zlib/ = -DNSIS_COMPRESS_USE_ZLIB
Release-bzip2/ = -DNSIS_COMPRESS_USE_BZIP2
Release-lzma/ = -DNSIS_COMPRESS_USE_LZMA
getdefine = $($(dir $@))
infutil.o : ../zlib/infutil.c ../zlib/zutil.h ../zlib/infblock.h ../zlib/inftrees.h ../zlib/infcodes.h ../zlib/infutil.h ../zlib/zlib.h ../zlib/zconf.h Makefile
$(CC) $(CFLAGS) -c ../zlib/infutil.c -o infutil.o
Release-zlib/%.o Release-bzip2/%.o Release-lzma/%.o : %.c $(DEPENDS)
$(CC) $(CFLAGS) $(getdefine) -c $< -o $@
# -- Special command lines for bzip2 --
bzlib.o : ../bzip2/bzlib.c ../bzip2/bzlib.h ../bzip2/bzlib_private.h config.h
$(CC) $(CFLAGS) -c ../bzip2/bzlib.c -o bzlib.o
Release-zlib/%.o Release-bzip2/%.o Release-lzma/%.o : ../%.c $(DEPENDS)
$(CC) $(CFLAGS) $(getdefine) -c $< -o $@
decompress.o : ../bzip2/decompress.c ../bzip2/bzlib.h ../bzip2/bzlib_private.h config.h
$(CC) $(CFLAGS) -c ../bzip2/decompress.c -o decompress.o
Release-zlib/%.o Release-bzip2/%.o Release-lzma/%.o : ../zlib/%.c $(DEPENDS)
$(CC) $(CFLAGS) $(getdefine) -c $< -o $@
huffman.o : ../bzip2/huffman.c ../bzip2/bzlib.h ../bzip2/bzlib_private.h config.h
$(CC) $(CFLAGS) -c ../bzip2/huffman.c -o huffman.o
Release-zlib/%.o Release-bzip2/%.o Release-lzma/%.o : ../bzip2/%.c $(DEPENDS)
$(CC) $(CFLAGS) $(getdefine) -c $< -o $@
randtable.o : ../bzip2/randtable.c ../bzip2/bzlib.h ../bzip2/bzlib_private.h config.h
$(CC) $(CFLAGS) -c ../bzip2/randtable.c -o randtable.o
Release-zlib/%.o Release-bzip2/%.o Release-lzma/%.o : ../7zip/%.c $(DEPENDS)
$(CC) $(CFLAGS) $(getdefine) -c $< -o $@
%/resource.res : resource.rc resource.h config.h Makefile
$(RC) $(RCFLAGS) -o $*/resource.res -i resource.rc
# -- Clean script --
clean ::
$(RM) *.o
$(RM) resource.res
$(RM) exehead.exe
$(RM) Release\exehead.h
$(RM) Release\bitmap1.h
$(RM) Release\bitmap2.h
$(RM) Release\icon.h
$(RM) Release\unicon.h
$(RM) sections_script.ld
$(RM) Release-zlib/*.o
$(RM) Release-zlib/resource.res
$(RM) Release-zlib/exehead_zlib.exe
$(RM) Release-zlib/exehead_zlib.h
$(RM) Release-zlib/bitmap1.h
$(RM) Release-zlib/icon.h
$(RM) Release-zlib/unicon.h
$(RM) Release-bzip2/*.o
$(RM) Release-bzip2/resource.res
$(RM) Release-bzip2/exehead_bzip2.exe
$(RM) Release-bzip2/exehead_bzip2.h
$(RM) Release-lzma/*.o
$(RM) Release-lzma/resource.res
$(RM) Release-lzma/exehead_lzma.exe
$(RM) Release-lzma/exehead_lzma.h

View file

@ -707,8 +707,10 @@ static BOOL CALLBACK LicenseProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
if (nmhdr->code==EN_LINK) {
if (enlink->msg==WM_LBUTTONDOWN) {
TEXTRANGE tr = {
enlink->chrg.cpMin,
enlink->chrg.cpMax,
{
enlink->chrg.cpMin,
enlink->chrg.cpMax,
},
ps_tmpbuf
};
if (tr.chrg.cpMax-tr.chrg.cpMin < sizeof(ps_tmpbuf)) {
@ -1232,7 +1234,9 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
int ns=lParam;
TVITEM tv;
if (tv.hItem=hTreeItems[x])
tv.hItem=hTreeItems[x];
if (tv.hItem)
{
tv.mask=TVIF_TEXT;
tv.pszText=GetNSISStringTT(ns);
@ -1360,7 +1364,9 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (t->flags&SF_RO) l+=3;
if (tv.hItem=*ht) {
tv.hItem=*ht;
if (tv.hItem) {
tv.mask=TVIF_STATE;
tv.state=INDEXTOSTATEIMAGEMASK(l);
tv.stateMask=TVIS_STATEIMAGEMASK;

View file

@ -3,22 +3,6 @@
#ifndef APSTUDIO_INVOKED // keep msdev's resource editor from mangling the .rc file
// Added by Dave Laundon 19th August 2002
// For all internal functions, use of stdcall calling convention moves the
// responsibility for tidying the stack to callee from caller, reducing the code
// involved considerably. Gives an instant saving of 0.5K.
// NB - the zlib and bzip2 portions have been given the same treatment, but with
// project compiler-options settings and/or project-wide defines.
// NB - safer for NSIS's routines to be defined explicitly to avoid problems
// calling DLL functions.
#if defined(_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
#define NSISCALL __stdcall // Ordinary functions
#define NSISCALLV __cdecl // Variable-argument-list functions
#else
#define NSISCALL
#define NSISCALLV
#endif
// NSIS_MAX_STRLEN defines the maximum string length for internal variables
// and stack entries. 1024 should be plenty, but if you are doing crazy registry
// shit, you might want to bump it up. Generally it adds about 16-32x the memory,

View file

@ -120,7 +120,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
char *buf1 = bufs[1];
char *buf2 = bufs[2];
char *buf3 = bufs[3];
char *buf4 = bufs[4];
//char *buf4 = bufs[4];
char *var0;
char *var1;
@ -1312,7 +1312,6 @@ static int NSISCALL ExecuteEntry(entry *entry_)
if (*hptr)
{
char lc=0;
int rcnt=0;
HANDLE h=(HANDLE)myatoi(hptr);
while (rpos<maxlen)
{

View file

@ -472,7 +472,7 @@ static int NSISCALL __ensuredata(int amount)
{
return -3;
}
r=g_inflate_stream.next_out-_outbuffer;
r=(DWORD)g_inflate_stream.next_out-(DWORD)_outbuffer;
if (r)
{
if (!WriteFile(dbd_hFile,_outbuffer,r,&t,NULL) || r != t)

View file

@ -19,4 +19,4 @@ extern HWND insthwnd,insthwndbutton;
#else
#define g_hwnd 0
#define g_hInstance 0
#endif//NSIS_CONFIG_VISIBLE_SUPPORT
#endif//NSIS_CONFIG_VISIBLE_SUPPORT

View file

@ -21,11 +21,18 @@ char g_log_file[1024];
// and change the virtual size of this section
// which result in extra memory for extra variables without code to do allocation :)
// nsis then removes the "DISCARDABLE" style from section (for safe)
#pragma bss_seg( VARS_SECTION_NAME )
#ifdef _MSC_VER
# pragma bss_seg(VARS_SECTION_NAME)
NSIS_STRING g_usrvars[1];
#pragma bss_seg()
#define SECTION_VARS_RWD "/section:" ## VARS_SECTION_NAME ## ",rwd"
#pragma comment(linker, SECTION_VARS_RWD)
# pragma bss_seg()
# pragma comment(linker, "/section:" VARS_SECTION_NAME ",rwd")
#else
# ifdef __GNUC__
NSIS_STRING g_usrvars[1] __attribute__((section (VARS_SECTION_NAME)));
# else
# error Unknown compiler. You must implement the seperate PE section yourself.
# endif
#endif
void NSISCALL FreePIDL(LPITEMIDLIST idl)
{
@ -155,7 +162,7 @@ void NSISCALL trimslashtoend(char *buf)
int NSISCALL validpathspec(char *ubuf)
{
char dl = ubuf[0] | 0x20; // convert alleged drive letter to lower case
return ((*(WORD*)ubuf==CHAR2_TO_WORD('\\','\\')) || (dl >= 'a' && dl <= 'z' && *CharNext(ubuf)==':'));
return ((*(WORD*)ubuf==CHAR2_TO_WORD('\\','\\')) || (dl >= 'a' && dl <= 'z' && ubuf[1]==':'));
}
char * NSISCALL skip_root(char *path)
@ -176,7 +183,7 @@ char * NSISCALL skip_root(char *path)
p2 = findchar(p2, '\\');
if (!*p2)
return NULL;
p2 = CharNext(p2);
p2++; // skip backslash
}
return p2;
@ -475,7 +482,7 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
unsigned char nVarIdx = (unsigned char)*in++;
int nData;
int fldrs[4];
if (nVarIdx > NS_SKIP_CODE)
if (nVarIdx > NS_CODES_START)
{
nData = ((in[1] & 0x7F) << 7) | (in[0] & 0x7F);
fldrs[0] = in[0]; // current user

View file

@ -1,3 +1,4 @@
#include "../Platform.h"
#include "config.h"
#include <shlobj.h>

View file

@ -706,12 +706,12 @@ void CEXEBuild::FillLanguageTable(LanguageTable *table) {
char SkipComments(FILE *f) {
char c;
while (c = fgetc(f)) {
while ((c = fgetc(f))) {
while (c == '\n' || c == '\r') {
c = fgetc(f); // Skip empty lines
}
if (c == '#' || c == ';') {
while (c = fgetc(f)) {
while ((c = fgetc(f))) {
if (c == '\n') break;
}
}
@ -763,7 +763,7 @@ LanguageTable * CEXEBuild::LoadLangFile(char *filename) {
}
// Generate language name
char *p, *p2, t;
char *p, *p2, t = 0;
p = strrchr(filename, '.');
if (p) {
@ -906,7 +906,8 @@ LanguageTable * CEXEBuild::LoadLangFile(char *filename) {
}
nlf->m_szStrings[i] = (char*)malloc(temp+1);
for (char *out = nlf->m_szStrings[i]; *in; in++, out++) {
char *out;
for (out = nlf->m_szStrings[i]; *in; in++, out++) {
if (*in == '\\') {
in++;
switch (*in) {

View file

@ -44,7 +44,7 @@ class LangStringList : public SortedStringListND<struct langstring>
if (index) *index = -1;
if (uindex) *uindex = -1;
if (sn) *sn = -1;
int v=SortedStringListND<struct langstring>::find(name);
int v=find(name);
if (v==-1) return -1;
if (index) *index = ((struct langstring*)gr.get())[v].index;
if (uindex) *uindex = ((struct langstring*)gr.get())[v].uindex;

View file

@ -197,4 +197,4 @@ class LineParser {
bool m_bCommentBlock;
char **m_tokens;
};
#endif//_LINEPARSE_H_
#endif//_LINEPARSE_H_

View file

@ -82,7 +82,6 @@ int main(int argc, char **argv)
int nousage=0;
int files_processed=0;
int cmds_processed=0;
int plugins_processed=0;
FILE *fp;
int tmpargpos=1;
int no_logo=0;

View file

@ -910,8 +910,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
// advance over parms
while (*t)
{
char *v;
if (v=definedlist.find(t))
char *v=definedlist.find(t);
if (v)
{
l_define_saves.add(t,v);
definedlist.del(t);
@ -1302,7 +1302,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
char *file = line.gettoken_str(3);
FILE *fp;
int datalen;
unsigned int datalen;
fp=fopen(file,"rb");
if (!fp)
{
@ -1594,7 +1594,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
{
int idx = 0;
char *file = line.gettoken_str(1);
char *data;
char *data = NULL;
if (file[0] == '$' && file[1] == '(')
{
@ -1610,7 +1610,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
if (!idx)
{
int datalen;
unsigned int datalen;
FILE *fp=fopen(file,"rb");
if (!fp)
{
@ -2075,7 +2075,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
if (k == -1) PRINTHELP()
SCRIPT_MSG("XPStyle: %s\n", line.gettoken_str(1));
init_res_editor();
char* szXPManifest = k ? 0 : "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"><assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"X86\" name=\"Nullsoft.NSIS.exehead\" type=\"win32\"/><description>Nullsoft Install System v2.0</description><dependency><dependentAssembly><assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"X86\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\" /></dependentAssembly></dependency></assembly>";
const char *szXPManifest = k ? 0 : "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"><assemblyIdentity version=\"1.0.0.0\" processorArchitecture=\"X86\" name=\"Nullsoft.NSIS.exehead\" type=\"win32\"/><description>Nullsoft Install System v2.0</description><dependency><dependentAssembly><assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"X86\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\" /></dependentAssembly></dependency></assembly>";
res_editor->UpdateResource(MAKEINTRESOURCE(24), MAKEINTRESOURCE(1), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (unsigned char*)szXPManifest, k ? 0 : lstrlen(szXPManifest));
}
catch (exception& err) {
@ -2145,7 +2145,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
// Search for bitmap holder (default for SetBrandingImage)
branding_image_found = false;
DialogItemTemplate* dlgItem = 0;
for (int i = 0; dlgItem = UIDlg.GetItemByIdx(i); i++) {
for (int i = 0; (dlgItem = UIDlg.GetItemByIdx(i)); i++) {
if (IS_INTRESOURCE(dlgItem->szClass)) {
if (dlgItem->szClass == MAKEINTRESOURCE(0x0082)) {
if ((dlgItem->dwStyle & SS_BITMAP) == SS_BITMAP) {
@ -2233,7 +2233,6 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
CDialogTemplate dt(dlg,uDefCodePage);
delete [] dlg;
DialogItemTemplate *childRect = dt.GetItem(IDC_CHILDRECT);
DialogItemTemplate brandingCtl = {0,};
brandingCtl.dwStyle = SS_BITMAP | WS_CHILD | WS_VISIBLE;
@ -3348,8 +3347,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
char *np=p;
while (*np && *np != '|') np++;
if (*np) *np++=0;
for (x =0 ; x < sizeof(list)/sizeof(list[0]) && strcmpi(list[x].str,p); x ++);
if (x < sizeof(list)/sizeof(list[0]))
for (x = 0 ; (unsigned) x < sizeof(list) / sizeof(list[0]) && strcmpi(list[x].str, p); x++);
if ((unsigned) x < sizeof(list) / sizeof(list[0]))
{
r|=list[x].id;
}
@ -3958,9 +3957,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
char *np=p;
while (*np && *np != '|') np++;
if (*np) *np++=0;
for (x =0 ; x < sizeof(list)/sizeof(list[0]) && stricmp(list[x].str,p); x ++);
for (x = 0 ; (unsigned) x < sizeof(list)/sizeof(list[0]) && stricmp(list[x].str,p); x ++);
if (x < sizeof(list)/sizeof(list[0]))
if ((unsigned) x < sizeof(list)/sizeof(list[0]))
{
r|=list[x].id;
}
@ -4122,7 +4121,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
case TOK_GETDLLVERSIONLOCAL:
{
char buf[128];
DWORD low, high;
DWORD low=0, high=0;
DWORD s,d;
int flag=0;
int alloced=0;
@ -4199,7 +4198,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
case TOK_GETFILETIMELOCAL:
{
char buf[129];
DWORD high,low;
DWORD high=0,low=0;
int flag=0;
HANDLE hFile=CreateFile(line.gettoken_str(1),0,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if (hFile != INVALID_HANDLE_VALUE)
@ -5442,7 +5441,7 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
#ifdef NSIS_SUPPORT_STACK
WIN32_FIND_DATA temp;
int a=GetFileAttributes(lgss);
DWORD a=GetFileAttributes(lgss);
const char *fspec=lgss+strlen(dir)+!!dir[0];
strcpy(newfn,lgss);
if (a==INVALID_FILE_ATTRIBUTES)
@ -5467,8 +5466,6 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
{
if (strcmp(d.cFileName,"..") && strcmp(d.cFileName,"."))
{
entry ent={0,};
int a;
char out_path[1024] = "$OUTDIR\\";
{

View file

@ -32,7 +32,7 @@ class GrowBuf : public IGrowBuf
{
public:
GrowBuf() { m_alloc=m_used=m_zero=0; m_s=NULL; m_bs=32768; }
~GrowBuf() { free(m_s); }
virtual ~GrowBuf() { free(m_s); }
void set_zeroing(int zero) { m_zero=zero; }
@ -284,6 +284,8 @@ class SortedStringList
TinyGrowBuf gr;
};
#define mymin(x, y) ((x < y) ? x : y)
template <class T>
class SortedStringListND // no delete - can be placed in GrowBuf
{
@ -311,7 +313,7 @@ class SortedStringListND // no delete - can be placed in GrowBuf
// returns -1 if not found, position if found
// if returnbestpos=1 returns -1 if found, best pos to insert if not found
// if n_chars equal to -1 all string is tested
int find(const char *str, size_t n_chars=-1, int case_sensitive=0, int returnbestpos=0, int *where=0)
int find(const char *str, int n_chars=-1, int case_sensitive=0, int returnbestpos=0, int *where=0)
{
T *data=(T *)gr.get();
int ul=gr.getlen()/sizeof(T);
@ -322,20 +324,20 @@ class SortedStringListND // no delete - can be placed in GrowBuf
{
int res;
const char *pCurr = (char*)strings.get() + data[nextpos].name;
if (n_chars == -1 )
if (n_chars < 0)
{
if (case_sensitive)
res=strcmp(str, pCurr);
res = strcmp(str, pCurr);
else
res=stricmp(str, pCurr);
res = stricmp(str, pCurr);
}
else
{
if (case_sensitive)
res=strncmp(str, pCurr, min(n_chars, strlen(pCurr)));
res=strncmp(str, pCurr, mymin((unsigned int) n_chars, strlen(pCurr)));
else
res=strnicmp(str, pCurr, min(n_chars, strlen(pCurr)));
if ( res == 0 && n_chars != -1 && n_chars != strlen(pCurr) )
res=strnicmp(str, pCurr, mymin((unsigned int) n_chars, strlen(pCurr)));
if (res == 0 && n_chars != -1 && (unsigned int) n_chars != strlen(pCurr))
res = n_chars - strlen(pCurr);
}
@ -498,7 +500,7 @@ class MMapFile : public IMMap
}
}
~MMapFile()
virtual ~MMapFile()
{
clear();
}
@ -750,7 +752,7 @@ class MMapBuf : public IGrowBuf, public IMMap
m_alloc=m_used=0;
}
~MMapBuf()
virtual ~MMapBuf()
{
m_fm.release();
}

View file

@ -357,4 +357,4 @@ int CEXEBuild::IsTokenPlacedRight(int pos, char *tok)
ERROR_MSG(err, tok);
return PS_ERROR;
}
}
}

View file

@ -36,7 +36,7 @@ class UserVarsStringList : public SortedStringListND<struct uservarstring>
return temp;
}
int get(char *name, size_t n_chars = -1)
int get(char *name, int n_chars = -1)
{
int v=SortedStringListND<struct uservarstring>::find(name, n_chars);
if (v==-1) return -1;

View file

@ -298,7 +298,7 @@ int generate_unicons_offsets(unsigned char* exeHeader, unsigned char* uninstIcon
MY_ASSERT((int)rdRoot - (int)exeHeader > iNextSection, "corrupted EXE - invalid pointer");
int idx = find_in_dir(rdRoot, WORD(RT_ICON));
int idx = find_in_dir(rdRoot, (WORD) (int) RT_ICON);
MY_ASSERT(idx == -1, "no icons?!");
MY_ASSERT(!rdRoot->Entries[idx].DataIsDirectory, "bad resource directory");
@ -390,4 +390,4 @@ void operator delete(void *p) {
void operator delete [](void *p) {
if (p) free(p);
}
}

View file

@ -19,11 +19,11 @@ int replace_icon(CResourceEditor* re, WORD wIconId, char* filename);
unsigned char* generate_uninstall_icon_data(char* filename);
// Fill the array of icons for uninstall with their offsets
int generate_unicons_offsets(unsigned char* exeHeader, unsigned char* uninstIconData);
#endif NSIS_CONFIG_UNINSTALL_SUPPORT
#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
// Returns dialog's raw data from a given loaded module
BYTE* get_dlg(HINSTANCE hUIFile, WORD dlgId, char* filename);
#endif
#endif //_UTIL_H_
#endif //_UTIL_H_