diff --git a/Source/build.cpp b/Source/build.cpp index 27a89d29..85620047 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -1944,7 +1944,7 @@ int CEXEBuild::write_output(void) icon_offset = generate_unicons_offsets(header_data_new, m_unicon_data); if (icon_offset == 0) return PS_ERROR; - SCRIPT_MSG("Done!\n"); + SCRIPT_MSG("Done!\n"); } #endif //NSIS_CONFIG_UNINSTALL_SUPPORT @@ -2678,7 +2678,7 @@ void CEXEBuild::init_res_editor() { build_compressor_set=true; if (!res_editor) - res_editor=new CResourceEditor(header_data_new, exeheader_size_new); + res_editor=new CResourceEditor(header_data_new, exeheader_size_new); } void CEXEBuild::close_res_editor() @@ -2694,48 +2694,48 @@ void CEXEBuild::close_res_editor() #ifdef NSIS_SUPPORT_NAMED_USERVARS int CEXEBuild::DeclaredUserVar(const char *szVarName) { - int idxUserVar = m_UserVarNames.get((char*)szVarName); - if ( idxUserVar > 0 ) - { - ERROR_MSG("Error: variable \"%s\" already declared\n", szVarName); - return PS_ERROR; - } - const char *pVarName = szVarName; - int iVarLen = strlen(szVarName); + int idxUserVar = m_UserVarNames.get((char*)szVarName); + if ( idxUserVar > 0 ) + { + ERROR_MSG("Error: variable \"%s\" already declared\n", szVarName); + return PS_ERROR; + } + const char *pVarName = szVarName; + int iVarLen = strlen(szVarName); - if ( iVarLen > 60 ) - { - ERROR_MSG("Error: variable name too long!\n"); - return PS_ERROR; - } - else if ( !iVarLen ) - { - ERROR_MSG("Error: variable with empty name!\n"); - return PS_ERROR; - } - else - { - while ( *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; - } - pVarName++; - } - } + if ( iVarLen > 60 ) + { + ERROR_MSG("Error: variable name too long!\n"); + return PS_ERROR; + } + else if ( !iVarLen ) + { + ERROR_MSG("Error: variable with empty name!\n"); + return PS_ERROR; + } + else + { + while ( *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; + } + pVarName++; + } + } - if ( !strnicmp(szVarName,"un.",3) ) + if ( !strnicmp(szVarName,"un.",3) ) m_UnUserVarNames.add(szVarName); else m_UserVarNames.add(szVarName); if ( m_UserVarNames.getnum() > MAX_NAMED_USER_VARS || m_UnUserVarNames.getnum() > MAX_NAMED_USER_VARS ) - { - ERROR_MSG("Error: too many user variables declared!\n"); + { + ERROR_MSG("Error: too many user variables declared!\n"); return PS_ERROR; } - return PS_OK; + return PS_OK; } #endif diff --git a/Source/build.h b/Source/build.h index e7b814bc..bd94198f 100644 --- a/Source/build.h +++ b/Source/build.h @@ -228,7 +228,7 @@ class CEXEBuild { char build_packname[1024], build_packcmd[1024]; int build_overwrite, build_compress, build_crcchk, build_datesave, build_optimize_datablock, - build_allowskipfiles; // Added by ramon 23 May 2003 + build_allowskipfiles; // Added by ramon 23 May 2003 header build_header; int uninstall_mode; diff --git a/Source/bzip2/blocksort.c b/Source/bzip2/blocksort.c index c67ca14b..c9379590 100644 --- a/Source/bzip2/blocksort.c +++ b/Source/bzip2/blocksort.c @@ -312,7 +312,7 @@ void fallbackSort ( UInt32* fmap, r = -1; while (1) { - /*-- find the next non-singleton bucket --*/ + /*-- find the next non-singleton bucket --*/ k = r + 1; while (ISSET_BH(k) && UNALIGNED_BH(k)) k++; if (ISSET_BH(k)) { diff --git a/Source/bzip2/bzlib.c b/Source/bzip2/bzlib.c index b9868d1f..0badda5f 100644 --- a/Source/bzip2/bzlib.c +++ b/Source/bzip2/bzlib.c @@ -377,7 +377,7 @@ int BZ2_bzCompress( bz_stream *strm, int action ) return progress ? BZ_RUN_OK : BZ_PARAM_ERROR; } else - if (action == BZ_FLUSH) { + if (action == BZ_FLUSH) { s->avail_in_expect = strm->avail_in; s->mode = BZ_M_FLUSHING; goto preswitch; diff --git a/Source/bzip2/compress.c b/Source/bzip2/compress.c index a3b2b816..6bed5398 100644 --- a/Source/bzip2/compress.c +++ b/Source/bzip2/compress.c @@ -360,14 +360,14 @@ void sendMTFValues ( EState* s ) /*--- Set up an auxiliary length table which is used to fast-track - the common case (nGroups == 6). + the common case (nGroups == 6). ---*/ if (nGroups == 6) { for (v = 0; v < alphaSize; v++) { s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v]; s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v]; s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v]; - } + } } nSelectors = 0; @@ -416,7 +416,7 @@ void sendMTFValues ( EState* s ) cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16; } else { - /*--- slow version which correctly handles all situations ---*/ + /*--- slow version which correctly handles all situations ---*/ for (i = gs; i <= ge; i++) { UInt16 icv = mtfv[i]; for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv]; @@ -457,7 +457,7 @@ void sendMTFValues ( EState* s ) # undef BZ_ITUR } else { - /*--- slow version which correctly handles all situations ---*/ + /*--- slow version which correctly handles all situations ---*/ for (i = gs; i <= ge; i++) s->rfreq[bt][ mtfv[i] ]++; } @@ -595,7 +595,7 @@ void sendMTFValues ( EState* s ) # undef BZ_ITAH } else { - /*--- slow version which correctly handles all situations ---*/ + /*--- slow version which correctly handles all situations ---*/ for (i = gs; i <= ge; i++) { bsW ( s, s->len [s->selector[selCtr]] [mtfv[i]], diff --git a/Source/exehead/bgbg.c b/Source/exehead/bgbg.c index 9662b17a..b5079e05 100644 --- a/Source/exehead/bgbg.c +++ b/Source/exehead/bgbg.c @@ -36,15 +36,15 @@ LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) while (r.top < ry) { int rv,gv,bv; - HBRUSH brush; + HBRUSH brush; rv = (GetRValue(c2) * r.top + GetRValue(c1) * (ry-r.top)) / ry; gv = (GetGValue(c2) * r.top + GetGValue(c1) * (ry-r.top)) / ry; bv = (GetBValue(c2) * r.top + GetBValue(c1) * (ry-r.top)) / ry; - brush = CreateSolidBrush(RGB(rv,gv,bv)); - // note that we don't need to do "SelectObject(hdc, brush)" - // because FillRect lets us specify the brush as a parameter. - FillRect(hdc, &r, brush); - DeleteObject(brush); + brush = CreateSolidBrush(RGB(rv,gv,bv)); + // note that we don't need to do "SelectObject(hdc, brush)" + // because FillRect lets us specify the brush as a parameter. + FillRect(hdc, &r, brush); + DeleteObject(brush); r.top+=4; r.bottom+=4; } diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index 363e70f2..ca292d95 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -32,25 +32,25 @@ union installer_flags g_flags; // but in win2k you need to do this manually. static LONG NSISCALL myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyifempty) { - HKEY key; - int retval=RegOpenKeyEx(thiskey,lpSubKey,0,KEY_ENUMERATE_SUB_KEYS,&key); - if (retval==ERROR_SUCCESS) - { + HKEY key; + int retval=RegOpenKeyEx(thiskey,lpSubKey,0,KEY_ENUMERATE_SUB_KEYS,&key); + if (retval==ERROR_SUCCESS) + { // NB - don't change this to static (recursive function) - char buffer[MAX_PATH+1]; - while (RegEnumKey(key,0,buffer,MAX_PATH+1)==ERROR_SUCCESS) + char buffer[MAX_PATH+1]; + while (RegEnumKey(key,0,buffer,MAX_PATH+1)==ERROR_SUCCESS) { if (onlyifempty) { - RegCloseKey(key); + RegCloseKey(key); return !ERROR_SUCCESS; } if ((retval=myRegDeleteKeyEx(key,buffer,0)) != ERROR_SUCCESS) break; } - RegCloseKey(key); - retval=RegDeleteKey(thiskey,lpSubKey); - } - return retval; + RegCloseKey(key); + retval=RegDeleteKey(thiskey,lpSubKey); + } + return retval; } #endif//NSIS_SUPPORT_REGISTRYFUNCTIONS @@ -454,26 +454,26 @@ static int NSISCALL ExecuteEntry(entry *entry_) } #undef overwriteflag - // Added by ramon 23 May 2003 - #undef allowskipfilesflag + // Added by ramon 23 May 2003 + #undef allowskipfilesflag } break; #endif//NSIS_SUPPORT_FILE #ifdef NSIS_SUPPORT_DELETE case EW_DELETEFILE: { - HANDLE h; - WIN32_FIND_DATA fd; + HANDLE h; + WIN32_FIND_DATA fd; char *buf1=process_string_fromparm_tobuf(0x10); mystrcpy(buf0,buf1); log_printf2("Delete: \"%s\"",buf0); trimslashtoend(buf0); h=FindFirstFile(buf1,&fd); - if (h != INVALID_HANDLE_VALUE) - { + if (h != INVALID_HANDLE_VALUE) + { do { - if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { wsprintf(buf1,"%s\\%s",buf0,fd.cFileName); if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) @@ -503,8 +503,8 @@ static int NSISCALL ExecuteEntry(entry *entry_) } } } while (FindNextFile(h,&fd)); - FindClose(h); - } + FindClose(h); + } } break; #endif//NSIS_SUPPORT_DELETE @@ -1038,12 +1038,12 @@ static int NSISCALL ExecuteEntry(entry *entry_) case EW_COPYFILES: // CopyFile (added by NOP) { int res; - SHFILEOPSTRUCT op; + SHFILEOPSTRUCT op; char *buf0=process_string_fromparm_tobuf(0x00); char *buf1=process_string_fromparm_tobuf(0x11); log_printf3("CopyFiles \"%s\"->\"%s\"",buf0,buf1); - op.hwnd=g_hwnd; - op.wFunc=FO_COPY; + op.hwnd=g_hwnd; + op.wFunc=FO_COPY; buf0[mystrlen(buf0)+1]=0; buf1[mystrlen(buf1)+1]=0; @@ -1052,16 +1052,16 @@ static int NSISCALL ExecuteEntry(entry *entry_) op.pFrom=buf0; op.pTo=buf1; op.lpszProgressTitle=buf2; - op.fFlags=parm2; + op.fFlags=parm2; update_status_text("",buf2); - res=SHFileOperation(&op); - if (res) + res=SHFileOperation(&op); + if (res) { // some of these changes were from Edgewise (wiked_edge@yahoo.com) update_status_text_from_lang(LANG_COPYFAILED,""); g_flags.exec_error++; - } - } - break; + } + } + break; #endif//NSIS_SUPPORT_COPYFILES #ifdef NSIS_SUPPORT_REBOOT case EW_REBOOT: @@ -1219,8 +1219,8 @@ static int NSISCALL ExecuteEntry(entry *entry_) p[0]=0; if (RegOpenKeyEx((HKEY)rootkey,buf0,0,KEY_READ,&hKey) == ERROR_SUCCESS) { - DWORD l = NSIS_MAX_STRLEN; - DWORD t; + DWORD l = NSIS_MAX_STRLEN; + DWORD t; if (RegQueryValueEx(hKey,buf1,NULL,&t,p,&l ) != ERROR_SUCCESS || (t != REG_DWORD && t != REG_SZ && t != REG_EXPAND_SZ)) diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index 1fedfd74..278b04be 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -457,7 +457,7 @@ typedef struct typedef struct { int which; - int offsets[MAX_ENTRY_OFFSETS]; // count and meaning of offsets depend on 'which' + int offsets[MAX_ENTRY_OFFSETS]; // count and meaning of offsets depend on 'which' } entry; enum diff --git a/Source/exehead/util.c b/Source/exehead/util.c index a57184bb..872cc18b 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -144,15 +144,15 @@ void NSISCALL trimslashtoend(char *buf) char * NSISCALL scanendslash(const char *str) { char *s=CharPrev(str,str+mystrlen(str)); - if (!*str) return (char*)str-1; - for (;;) - { + if (!*str) return (char*)str-1; + for (;;) + { char *t; - if ('\\' == *s) return s; - t=CharPrev(str,s); - if (t==s) return (char*)str-1; - s=t; - } + if ('\\' == *s) return s; + t=CharPrev(str,s); + if (t==s) return (char*)str-1; + s=t; + } } int NSISCALL validpathspec(char *ubuf) @@ -326,12 +326,12 @@ BOOL NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew) void NSISCALL myRegGetStr(HKEY root, const char *sub, const char *name, char *out) { - HKEY hKey; + HKEY hKey; *out=0; if (RegOpenKeyEx(root,sub,0,KEY_READ,&hKey) == ERROR_SUCCESS) { - DWORD l = NSIS_MAX_STRLEN; - DWORD t; + DWORD l = NSIS_MAX_STRLEN; + DWORD t; if (RegQueryValueEx(hKey,name,NULL,&t,out,&l ) != ERROR_SUCCESS || (t != REG_SZ && t != REG_EXPAND_SZ)) *out=0; out[NSIS_MAX_STRLEN-1]=0; RegCloseKey(hKey); @@ -424,11 +424,11 @@ char * NSISCALL process_string(const char *in) #ifndef NSIS_SUPPORT_NAMED_USERVARS if (nVarIdx < VAR_CODES_START) { - *out++ = nVarIdx; + *out++ = nVarIdx; } else if (nVarIdx == 255) { - *out++ = *in++; + *out++ = *in++; } else { @@ -544,7 +544,7 @@ char * NSISCALL process_string(const char *in) if (nVarIdx == 255) { - *out++ = *in++; + *out++ = *in++; } else if (nVarIdx == VAR_CODES_START) { @@ -634,7 +634,7 @@ char * NSISCALL process_string(const char *in) #endif else // Normal char { - *out++ = nVarIdx; + *out++ = nVarIdx; } #endif } // while diff --git a/Source/exehead/util.h b/Source/exehead/util.h index 8846f7f3..8a2b6329 100644 --- a/Source/exehead/util.h +++ b/Source/exehead/util.h @@ -67,8 +67,8 @@ void * NSISCALL mini_memcpy(void *out, const void *in, int len); // Turn four chars into a dword #ifdef __BIG_ENDIAN__ // Not very likely, but, still... #define CHAR2_TO_WORD(a,b) (((WORD)(b))|((a)<<8)) -#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(c,d))|(CHAR2_TO_WORD(a,b)<<16)) +#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(c,d))|(CHAR2_TO_WORD(a,b)<<16)) #else #define CHAR2_TO_WORD(a,b) (((WORD)(a))|((b)<<8)) -#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(a,b))|(CHAR2_TO_WORD(c,d)<<16)) +#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(a,b))|(CHAR2_TO_WORD(c,d)<<16)) #endif diff --git a/Source/lang.cpp b/Source/lang.cpp index eb168aae..359b230a 100644 --- a/Source/lang.cpp +++ b/Source/lang.cpp @@ -793,7 +793,7 @@ NLF::NLF(char *filename) { if (nlf_version < 4) { switch (i) { - case NLF_LOG_INSTALL_PROCESS: + case NLF_LOG_INSTALL_PROCESS: case NLF_BYTE: case NLF_KILO: case NLF_MEGA: @@ -832,7 +832,7 @@ NLF::NLF(char *filename) { if (*in == '\\') { in++; switch (*in) { - case 'n': + case 'n': *out = '\n'; break; case 'r': diff --git a/Source/lineparse.h b/Source/lineparse.h index 9cceb0c6..a514e7f0 100644 --- a/Source/lineparse.h +++ b/Source/lineparse.h @@ -149,7 +149,7 @@ class LineParser { { if (line[0] == '$' && line[1] == '\\') { switch (line[2]) { - case '"': + case '"': case '\'': case '`': nc += ignore_escaping ? 3 : 1; @@ -171,7 +171,7 @@ class LineParser { for (i = 0; p < line; i++, p++) { if (!ignore_escaping && p[0] == '$' && p[1] == '\\') { switch (p[2]) { - case '"': + case '"': case '\'': case '`': p += 2; diff --git a/Source/script.cpp b/Source/script.cpp index 15f1320b..598aeb7a 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -828,7 +828,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) if (k != 4) { lstrcpy(build_last_page_define, line.gettoken_str(5)); } - case 5: + case 5: if (*line.gettoken_str(4)) p.leavefunc = ns_func.add(line.gettoken_str(4),0); case 4: @@ -868,7 +868,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) #endif//NSIS_SUPPORT_CODECALLBACKS switch (k) { - case 0: + case 0: p.id = NSIS_PAGE_CUSTOM; build_custom_used++; break; @@ -972,7 +972,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) if (k != 2) { lstrcpy(ubuild_last_page_define, line.gettoken_str(5)); } - case 5: + case 5: if (*line.gettoken_str(4)) { if (strnicmp(line.gettoken_str(4),"un.",3)) { ERROR_MSG("\nError: uninstall function must have a un. prefix!\n"); @@ -1037,7 +1037,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) #endif//NSIS_SUPPORT_CODECALLBACKS switch (k) { - case 0: + case 0: p.id = NSIS_PAGE_CUSTOM; ubuild_custom_used++; break; @@ -1143,7 +1143,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) int err = update_bitmap(res_editor, IDB_BITMAP1, line.gettoken_str(1), 96, 16, 8); if (err) { switch (err) { - case -1: + case -1: ERROR_MSG("Error: can't find bitmap\n"); break; case -2: @@ -1325,7 +1325,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) if (k < line.getnumtokens() - 2 - a) PRINTHELP() switch (line.getnumtokens()-a) { - case 4: + case 4: SetString(line.gettoken_str(3+a), NLF_BTN_LICENSE_DISAGREE, 0, lang); case 3: SetString(line.gettoken_str(2+a), NLF_BTN_LICENSE_AGREE, 0, lang); @@ -1341,7 +1341,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) free(dlg); switch (k) { - case 0: + case 0: build_header.common.flags&=~CH_FLAGS_LICENSE_FORCE_SELECTION; dt.RemoveItem(IDC_LICENSEAGREE); dt.RemoveItem(IDC_LICENSEDISAGREE); @@ -4599,7 +4599,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) return PS_ERROR; #endif//!NSIS_SUPPORT_CREATEFONT - // Added by ramon 3 jun 2003 + // Added by ramon 3 jun 2003 #ifdef NSIS_SUPPORT_NAMED_USERVARS case TOK_DEFVAR: { @@ -4609,7 +4609,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) return make_sure_not_in_secorfunc(line.gettoken_str(0)); #else //NSIS_SUPPORT_NAMED_USERVARS - case TOK_DEFVAR: + case TOK_DEFVAR: ERROR_MSG("Error: %s specified, case NSIS_SUPPORT_NAMED_USERVARS not defined.\n",line.gettoken_str(0)); return PS_ERROR; #endif //NSIS_SUPPORT_NAMED_USERVARS diff --git a/Source/util.cpp b/Source/util.cpp index 8e37ee13..d3f10609 100644 --- a/Source/util.cpp +++ b/Source/util.cpp @@ -273,8 +273,8 @@ int generate_unicons_offsets(unsigned char* exeHeader, unsigned char* uninstIcon PIMAGE_SECTION_HEADER sectionHeadersArray = IMAGE_FIRST_SECTION(ntHeaders); for (i = 0; i < ntHeaders->FileHeader.NumberOfSections; i++) - if (dwResourceSectionVA == sectionHeadersArray[i].VirtualAddress) - break; + if (dwResourceSectionVA == sectionHeadersArray[i].VirtualAddress) + break; MY_ASSERT(i == ntHeaders->FileHeader.NumberOfSections, "can't find resource section"); diff --git a/Source/zlib/DEFLATE.H b/Source/zlib/DEFLATE.H index 4189e2d6..e4a48948 100644 --- a/Source/zlib/DEFLATE.H +++ b/Source/zlib/DEFLATE.H @@ -189,7 +189,7 @@ typedef struct internal_state { void _tr_init OF((deflate_state *s)); int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); + int eof)); void _tr_align OF((deflate_state *s)); void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, int eof)); diff --git a/Source/zlib/deflate.c b/Source/zlib/deflate.c index 002f140c..d5777bf3 100644 --- a/Source/zlib/deflate.c +++ b/Source/zlib/deflate.c @@ -104,13 +104,13 @@ int ZEXPORT deflateInit_(strm, level, version, stream_size) int stream_size; { return deflateInit2_(strm, level, Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); + Z_DEFAULT_STRATEGY, version, stream_size); /* To do: ignore strm->next_in if we use it as window */ } /* ========================================================================= */ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) + version, stream_size) z_streamp strm; int level; int method; @@ -129,7 +129,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, */ if (stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; + return Z_VERSION_ERROR; } if (strm == Z_NULL) return Z_STREAM_ERROR; @@ -140,7 +140,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, } if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < 8 || windowBits > MAX_WBITS || level < 0 || level > 9 || - strategy < 0 || strategy > Z_HUFFMAN_ONLY) { + strategy < 0 || strategy > Z_HUFFMAN_ONLY) { return Z_STREAM_ERROR; } @@ -204,9 +204,9 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) if (length < MIN_MATCH) return Z_OK; if (length > MAX_DIST(s)) { - length = MAX_DIST(s); + length = MAX_DIST(s); #ifndef USE_DICT_HEAD - dictionary += dictLength - length; /* use the tail of the dictionary */ + dictionary += dictLength - length; /* use the tail of the dictionary */ #endif } zmemcpy(s->window, dictionary, length); @@ -216,7 +216,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) s->ins_h = s->window[0]; UPDATE_HASH(s, s->ins_h, s->window[1]); for (n = 0; n <= length - MIN_MATCH; n++) { - INSERT_STRING(s, n, hash_head); + INSERT_STRING(s, n, hash_head); } if (hash_head) hash_head = 0; /* to make compiler happy */ return Z_OK; @@ -263,19 +263,19 @@ int ZEXPORT deflateParams(strm, level, strategy) s = strm->state; if (level == Z_DEFAULT_COMPRESSION) { - level = 6; + level = 6; } if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) { - return Z_STREAM_ERROR; + return Z_STREAM_ERROR; } func = configuration_table.func; - s->level = level; - s->max_lazy_match = configuration_table.max_lazy; - s->good_match = configuration_table.good_length; - s->nice_match = configuration_table.nice_length; - s->max_chain_length = configuration_table.max_chain; - s->strategy = strategy; + s->level = level; + s->max_lazy_match = configuration_table.max_lazy; + s->good_match = configuration_table.good_length; + s->nice_match = configuration_table.nice_length; + s->max_chain_length = configuration_table.max_chain; + s->strategy = strategy; return err; } @@ -315,14 +315,14 @@ int ZEXPORT deflate (strm, flush) deflate_state *s; if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_FINISH || flush < 0) { + flush > Z_FINISH || flush < 0) { return Z_STREAM_ERROR; } s = strm->state; if (strm->next_out == Z_NULL || (strm->next_in == Z_NULL && strm->avail_in != 0) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { + (s->status == FINISH_STATE && flush != Z_FINISH)) { ERR_RETURN(strm, Z_STREAM_ERROR); } if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); @@ -339,30 +339,30 @@ int ZEXPORT deflate (strm, flush) if (level_flags > 3) level_flags = 3; header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; + if (s->strstart != 0) header |= PRESET_DICT; header += 31 - (header % 31); s->status = BUSY_STATE; putShortMSB(s, header); - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { -// putShortMSB(s, (uInt)(strm->adler >> 16)); - // putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } -// strm->adler = 1L; + /* Save the adler32 of the preset dictionary: */ + if (s->strstart != 0) { + //putShortMSB(s, (uInt)(strm->adler >> 16)); + //putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + //strm->adler = 1L; } /* Flush as much pending output as possible */ if (s->pending != 0) { flush_pending(strm); if (strm->avail_out == 0) { - s->last_flush = -1; - return Z_OK; - } + s->last_flush = -1; + return Z_OK; + } } else if (strm->avail_in == 0 && flush <= old_flush && - flush != Z_FINISH) { + flush != Z_FINISH) { ERR_RETURN(strm, Z_BUF_ERROR); } @@ -377,17 +377,17 @@ int ZEXPORT deflate (strm, flush) (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { block_state bstate; - bstate = (*(configuration_table.func))(s, flush); + bstate = (*(configuration_table.func))(s, flush); if (bstate == finish_started || bstate == finish_done) { s->status = FINISH_STATE; } if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - } + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ + } + return Z_OK; + } if (bstate == block_done) { if (flush == Z_PARTIAL_FLUSH) { _tr_align(s); @@ -401,10 +401,10 @@ int ZEXPORT deflate (strm, flush) } } flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; + } } } Assert(strm->avail_out > 0, "bug2"); @@ -427,7 +427,7 @@ int ZEXPORT deflateEnd (strm) status = strm->state->status; if (status != INIT_STATE && status != BUSY_STATE && - status != FINISH_STATE) { + status != FINISH_STATE) { return Z_STREAM_ERROR; } @@ -647,10 +647,10 @@ local uInt longest_match(s, cur_match) do { } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); @@ -697,23 +697,23 @@ local void fill_window(s) s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ s->block_start -= (long) wsize; - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); + n = s->hash_size; + p = &s->head[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + } while (--n); - n = wsize; + n = wsize; #ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); + p = &s->prev[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); #endif more += wsize; } @@ -739,8 +739,8 @@ local void fill_window(s) _tr_flush_block(s, (s->block_start >= 0L ? \ (charf *)&s->window[(unsigned)s->block_start] : \ (charf *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (eof)); \ + (ulg)((long)s->strstart - s->block_start), \ + (eof)); \ s->block_start = s->strstart; \ flush_pending(s->strm); \ Tracev((stderr,"[FLUSH]")); \ @@ -766,8 +766,8 @@ local block_state deflate_slow(s, flush) if (s->lookahead < MIN_LOOKAHEAD) { fill_window(s); if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } + return need_more; + } if (s->lookahead == 0) break; /* flush the current block */ } if (s->lookahead >= MIN_MATCH) { @@ -800,7 +800,7 @@ local block_state deflate_slow(s, flush) check_match(s, s->strstart-1, s->prev_match, s->prev_length); _tr_tally_dist(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH, bflush); + s->prev_length - MIN_MATCH, bflush); s->lookahead -= s->prev_length-1; s->prev_length -= 2; @@ -817,8 +817,8 @@ local block_state deflate_slow(s, flush) } else if (s->match_available) { Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - if (bflush) { + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + if (bflush) { FLUSH_BLOCK_ONLY(s, 0); } s->strstart++; diff --git a/Source/zlib/trees.c b/Source/zlib/trees.c index 519308cc..b5907433 100644 --- a/Source/zlib/trees.c +++ b/Source/zlib/trees.c @@ -660,30 +660,29 @@ void _tr_flush_block(s, buf, stored_len, eof) /* Build the Huffman trees unless a stored block is forced */ if (s->level > 0) { + /* Construct the literal and distance trees */ + build_tree(s, (tree_desc *)(&(s->l_desc))); + Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); - /* Construct the literal and distance trees */ - build_tree(s, (tree_desc *)(&(s->l_desc))); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); + build_tree(s, (tree_desc *)(&(s->d_desc))); + Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + max_blindex = build_bl_tree(s); - build_tree(s, (tree_desc *)(&(s->d_desc))); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - max_blindex = build_bl_tree(s); + /* Determine the best encoding. Compute first the block length in bytes*/ + opt_lenb = (s->opt_len+3+7)>>3; + static_lenb = (s->static_len+3+7)>>3; - /* Determine the best encoding. Compute first the block length in bytes*/ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; + Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", + opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, + s->last_lit)); - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; } else { Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ } #ifdef FORCE_STORED