Skip to content

Commit

Permalink
Monster commit to 12.02
Browse files Browse the repository at this point in the history
Sorry for that :p
  • Loading branch information
nmaier committed Feb 2, 2012
1 parent d60058e commit f21fc41
Show file tree
Hide file tree
Showing 55 changed files with 3,155 additions and 2,375 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.user
*.old
*.ncb
*.suo
*.sdf
UpgradeLog*.xml
bin/
obj/
2 changes: 2 additions & 0 deletions 7z/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
AMD64-avx
AMD64-generic
AMD64-sse3
X86-dbg
X86-generic
X86-sse3
*.obj
4 changes: 0 additions & 4 deletions 7z/CPP/7zip/Bundles/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ DIRS = \
Format7zR\~ \
Format7zExtract\~ \
Format7zExtractR\~ \
LzmaCon\~ \
SFXCon\~ \
SFXSetup\~ \
SFXWin\~ \

all: $(DIRS)

Expand Down
7 changes: 4 additions & 3 deletions 7z/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
{
UString fullPathNew;
CreateComplexDirectory(pathParts, fullPathNew);
if (_fi.IsDir)
/*if (_fi.IsDir)
NFile::NDirectory::SetDirTime(fullPathNew,
(WriteCTime && _fi.CTimeDefined) ? &_fi.CTime : NULL,
(WriteATime && _fi.ATimeDefined) ? &_fi.ATime : NULL,
(WriteMTime && _fi.MTimeDefined) ? &_fi.MTime : (_arc->MTimeDefined ? &_arc->MTime : NULL));
(WriteMTime && _fi.MTimeDefined) ? &_fi.MTime : (_arc->MTimeDefined ? &_arc->MTime : NULL));*/
}
}

Expand Down Expand Up @@ -434,10 +434,11 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
}
if (_outFileStream)
{
_outFileStreamSpec->SetTime(
/*_outFileStreamSpec->SetTime(
(WriteCTime && _fi.CTimeDefined) ? &_fi.CTime : NULL,
(WriteATime && _fi.ATimeDefined) ? &_fi.ATime : NULL,
(WriteMTime && _fi.MTimeDefined) ? &_fi.MTime : (_arc->MTimeDefined ? &_arc->MTime : NULL));
*/
_curSize = _outFileStreamSpec->ProcessedSize;
_curSizeDefined = true;
RINOK(_outFileStreamSpec->Close());
Expand Down
21 changes: 17 additions & 4 deletions 7z/CPP/7zip/UI/FileManager/PanelSort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,22 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
// if (panel->_sortIndex == 0)
case kpidName:
{
const UString name1 = panel->GetItemName((int)lParam1);
const UString name2 = panel->GetItemName((int)lParam2);
int res = name1.CompareNoCase(name2);
UString name1 = panel->GetItemName((int)lParam1);
UString name2 = panel->GetItemName((int)lParam2);
const UString ext1 = GetExtension(name1);
const UString ext2 = GetExtension(name2);

if (!ext1.IsEmpty()) {
name1 = name1.Mid(0, name1.Length() - ext1.Length());
}
if (!ext2.IsEmpty()) {
name2 = name2.Mid(0, name2.Length() - ext2.Length());
}

int res = name1.CompareNatural(name2);
if (!res) {
res = ext1.CompareNatural(ext2);
}
/*
if (res != 0 || !panel->_flatMode)
return res;
Expand All @@ -49,7 +62,7 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
{
const UString ext1 = GetExtension(panel->GetItemName((int)lParam1));
const UString ext2 = GetExtension(panel->GetItemName((int)lParam2));
return ext1.CompareNoCase(ext2);
return ext1.CompareNatural(ext2);
}
}
/*
Expand Down
1 change: 0 additions & 1 deletion 7z/CPP/7zip/UI/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ DIRS = \
Client7z\~ \
Console\~ \
Explorer\~ \
Far\~ \
FileManager\~ \
GUI\~ \

Expand Down
14 changes: 7 additions & 7 deletions 7z/CPP/Build.mak
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ RFLAGS = $(RFLAGS) -dUNDER_CE
LFLAGS = $(LFLAGS) /ENTRY:mainACRTStartup
!ENDIF
!ELSE
!IFNDEF NEW_COMPILER
LFLAGS = $(LFLAGS) -OPT:NOWIN98
!ENDIF
CFLAGS = $(CFLAGS) -Gr
CFLAGS = $(CFLAGS)
LIBS = $(LIBS) user32.lib advapi32.lib shell32.lib
!ENDIF

Expand All @@ -50,7 +47,7 @@ COMPL_ASM = $(MY_ML) $** $O/$(*B).obj
COMPL_ASM = $(MY_ML) -c -Fo$O/ $**
!ENDIF

CFLAGS = $(CFLAGS) $(EXTRA_CFLAGS) -nologo -c -Fo$O/ -WX -EHsc -Gr -Gy -GR-
CFLAGS = $(CFLAGS) $(EXTRA_CFLAGS) -nologo -c -Fo$O/ -WX -EHsc -Gy -GR-

CFLAGS = $(CFLAGS) -MT

Expand All @@ -64,8 +61,11 @@ CFLAGS = $(CFLAGS) -W3
CFLAGS_O1 = $(CFLAGS) -Od
CFLAGS_O2 = $(CFLAGS) -Od
!ELSEIF "$(ARCH)" == "sse3"
CFLAGS_O1 = $(CFLAGS) -Og -Ox -Oi -Ot -GT -GF -Og -Qipo -Ob2 -GS -arch:SSE3 -QxSSE3 -QaxSSE4.2 -Quse-intel-optimized-headers
CFLAGS_O2 = $(CFLAGS) -Og -Ox -Oi -Ot -GT -GF -Qipo -Ob2 -Og -QxSSE3 -QaxSSE4.2 -Quse-intel-optimized-headers
CFLAGS_O1 = $(CFLAGS) -Og -Ox -Oi -Ot -GT -GF -Og -Qipo -Ob2 -GS -arch:SSE3 -QxSSE3 -QaxSSE4.2 -Quse-intel-optimized-headers /Qfnalign /Qipo-jobs:4
CFLAGS_O2 = $(CFLAGS) -Og -Ox -Oi -Ot -GT -GF -Qipo -Ob2 -Og -QxSSE3 -QaxSSE4.2 -Quse-intel-optimized-headers /Qfnalign /Qipo-jobs:4
!ELSEIF "$(ARCH)" == "avx"
CFLAGS_O1 = $(CFLAGS) -O3 -Oi -Ot -Ob2 -GT -GF -Qipo -QxSSE4.1 -QaxAVX -Quse-intel-optimized-headers
CFLAGS_O2 = $(CFLAGS) -O3 -Oi -Ot -Ob2 -GT -GF -Qipo -QxSSE4.1 -QaxAVX -Quse-intel-optimized-headers
!ELSE
CFLAGS_O1 = $(CFLAGS) -Ox -Oi -Ot -GT -GF -Og -Qipo -Ob2 -GS
CFLAGS_O2 = $(CFLAGS) -Ox -Oi -Ot -GT -GF -Qipo -Ob2 -Og
Expand Down
6 changes: 6 additions & 0 deletions 7z/CPP/Common/MyString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#endif

#include "MyString.h"
#include "natcmp.h"


#ifdef _WIN32
Expand Down Expand Up @@ -192,6 +193,11 @@ int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2)
}
}

int MyStringCompareNatural(const wchar_t *s1, const wchar_t *s2)
{
return string_natural_compare_ic(s1, s2);
}

/*
int MyStringCompareNoCase(const char *s1, const char *s2)
{
Expand Down
9 changes: 8 additions & 1 deletion 7z/CPP/Common/MyString.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ int MyStringCompare(const wchar_t *s1, const wchar_t *s2);

// int MyStringCompareNoCase(const char *s1, const char *s2);
int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2);
int MyStringCompareNatural(const wchar_t *s1, const wchar_t *s2);

template <class T>
class CStringBase
Expand Down Expand Up @@ -355,7 +356,13 @@ class CStringBase
int CompareNoCase(const T *s) const
{ return MyStringCompareNoCase(_chars, s); }

/*
int CompareNatural(const CStringBase& s) const
{ return MyStringCompareNatural(_chars, s._chars); }

int CompareNatural(const T *s) const
{ return MyStringCompareNatural(_chars, s); }

/*
int Collate(const CStringBase& s) const
{ return MyStringCollate(_chars, s._chars); }
int CollateNoCase(const CStringBase& s) const
Expand Down
160 changes: 160 additions & 0 deletions 7z/CPP/Common/natcmp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/* ************************************************************************ *
To the extent possible under law, Nils Maier has waived all copyright and
related or neighboring rights to string_natural_compare.
http://creativecommons.org/publicdomain/zero/1.0/
* ************************************************************************ */

#ifndef __NATCAMP_H__
#define __NATCAMP_H__

#include <ctype.h>
#include <stdlib.h>

namespace string_natural_compare_ns {
template<typename char_type, class func_tol>
int impl(const char_type *s1, const char_type *s2, func_tol ToLong)
{
for (
register char_type c1, c2, *ep1, *ep2;
(c1 = *s1) && (c2 = *s2);
++s1, ++s2
) {
// Get leading numbers
// Note: the CRT tol implementation will remove leading white space
// This is ok for our purpose
const long n1 = ToLong(s1, &ep1, 10),
n2 = ToLong(s2, &ep2, 10);
// Got numbers?
const bool isn1 = n1 || s1 != ep1,
isn2 = n2 || s2 != ep2;

// Both not a number; regular character compare
if (!isn1 && !isn2) {
const int diff = (int)c1 - c2;
if (diff) {
return diff;
}
continue;
}

// Both are numbers
if (isn1 && isn2) {
if (n1 > n2) {
return 1;
}
if (n2 > n1) {
return -1;
}

// Same number, but might contain different front-padding
// Larger front-padding is cmp-smaller
const size_t d1 = ep1 - s1,
d2 = ep2 - s2;
if (d1 < d2) {
return 1;
}
if (d2 < d1) {
return -1;
}

// Same number
s1 = ep1 - 1;
s2 = ep2 - 1;
continue;
}

// s1 contains a number, while s2 does not
// hence s1 < s2
if (isn1) {
return -1;
}

// s2 contains a number, while s2 does not
// hence s1 > s2
if (isn2) {
return 1;
}
}

// len(s1) > len(s2)
if (*s1) {
return 1;
}
// len(s1) < len(s2)
if (*s2) {
return -1;
}
return 0;
}

// version with transformations
template<typename char_type, class func_tol, class func_transform>
int impl(const char_type *s1, const char_type *s2, func_tol ToLong, func_transform Transform)
{
// For comments see implementation without transformations
for (
register char_type c1, c2, *ep1, *ep2;
(c1 = *s1) && (c2 = *s2);
++s1, ++s2
) {
const long n1 = ToLong(s1, &ep1, 10),
n2 = ToLong(s2, &ep2, 10);
const bool isn1 = n1 || s1 != ep1,
isn2 = n2 || s2 != ep2;
if (!isn1 && !isn2) {
const int diff = (int)Transform(c1) - Transform(c2);
if (diff) {
return diff;
}
continue;
}
if (isn1 && isn2) {
if (n1 > n2) {
return 1;
}
if (n2 > n1) {
return -1;
}
const size_t d1 = ep1 - s1,
d2 = ep2 - s2;
if (d1 < d2) {
return 1;
}
if (d2 < d1) {
return -1;
}
s1 = ep1 - 1;
s2 = ep2 - 1;
continue;
}
if (isn1) {
return -1;
}
if (isn2) {
return 1;
}
}
if (*s1) {
return 1;
}
if (*s2) {
return -1;
}
return 0;
}
};

inline int string_natural_compare(const char* s1, const char *s2) {
return string_natural_compare_ns::impl(s1, s2, ::strtol);
}
inline int string_natural_compare(const wchar_t* s1, const wchar_t *s2) {
return string_natural_compare_ns::impl(s1, s2, ::wcstol);
}
inline int string_natural_compare_ic(const char* s1, const char *s2) {
return string_natural_compare_ns::impl(s1, s2, ::strtol, ::tolower);
}
inline int string_natural_compare_ic(const wchar_t* s1, const wchar_t *s2) {
return string_natural_compare_ns::impl(s1, s2, ::wcstol, ::towlower);
}

#endif
Loading

0 comments on commit f21fc41

Please sign in to comment.