mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 13:14:59 -06:00
17.00
This commit is contained in:
@@ -10,7 +10,11 @@
|
||||
#define COM_TRY_BEGIN try {
|
||||
#define COM_TRY_END } catch(...) { return E_OUTOFMEMORY; }
|
||||
|
||||
// catch(const CNewException &) { return E_OUTOFMEMORY; }
|
||||
/*
|
||||
#define COM_TRY_END } \
|
||||
catch(const CNewException &) { return E_OUTOFMEMORY; } \
|
||||
catch(...) { return HRESULT_FROM_WIN32(ERROR_NOACCESS); } \
|
||||
*/
|
||||
// catch(const CSystemException &e) { return e.ErrorCode; }
|
||||
// catch(...) { return E_FAIL; }
|
||||
|
||||
|
||||
@@ -4,20 +4,6 @@
|
||||
|
||||
#include "CommandLineParser.h"
|
||||
|
||||
static bool IsString1PrefixedByString2_NoCase(const wchar_t *u, const char *a)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
char c = *a;
|
||||
if (c == 0)
|
||||
return true;
|
||||
if ((unsigned char)MyCharLower_Ascii(c) != MyCharLower_Ascii(*u))
|
||||
return false;
|
||||
a++;
|
||||
u++;
|
||||
}
|
||||
}
|
||||
|
||||
namespace NCommandLineParser {
|
||||
|
||||
bool SplitCommandLine(const UString &src, UString &dest1, UString &dest2)
|
||||
@@ -44,7 +30,7 @@ bool SplitCommandLine(const UString &src, UString &dest1, UString &dest2)
|
||||
|
||||
void SplitCommandLine(const UString &s, UStringVector &parts)
|
||||
{
|
||||
UString sTemp = s;
|
||||
UString sTemp (s);
|
||||
sTemp.Trim();
|
||||
parts.Clear();
|
||||
for (;;)
|
||||
@@ -59,18 +45,17 @@ void SplitCommandLine(const UString &s, UStringVector &parts)
|
||||
}
|
||||
|
||||
|
||||
static const char *kStopSwitchParsing = "--";
|
||||
static const char * const kStopSwitchParsing = "--";
|
||||
|
||||
static bool inline IsItSwitchChar(wchar_t c)
|
||||
{
|
||||
return (c == '-');
|
||||
}
|
||||
|
||||
CParser::CParser(unsigned numSwitches):
|
||||
_numSwitches(numSwitches),
|
||||
_switches(0)
|
||||
CParser::CParser():
|
||||
_switches(NULL),
|
||||
StopSwitchIndex(-1)
|
||||
{
|
||||
_switches = new CSwitchResult[numSwitches];
|
||||
}
|
||||
|
||||
CParser::~CParser()
|
||||
@@ -81,7 +66,7 @@ CParser::~CParser()
|
||||
|
||||
// if (s) contains switch then function updates switch structures
|
||||
// out: true, if (s) is a switch
|
||||
bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
|
||||
bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms, unsigned numSwitches)
|
||||
{
|
||||
if (s.IsEmpty() || !IsItSwitchChar(s[0]))
|
||||
return false;
|
||||
@@ -90,13 +75,13 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
|
||||
unsigned switchIndex = 0;
|
||||
int maxLen = -1;
|
||||
|
||||
for (unsigned i = 0; i < _numSwitches; i++)
|
||||
for (unsigned i = 0; i < numSwitches; i++)
|
||||
{
|
||||
const char *key = switchForms[i].Key;
|
||||
const char * const key = switchForms[i].Key;
|
||||
unsigned switchLen = MyStringLen(key);
|
||||
if ((int)switchLen <= maxLen || pos + switchLen > s.Len())
|
||||
continue;
|
||||
if (IsString1PrefixedByString2_NoCase((const wchar_t *)s + pos, key))
|
||||
if (IsString1PrefixedByString2_NoCase_Ascii((const wchar_t *)s + pos, key))
|
||||
{
|
||||
switchIndex = i;
|
||||
maxLen = switchLen;
|
||||
@@ -161,8 +146,10 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
|
||||
break;
|
||||
|
||||
case NSwitchType::kString:
|
||||
sw.PostStrings.Add((const wchar_t *)s + pos);
|
||||
{
|
||||
sw.PostStrings.Add(s.Ptr(pos));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos != s.Len())
|
||||
@@ -173,23 +160,30 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CParser::ParseStrings(const CSwitchForm *switchForms, const UStringVector &commandStrings)
|
||||
|
||||
bool CParser::ParseStrings(const CSwitchForm *switchForms, unsigned numSwitches, const UStringVector &commandStrings)
|
||||
{
|
||||
StopSwitchIndex = -1;
|
||||
ErrorMessage.Empty();
|
||||
ErrorLine.Empty();
|
||||
bool stopSwitch = false;
|
||||
NonSwitchStrings.Clear();
|
||||
delete []_switches;
|
||||
_switches = NULL;
|
||||
_switches = new CSwitchResult[numSwitches];
|
||||
|
||||
FOR_VECTOR (i, commandStrings)
|
||||
{
|
||||
const UString &s = commandStrings[i];
|
||||
if (!stopSwitch)
|
||||
if (StopSwitchIndex < 0)
|
||||
{
|
||||
if (s.IsEqualTo(kStopSwitchParsing))
|
||||
{
|
||||
stopSwitch = true;
|
||||
StopSwitchIndex = NonSwitchStrings.Size();
|
||||
continue;
|
||||
}
|
||||
if (!s.IsEmpty() && IsItSwitchChar(s[0]))
|
||||
{
|
||||
if (ParseString(s, switchForms))
|
||||
if (ParseString(s, switchForms, numSwitches))
|
||||
continue;
|
||||
ErrorLine = s;
|
||||
return false;
|
||||
|
||||
@@ -43,19 +43,19 @@ struct CSwitchResult
|
||||
|
||||
class CParser
|
||||
{
|
||||
unsigned _numSwitches;
|
||||
CSwitchResult *_switches;
|
||||
|
||||
bool ParseString(const UString &s, const CSwitchForm *switchForms);
|
||||
bool ParseString(const UString &s, const CSwitchForm *switchForms, unsigned numSwitches);
|
||||
public:
|
||||
UStringVector NonSwitchStrings;
|
||||
int StopSwitchIndex; // NonSwitchStrings[StopSwitchIndex+] are after "--"
|
||||
AString ErrorMessage;
|
||||
UString ErrorLine;
|
||||
|
||||
CParser(unsigned numSwitches);
|
||||
CParser();
|
||||
~CParser();
|
||||
bool ParseStrings(const CSwitchForm *switchForms, const UStringVector &commandStrings);
|
||||
const CSwitchResult& operator[](size_t index) const { return _switches[index]; }
|
||||
bool ParseStrings(const CSwitchForm *switchForms, unsigned numSwitches, const UStringVector &commandStrings);
|
||||
const CSwitchResult& operator[](unsigned index) const { return _switches[index]; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,41 @@
|
||||
#ifndef __COMMON_COMMON_H
|
||||
#define __COMMON_COMMON_H
|
||||
|
||||
/*
|
||||
This file is included to all cpp files in 7-Zip.
|
||||
Each folder contains StdAfx.h file that includes "Common.h".
|
||||
So 7-Zip includes "Common.h" in both modes:
|
||||
with precompiled StdAfx.h
|
||||
and
|
||||
without precompiled StdAfx.h
|
||||
|
||||
If you use 7-Zip code, you must include "Common.h" before other h files of 7-zip.
|
||||
If you don't need some things that are used in 7-Zip,
|
||||
you can change this h file or h files included in this file.
|
||||
*/
|
||||
|
||||
// compiler pragmas to disable some warnings
|
||||
#include "../../C/Compiler.h"
|
||||
|
||||
// it's <windows.h> or code that defines windows things, if it's not _WIN32
|
||||
#include "MyWindows.h"
|
||||
|
||||
// NewHandler.h and NewHandler.cpp redefine operator new() to throw exceptions, if compiled with old MSVC compilers
|
||||
#include "NewHandler.h"
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[1]))
|
||||
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
|
||||
/* There is BUG in MSVC 6.0 compiler for operator new[]:
|
||||
It doesn't check overflow, when it calculates size in bytes for allocated array.
|
||||
So we can use MY_ARRAY_NEW macro instead of new[] operator. */
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER == 1200) && !defined(_WIN64)
|
||||
#define MY_ARRAY_NEW(p, T, size) p = new T[(size > (unsigned)0xFFFFFFFF / sizeof(T)) ? (unsigned)0xFFFFFFFF / sizeof(T) : size];
|
||||
#else
|
||||
#define MY_ARRAY_NEW(p, T, size) p = new T[size];
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
~CDynLimBuf() { MyFree(_chars); }
|
||||
|
||||
size_t Len() const { return _pos; }
|
||||
bool IsError() const { return _error; }
|
||||
void Empty() { _pos = 0; _error = false; }
|
||||
|
||||
operator const Byte *() const { return _chars; }
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../C/CpuArch.h"
|
||||
|
||||
#include "IntToString.h"
|
||||
|
||||
#define CONVERT_INT_TO_STR(charType, tempSize) \
|
||||
@@ -46,6 +48,12 @@ void ConvertUInt64ToOct(UInt64 val, char *s) throw()
|
||||
while (i);
|
||||
}
|
||||
|
||||
|
||||
#define GET_HEX_CHAR(t) ((char)(((t < 10) ? ('0' + t) : ('A' + (t - 10)))))
|
||||
|
||||
static inline char GetHexChar(unsigned t) { return GET_HEX_CHAR(t); }
|
||||
|
||||
|
||||
void ConvertUInt32ToHex(UInt32 val, char *s) throw()
|
||||
{
|
||||
UInt32 v = val;
|
||||
@@ -59,13 +67,14 @@ void ConvertUInt32ToHex(UInt32 val, char *s) throw()
|
||||
s[i] = 0;
|
||||
do
|
||||
{
|
||||
unsigned t = (unsigned)((val & 0xF));
|
||||
unsigned t = (unsigned)(val & 0xF);
|
||||
val >>= 4;
|
||||
s[--i] = (char)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
|
||||
s[--i] = GET_HEX_CHAR(t);
|
||||
}
|
||||
while (i);
|
||||
}
|
||||
|
||||
|
||||
void ConvertUInt64ToHex(UInt64 val, char *s) throw()
|
||||
{
|
||||
UInt64 v = val;
|
||||
@@ -79,9 +88,9 @@ void ConvertUInt64ToHex(UInt64 val, char *s) throw()
|
||||
s[i] = 0;
|
||||
do
|
||||
{
|
||||
unsigned t = (unsigned)((val & 0xF));
|
||||
unsigned t = (unsigned)(val & 0xF);
|
||||
val >>= 4;
|
||||
s[--i] = (char)((t < 10) ? ('0' + t) : ('A' + (t - 10)));
|
||||
s[--i] = GET_HEX_CHAR(t);
|
||||
}
|
||||
while (i);
|
||||
}
|
||||
@@ -93,7 +102,7 @@ void ConvertUInt32ToHex8Digits(UInt32 val, char *s) throw()
|
||||
{
|
||||
unsigned t = val & 0xF;
|
||||
val >>= 4;
|
||||
s[i] = (char)(((t < 10) ? ('0' + t) : ('A' + (t - 10))));
|
||||
s[i] = GET_HEX_CHAR(t);;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,3 +153,41 @@ void ConvertInt64ToString(Int64 val, wchar_t *s) throw()
|
||||
}
|
||||
ConvertUInt64ToString(val, s);
|
||||
}
|
||||
|
||||
|
||||
static void ConvertByteToHex2Digits(unsigned v, char *s) throw()
|
||||
{
|
||||
s[0] = GetHexChar(v >> 4);
|
||||
s[1] = GetHexChar(v & 0xF);
|
||||
}
|
||||
|
||||
static void ConvertUInt16ToHex4Digits(UInt32 val, char *s) throw()
|
||||
{
|
||||
ConvertByteToHex2Digits(val >> 8, s);
|
||||
ConvertByteToHex2Digits(val & 0xFF, s + 2);
|
||||
}
|
||||
|
||||
char *RawLeGuidToString(const Byte *g, char *s) throw()
|
||||
{
|
||||
ConvertUInt32ToHex8Digits(GetUi32(g ), s); s += 8; *s++ = '-';
|
||||
ConvertUInt16ToHex4Digits(GetUi16(g + 4), s); s += 4; *s++ = '-';
|
||||
ConvertUInt16ToHex4Digits(GetUi16(g + 6), s); s += 4; *s++ = '-';
|
||||
for (unsigned i = 0; i < 8; i++)
|
||||
{
|
||||
if (i == 2)
|
||||
*s++ = '-';
|
||||
ConvertByteToHex2Digits(g[8 + i], s);
|
||||
s += 2;
|
||||
}
|
||||
*s = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
char *RawLeGuidToString_Braced(const Byte *g, char *s) throw()
|
||||
{
|
||||
*s++ = '{';
|
||||
s = RawLeGuidToString(g, s);
|
||||
*s++ = '}';
|
||||
*s = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -21,4 +21,8 @@ void ConvertUInt32ToHex8Digits(UInt32 value, char *s) throw();
|
||||
void ConvertInt64ToString(Int64 value, char *s) throw();
|
||||
void ConvertInt64ToString(Int64 value, wchar_t *s) throw();
|
||||
|
||||
// use RawLeGuid only for RAW bytes that contain stored GUID as Little-endian.
|
||||
char *RawLeGuidToString(const Byte *guid, char *s) throw();
|
||||
char *RawLeGuidToString_Braced(const Byte *guid, char *s) throw();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
|
||||
void CLang::Clear() throw()
|
||||
{
|
||||
delete []_text;
|
||||
_text = 0;
|
||||
_ids.Clear();
|
||||
_offsets.Clear();
|
||||
delete []_text;
|
||||
_text = 0;
|
||||
}
|
||||
|
||||
static const wchar_t *kLangSignature = L";!@Lang2@!UTF-8!";
|
||||
static const char * const kLangSignature = ";!@Lang2@!UTF-8!";
|
||||
|
||||
bool CLang::OpenFromString(const AString &s2)
|
||||
{
|
||||
@@ -29,9 +29,9 @@ bool CLang::OpenFromString(const AString &s2)
|
||||
if (s[0] == 0xFEFF)
|
||||
i++;
|
||||
|
||||
for (const wchar_t *p = kLangSignature;; i++)
|
||||
for (const char *p = kLangSignature;; i++)
|
||||
{
|
||||
wchar_t c = *p++;
|
||||
Byte c = *p++;
|
||||
if (c == 0)
|
||||
break;
|
||||
if (s[i] != c)
|
||||
@@ -109,7 +109,7 @@ bool CLang::OpenFromString(const AString &s2)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CLang::Open(CFSTR fileName, const wchar_t *id)
|
||||
bool CLang::Open(CFSTR fileName, const char *id)
|
||||
{
|
||||
Clear();
|
||||
NWindows::NFile::NIO::CInFile file;
|
||||
@@ -146,7 +146,7 @@ bool CLang::Open(CFSTR fileName, const wchar_t *id)
|
||||
if (OpenFromString(s))
|
||||
{
|
||||
const wchar_t *name = Get(0);
|
||||
if (name && wcscmp(name, id) == 0)
|
||||
if (name && StringsAreEqual_Ascii(name, id))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class CLang
|
||||
public:
|
||||
CLang(): _text(0) {}
|
||||
~CLang() { Clear(); }
|
||||
bool Open(CFSTR fileName, const wchar_t *id);
|
||||
bool Open(CFSTR fileName, const char *id);
|
||||
void Clear() throw();
|
||||
const wchar_t *Get(UInt32 id) const throw();
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ bool ReadNamesFromListFile(CFSTR fileName, UStringVector &strings, UINT codePage
|
||||
if (codePage == MY__CP_UTF16)
|
||||
for (unsigned i = 0; i < num; i++)
|
||||
{
|
||||
wchar_t c = GetUi16(buf + i * 2);
|
||||
wchar_t c = GetUi16(buf + (size_t)i * 2);
|
||||
if (c == 0)
|
||||
return false;
|
||||
p[i] = c;
|
||||
@@ -60,7 +60,7 @@ bool ReadNamesFromListFile(CFSTR fileName, UStringVector &strings, UINT codePage
|
||||
else
|
||||
for (unsigned i = 0; i < num; i++)
|
||||
{
|
||||
wchar_t c = (wchar_t)GetBe16(buf + i * 2);
|
||||
wchar_t c = (wchar_t)GetBe16(buf + (size_t)i * 2);
|
||||
if (c == 0)
|
||||
return false;
|
||||
p[i] = c;
|
||||
@@ -104,7 +104,7 @@ bool ReadNamesFromListFile(CFSTR fileName, UStringVector &strings, UINT codePage
|
||||
wchar_t c = u[i];
|
||||
if (c == kGoodBOM || c == kBadBOM)
|
||||
return false;
|
||||
if (c == L'\n' || c == 0xD)
|
||||
if (c == '\n' || c == 0xD)
|
||||
{
|
||||
AddName(strings, s);
|
||||
s.Empty();
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
#include "Defs.h"
|
||||
|
||||
/* 7-Zip now uses CBuffer only as CByteBuffer.
|
||||
So there is no need to use MY_ARRAY_NEW macro in CBuffer code. */
|
||||
|
||||
template <class T> class CBuffer
|
||||
{
|
||||
T *_items;
|
||||
@@ -119,7 +122,7 @@ bool operator!=(const CBuffer<T>& b1, const CBuffer<T>& b2)
|
||||
}
|
||||
|
||||
|
||||
typedef CBuffer<char> CCharBuffer;
|
||||
// typedef CBuffer<char> CCharBuffer;
|
||||
// typedef CBuffer<wchar_t> CWCharBuffer;
|
||||
typedef CBuffer<unsigned char> CByteBuffer;
|
||||
|
||||
@@ -129,7 +132,7 @@ template <class T> class CObjArray
|
||||
protected:
|
||||
T *_items;
|
||||
private:
|
||||
// we disable constructors
|
||||
// we disable copy
|
||||
CObjArray(const CObjArray &buffer);
|
||||
void operator=(const CObjArray &buffer);
|
||||
public:
|
||||
@@ -138,7 +141,14 @@ public:
|
||||
delete []_items;
|
||||
_items = 0;
|
||||
}
|
||||
CObjArray(size_t size): _items(0) { if (size != 0) _items = new T[size]; }
|
||||
CObjArray(size_t size): _items(0)
|
||||
{
|
||||
if (size != 0)
|
||||
{
|
||||
MY_ARRAY_NEW(_items, T, size)
|
||||
// _items = new T[size];
|
||||
}
|
||||
}
|
||||
CObjArray(): _items(0) {};
|
||||
~CObjArray() { delete []_items; }
|
||||
|
||||
@@ -149,7 +159,8 @@ public:
|
||||
{
|
||||
delete []_items;
|
||||
_items = 0;
|
||||
_items = new T[newSize];
|
||||
MY_ARRAY_NEW(_items, T, newSize)
|
||||
// _items = new T[newSize];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -164,6 +175,7 @@ template <class T> class CObjArray2
|
||||
T *_items;
|
||||
unsigned _size;
|
||||
|
||||
// we disable copy
|
||||
CObjArray2(const CObjArray2 &buffer);
|
||||
void operator=(const CObjArray2 &buffer);
|
||||
public:
|
||||
@@ -216,7 +228,10 @@ public:
|
||||
return;
|
||||
T *newBuffer = NULL;
|
||||
if (size != 0)
|
||||
newBuffer = new T[size];
|
||||
{
|
||||
MY_ARRAY_NEW(newBuffer, T, size)
|
||||
// newBuffer = new T[size];
|
||||
}
|
||||
delete []_items;
|
||||
_items = newBuffer;
|
||||
_size = size;
|
||||
|
||||
45
CPP/Common/MyBuffer2.h
Normal file
45
CPP/Common/MyBuffer2.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// Common/MyBuffer2.h
|
||||
|
||||
#ifndef __COMMON_MY_BUFFER2_H
|
||||
#define __COMMON_MY_BUFFER2_H
|
||||
|
||||
#include "../../C/Alloc.h"
|
||||
|
||||
#include "Defs.h"
|
||||
|
||||
class CMidBuffer
|
||||
{
|
||||
Byte *_data;
|
||||
size_t _size;
|
||||
|
||||
CLASS_NO_COPY(CMidBuffer)
|
||||
|
||||
public:
|
||||
CMidBuffer(): _data(NULL), _size(0) {};
|
||||
~CMidBuffer() { ::MidFree(_data); }
|
||||
|
||||
void Free() { ::MidFree(_data); _data = NULL; _size = 0; }
|
||||
|
||||
bool IsAllocated() const { return _data != NULL; }
|
||||
operator Byte *() { return _data; }
|
||||
operator const Byte *() const { return _data; }
|
||||
size_t Size() const { return _size; }
|
||||
|
||||
void AllocAtLeast(size_t size)
|
||||
{
|
||||
if (!_data || size > _size)
|
||||
{
|
||||
const size_t kMinSize = (size_t)1 << 16;
|
||||
if (size < kMinSize)
|
||||
size = kMinSize;
|
||||
::MidFree(_data);
|
||||
_size = 0;
|
||||
_data = 0;
|
||||
_data = (Byte *)::MidAlloc(size);
|
||||
if (_data)
|
||||
_size = size;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -4,7 +4,6 @@
|
||||
#define __MY_COM_H
|
||||
|
||||
#include "MyWindows.h"
|
||||
#include "NewHandler.h"
|
||||
|
||||
#ifndef RINOK
|
||||
#define RINOK(x) { HRESULT __result_ = (x); if (__result_ != S_OK) return __result_; }
|
||||
@@ -158,7 +157,20 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
If CMyUnknownImp doesn't use virtual destructor, the code size is smaller.
|
||||
But if some class_1 derived from CMyUnknownImp
|
||||
uses MY_ADDREF_RELEASE and IUnknown::Release()
|
||||
and some another class_2 is derived from class_1,
|
||||
then class_1 must use virtual destructor:
|
||||
virtual ~class_1();
|
||||
In that case, class_1::Release() calls correct destructor of class_2.
|
||||
|
||||
Also you can use virtual ~CMyUnknownImp(), if you want to disable warning
|
||||
"class has virtual functions, but destructor is not virtual".
|
||||
*/
|
||||
|
||||
class CMyUnknownImp
|
||||
{
|
||||
@@ -166,9 +178,12 @@ public:
|
||||
ULONG __m_RefCount;
|
||||
CMyUnknownImp(): __m_RefCount(0) {}
|
||||
|
||||
// virtual ~CMyUnknownImp() {};
|
||||
// virtual
|
||||
~CMyUnknownImp() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define MY_QUERYINTERFACE_BEGIN STDMETHOD(QueryInterface) \
|
||||
(REFGUID iid, void **outObject) throw() { *outObject = NULL;
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#include "IntToString.h"
|
||||
|
||||
#if !defined(_UNICODE) || !defined(USE_UNICODE_FSTRING)
|
||||
#include "StringConvert.h"
|
||||
#endif
|
||||
@@ -28,6 +30,10 @@ inline const char* MyStringGetNextCharPointer(const char *p) throw()
|
||||
}
|
||||
*/
|
||||
|
||||
#define MY_STRING_NEW_char(_size_) MY_STRING_NEW(char, _size_)
|
||||
#define MY_STRING_NEW_wchar_t(_size_) MY_STRING_NEW(wchar_t, _size_)
|
||||
|
||||
|
||||
int FindCharPosInString(const char *s, char c) throw()
|
||||
{
|
||||
for (const char *p = s;; p++)
|
||||
@@ -52,7 +58,18 @@ int FindCharPosInString(const wchar_t *s, wchar_t c) throw()
|
||||
}
|
||||
|
||||
/*
|
||||
void MyStringUpper_Ascii(wchar_t *s)
|
||||
void MyStringUpper_Ascii(char *s) throw()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
char c = *s;
|
||||
if (c == 0)
|
||||
return;
|
||||
*s++ = MyCharUpper_Ascii(c);
|
||||
}
|
||||
}
|
||||
|
||||
void MyStringUpper_Ascii(wchar_t *s) throw()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
@@ -282,6 +299,26 @@ bool IsString1PrefixedByString2(const wchar_t *s1, const wchar_t *s2) throw()
|
||||
}
|
||||
}
|
||||
|
||||
bool IsString1PrefixedByString2(const wchar_t *s1, const char *s2) throw()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
unsigned char c2 = (unsigned char)(*s2++); if (c2 == 0) return true;
|
||||
wchar_t c1 = *s1++; if (c1 != c2) return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsString1PrefixedByString2_NoCase_Ascii(const wchar_t *s1, const char *s2) throw()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
char c2 = *s2++; if (c2 == 0) return true;
|
||||
wchar_t c1 = *s1++;
|
||||
if (c1 != (unsigned char)c2 && MyCharLower_Ascii(c1) != (unsigned char)MyCharLower_Ascii(c2))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_t *s2) throw()
|
||||
{
|
||||
for (;;)
|
||||
@@ -345,8 +382,8 @@ void AString::ReAlloc(unsigned newLimit)
|
||||
{
|
||||
if (newLimit < _len || newLimit >= k_Alloc_Len_Limit) throw 20130220;
|
||||
// MY_STRING_REALLOC(_chars, char, newLimit + 1, _len + 1);
|
||||
char *newBuf = MY_STRING_NEW(char, newLimit + 1);
|
||||
memcpy(newBuf, _chars, (size_t)(_len + 1)); \
|
||||
char *newBuf = MY_STRING_NEW_char(newLimit + 1);
|
||||
memcpy(newBuf, _chars, (size_t)(_len + 1));
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = newLimit;
|
||||
@@ -356,7 +393,7 @@ void AString::ReAlloc2(unsigned newLimit)
|
||||
{
|
||||
if (newLimit >= k_Alloc_Len_Limit) throw 20130220;
|
||||
// MY_STRING_REALLOC(_chars, char, newLimit + 1, 0);
|
||||
char *newBuf = MY_STRING_NEW(char, newLimit + 1);
|
||||
char *newBuf = MY_STRING_NEW_char(newLimit + 1);
|
||||
newBuf[0] = 0;
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
@@ -366,7 +403,7 @@ void AString::ReAlloc2(unsigned newLimit)
|
||||
void AString::SetStartLen(unsigned len)
|
||||
{
|
||||
_chars = 0;
|
||||
_chars = MY_STRING_NEW(char, len + 1);
|
||||
_chars = MY_STRING_NEW_char(len + 1);
|
||||
_len = len;
|
||||
_limit = len;
|
||||
}
|
||||
@@ -393,7 +430,6 @@ void AString::Grow(unsigned n)
|
||||
ReAlloc(next - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
AString::AString(unsigned num, const char *s)
|
||||
{
|
||||
unsigned len = MyStringLen(s);
|
||||
@@ -403,7 +439,6 @@ AString::AString(unsigned num, const char *s)
|
||||
memcpy(_chars, s, num);
|
||||
_chars[num] = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
AString::AString(unsigned num, const AString &s)
|
||||
{
|
||||
@@ -421,7 +456,7 @@ AString::AString(const AString &s, char c)
|
||||
unsigned len = s.Len();
|
||||
memcpy(chars, s, len);
|
||||
chars[len] = c;
|
||||
chars[len + 1] = 0;
|
||||
chars[(size_t)len + 1] = 0;
|
||||
}
|
||||
|
||||
AString::AString(const char *s1, unsigned num1, const char *s2, unsigned num2)
|
||||
@@ -436,20 +471,23 @@ AString operator+(const AString &s1, const AString &s2) { return AString(s1, s1.
|
||||
AString operator+(const AString &s1, const char *s2) { return AString(s1, s1.Len(), s2, MyStringLen(s2)); }
|
||||
AString operator+(const char *s1, const AString &s2) { return AString(s1, MyStringLen(s1), s2, s2.Len()); }
|
||||
|
||||
static const unsigned kStartStringCapacity = 4;
|
||||
|
||||
AString::AString()
|
||||
{
|
||||
_chars = 0;
|
||||
_chars = MY_STRING_NEW(char, 4);
|
||||
_chars = MY_STRING_NEW_char(kStartStringCapacity);
|
||||
_len = 0;
|
||||
_limit = 4 - 1;
|
||||
_limit = kStartStringCapacity - 1;
|
||||
_chars[0] = 0;
|
||||
}
|
||||
|
||||
AString::AString(char c)
|
||||
{
|
||||
SetStartLen(1);
|
||||
_chars[0] = c;
|
||||
_chars[1] = 0;
|
||||
char *chars = _chars;
|
||||
chars[0] = c;
|
||||
chars[1] = 0;
|
||||
}
|
||||
|
||||
AString::AString(const char *s)
|
||||
@@ -468,14 +506,15 @@ AString &AString::operator=(char c)
|
||||
{
|
||||
if (1 > _limit)
|
||||
{
|
||||
char *newBuf = MY_STRING_NEW(char, 1 + 1);
|
||||
char *newBuf = MY_STRING_NEW_char(1 + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = 1;
|
||||
}
|
||||
_len = 1;
|
||||
_chars[0] = c;
|
||||
_chars[1] = 0;
|
||||
char *chars = _chars;
|
||||
chars[0] = c;
|
||||
chars[1] = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -484,7 +523,7 @@ AString &AString::operator=(const char *s)
|
||||
unsigned len = MyStringLen(s);
|
||||
if (len > _limit)
|
||||
{
|
||||
char *newBuf = MY_STRING_NEW(char, len + 1);
|
||||
char *newBuf = MY_STRING_NEW_char(len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
@@ -501,7 +540,7 @@ AString &AString::operator=(const AString &s)
|
||||
unsigned len = s._len;
|
||||
if (len > _limit)
|
||||
{
|
||||
char *newBuf = MY_STRING_NEW(char, len + 1);
|
||||
char *newBuf = MY_STRING_NEW_char(len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
@@ -526,7 +565,7 @@ void AString::SetFromWStr_if_Ascii(const wchar_t *s)
|
||||
}
|
||||
if (len > _limit)
|
||||
{
|
||||
char *newBuf = MY_STRING_NEW(char, len + 1);
|
||||
char *newBuf = MY_STRING_NEW_char(len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
@@ -550,7 +589,7 @@ void AString::SetFromBstr_if_Ascii(BSTR s)
|
||||
}
|
||||
if (len > _limit)
|
||||
{
|
||||
char *newBuf = MY_STRING_NEW(char, len + 1);
|
||||
char *newBuf = MY_STRING_NEW_char(len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
@@ -577,6 +616,12 @@ AString &AString::operator+=(const char *s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void AString::Add_OptSpaced(const char *s)
|
||||
{
|
||||
Add_Space_if_NotEmpty();
|
||||
(*this) += s;
|
||||
}
|
||||
|
||||
AString &AString::operator+=(const AString &s)
|
||||
{
|
||||
Grow(s._len);
|
||||
@@ -585,11 +630,18 @@ AString &AString::operator+=(const AString &s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void AString::Add_UInt32(UInt32 v)
|
||||
{
|
||||
char sz[16];
|
||||
ConvertUInt32ToString(v, sz);
|
||||
(*this) += sz;
|
||||
}
|
||||
|
||||
void AString::SetFrom(const char *s, unsigned len) // no check
|
||||
{
|
||||
if (len > _limit)
|
||||
{
|
||||
char *newBuf = MY_STRING_NEW(char, len + 1);
|
||||
char *newBuf = MY_STRING_NEW_char(len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
@@ -694,7 +746,7 @@ void AString::TrimRight() throw()
|
||||
unsigned i;
|
||||
for (i = _len; i != 0; i--)
|
||||
{
|
||||
char c = p[i - 1];
|
||||
char c = p[(size_t)i - 1];
|
||||
if (c != ' ' && c != '\n' && c != '\t')
|
||||
break;
|
||||
}
|
||||
@@ -780,12 +832,13 @@ void AString::Replace(char oldChar, char newChar) throw()
|
||||
return; // 0;
|
||||
// unsigned number = 0;
|
||||
int pos = 0;
|
||||
char *chars = _chars;
|
||||
while ((unsigned)pos < _len)
|
||||
{
|
||||
pos = Find(oldChar, pos);
|
||||
if (pos < 0)
|
||||
break;
|
||||
_chars[(unsigned)pos] = newChar;
|
||||
chars[(unsigned)pos] = newChar;
|
||||
pos++;
|
||||
// number++;
|
||||
}
|
||||
@@ -895,7 +948,7 @@ void UString::ReAlloc(unsigned newLimit)
|
||||
{
|
||||
if (newLimit < _len || newLimit >= k_Alloc_Len_Limit) throw 20130221;
|
||||
// MY_STRING_REALLOC(_chars, wchar_t, newLimit + 1, _len + 1);
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, newLimit + 1);
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(newLimit + 1);
|
||||
wmemcpy(newBuf, _chars, _len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
@@ -906,7 +959,7 @@ void UString::ReAlloc2(unsigned newLimit)
|
||||
{
|
||||
if (newLimit >= k_Alloc_Len_Limit) throw 20130221;
|
||||
// MY_STRING_REALLOC(_chars, wchar_t, newLimit + 1, 0);
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, newLimit + 1);
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(newLimit + 1);
|
||||
newBuf[0] = 0;
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
@@ -916,7 +969,7 @@ void UString::ReAlloc2(unsigned newLimit)
|
||||
void UString::SetStartLen(unsigned len)
|
||||
{
|
||||
_chars = 0;
|
||||
_chars = MY_STRING_NEW(wchar_t, len + 1);
|
||||
_chars = MY_STRING_NEW_wchar_t(len + 1);
|
||||
_len = len;
|
||||
_limit = len;
|
||||
}
|
||||
@@ -971,7 +1024,7 @@ UString::UString(const UString &s, wchar_t c)
|
||||
unsigned len = s.Len();
|
||||
wmemcpy(chars, s, len);
|
||||
chars[len] = c;
|
||||
chars[len + 1] = 0;
|
||||
chars[(size_t)len + 1] = 0;
|
||||
}
|
||||
|
||||
UString::UString(const wchar_t *s1, unsigned num1, const wchar_t *s2, unsigned num2)
|
||||
@@ -989,17 +1042,26 @@ UString operator+(const wchar_t *s1, const UString &s2) { return UString(s1, MyS
|
||||
UString::UString()
|
||||
{
|
||||
_chars = 0;
|
||||
_chars = MY_STRING_NEW(wchar_t, 4);
|
||||
_chars = MY_STRING_NEW_wchar_t(kStartStringCapacity);
|
||||
_len = 0;
|
||||
_limit = 4 - 1;
|
||||
_limit = kStartStringCapacity - 1;
|
||||
_chars[0] = 0;
|
||||
}
|
||||
|
||||
UString::UString(wchar_t c)
|
||||
{
|
||||
SetStartLen(1);
|
||||
_chars[0] = c;
|
||||
_chars[1] = 0;
|
||||
wchar_t *chars = _chars;
|
||||
chars[0] = c;
|
||||
chars[1] = 0;
|
||||
}
|
||||
|
||||
UString::UString(char c)
|
||||
{
|
||||
SetStartLen(1);
|
||||
wchar_t *chars = _chars;
|
||||
chars[0] = (unsigned char)c;
|
||||
chars[1] = 0;
|
||||
}
|
||||
|
||||
UString::UString(const wchar_t *s)
|
||||
@@ -1009,6 +1071,16 @@ UString::UString(const wchar_t *s)
|
||||
wmemcpy(_chars, s, len + 1);
|
||||
}
|
||||
|
||||
UString::UString(const char *s)
|
||||
{
|
||||
unsigned len = MyStringLen(s);
|
||||
SetStartLen(len);
|
||||
wchar_t *chars = _chars;
|
||||
for (unsigned i = 0; i < len; i++)
|
||||
chars[i] = (unsigned char)s[i];
|
||||
chars[len] = 0;
|
||||
}
|
||||
|
||||
UString::UString(const UString &s)
|
||||
{
|
||||
SetStartLen(s._len);
|
||||
@@ -1019,14 +1091,15 @@ UString &UString::operator=(wchar_t c)
|
||||
{
|
||||
if (1 > _limit)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, 1 + 1);
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(1 + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = 1;
|
||||
}
|
||||
_len = 1;
|
||||
_chars[0] = c;
|
||||
_chars[1] = 0;
|
||||
wchar_t *chars = _chars;
|
||||
chars[0] = c;
|
||||
chars[1] = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -1035,7 +1108,7 @@ UString &UString::operator=(const wchar_t *s)
|
||||
unsigned len = MyStringLen(s);
|
||||
if (len > _limit)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, len + 1);
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
@@ -1052,7 +1125,7 @@ UString &UString::operator=(const UString &s)
|
||||
unsigned len = s._len;
|
||||
if (len > _limit)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, len + 1);
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
@@ -1062,12 +1135,27 @@ UString &UString::operator=(const UString &s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void UString::SetFrom(const wchar_t *s, unsigned len) // no check
|
||||
{
|
||||
if (len > _limit)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
}
|
||||
if (len != 0)
|
||||
wmemcpy(_chars, s, len);
|
||||
_chars[len] = 0;
|
||||
_len = len;
|
||||
}
|
||||
|
||||
void UString::SetFromBstr(BSTR s)
|
||||
{
|
||||
unsigned len = ::SysStringLen(s);
|
||||
if (len > _limit)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, len + 1);
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
@@ -1077,6 +1165,24 @@ void UString::SetFromBstr(BSTR s)
|
||||
wmemcpy(_chars, s, len + 1);
|
||||
}
|
||||
|
||||
UString &UString::operator=(const char *s)
|
||||
{
|
||||
unsigned len = MyStringLen(s);
|
||||
if (len > _limit)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
}
|
||||
wchar_t *chars = _chars;
|
||||
for (unsigned i = 0; i < len; i++)
|
||||
chars[i] = (unsigned char)s[i];
|
||||
chars[len] = 0;
|
||||
_len = len;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void UString::Add_Space() { operator+=(L' '); }
|
||||
void UString::Add_Space_if_NotEmpty() { if (!IsEmpty()) Add_Space(); }
|
||||
|
||||
@@ -1108,39 +1214,7 @@ UString &UString::operator+=(const UString &s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void UString::SetFrom(const wchar_t *s, unsigned len) // no check
|
||||
{
|
||||
if (len > _limit)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
}
|
||||
if (len != 0)
|
||||
wmemcpy(_chars, s, len);
|
||||
_chars[len] = 0;
|
||||
_len = len;
|
||||
}
|
||||
|
||||
void UString::SetFromAscii(const char *s)
|
||||
{
|
||||
unsigned len = MyStringLen(s);
|
||||
if (len > _limit)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, len + 1);
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
_limit = len;
|
||||
}
|
||||
wchar_t *chars = _chars;
|
||||
for (unsigned i = 0; i < len; i++)
|
||||
chars[i] = (unsigned char)s[i];
|
||||
chars[len] = 0;
|
||||
_len = len;
|
||||
}
|
||||
|
||||
void UString::AddAscii(const char *s)
|
||||
UString &UString::operator+=(const char *s)
|
||||
{
|
||||
unsigned len = MyStringLen(s);
|
||||
Grow(len);
|
||||
@@ -1149,9 +1223,17 @@ void UString::AddAscii(const char *s)
|
||||
chars[i] = (unsigned char)s[i];
|
||||
chars[len] = 0;
|
||||
_len += len;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void UString::Add_UInt32(UInt32 v)
|
||||
{
|
||||
char sz[16];
|
||||
ConvertUInt32ToString(v, sz);
|
||||
(*this) += sz;
|
||||
}
|
||||
|
||||
|
||||
int UString::Find(const wchar_t *s, unsigned startIndex) const throw()
|
||||
{
|
||||
@@ -1238,7 +1320,7 @@ void UString::TrimRight() throw()
|
||||
unsigned i;
|
||||
for (i = _len; i != 0; i--)
|
||||
{
|
||||
wchar_t c = p[i - 1];
|
||||
wchar_t c = p[(size_t)i - 1];
|
||||
if (c != ' ' && c != '\n' && c != '\t')
|
||||
break;
|
||||
}
|
||||
@@ -1324,12 +1406,13 @@ void UString::Replace(wchar_t oldChar, wchar_t newChar) throw()
|
||||
return; // 0;
|
||||
// unsigned number = 0;
|
||||
int pos = 0;
|
||||
wchar_t *chars = _chars;
|
||||
while ((unsigned)pos < _len)
|
||||
{
|
||||
pos = Find(oldChar, pos);
|
||||
if (pos < 0)
|
||||
break;
|
||||
_chars[(unsigned)pos] = newChar;
|
||||
chars[(unsigned)pos] = newChar;
|
||||
pos++;
|
||||
// number++;
|
||||
}
|
||||
@@ -1392,13 +1475,13 @@ void UString2::ReAlloc2(unsigned newLimit)
|
||||
{
|
||||
if (newLimit >= k_Alloc_Len_Limit) throw 20130221;
|
||||
// MY_STRING_REALLOC(_chars, wchar_t, newLimit + 1, 0);
|
||||
_chars = MY_STRING_NEW(wchar_t, newLimit + 1);
|
||||
_chars = MY_STRING_NEW_wchar_t(newLimit + 1);
|
||||
}
|
||||
|
||||
void UString2::SetStartLen(unsigned len)
|
||||
{
|
||||
_chars = 0;
|
||||
_chars = MY_STRING_NEW(wchar_t, len + 1);
|
||||
_chars = MY_STRING_NEW_wchar_t(len + 1);
|
||||
_len = len;
|
||||
}
|
||||
|
||||
@@ -1407,8 +1490,9 @@ void UString2::SetStartLen(unsigned len)
|
||||
UString2::UString2(wchar_t c)
|
||||
{
|
||||
SetStartLen(1);
|
||||
_chars[0] = c;
|
||||
_chars[1] = 0;
|
||||
wchar_t *chars = _chars;
|
||||
chars[0] = c;
|
||||
chars[1] = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1433,14 +1517,15 @@ UString2 &UString2::operator=(wchar_t c)
|
||||
{
|
||||
if (1 > _len)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, 1 + 1);
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(1 + 1);
|
||||
if (_chars)
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
}
|
||||
_len = 1;
|
||||
_chars[0] = c;
|
||||
_chars[1] = 0;
|
||||
wchar_t *chars = _chars;
|
||||
chars[0] = c;
|
||||
chars[1] = 0;
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
@@ -1450,7 +1535,7 @@ UString2 &UString2::operator=(const wchar_t *s)
|
||||
unsigned len = MyStringLen(s);
|
||||
if (len > _len)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, len + 1);
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(len + 1);
|
||||
if (_chars)
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
@@ -1465,7 +1550,7 @@ void UString2::SetFromAscii(const char *s)
|
||||
unsigned len = MyStringLen(s);
|
||||
if (len > _len)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, len + 1);
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(len + 1);
|
||||
if (_chars)
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
@@ -1484,7 +1569,7 @@ UString2 &UString2::operator=(const UString2 &s)
|
||||
unsigned len = s._len;
|
||||
if (len > _len)
|
||||
{
|
||||
wchar_t *newBuf = MY_STRING_NEW(wchar_t, len + 1);
|
||||
wchar_t *newBuf = MY_STRING_NEW_wchar_t(len + 1);
|
||||
if (_chars)
|
||||
MY_STRING_DELETE(_chars);
|
||||
_chars = newBuf;
|
||||
@@ -1542,6 +1627,11 @@ AString fs2fas(CFSTR s)
|
||||
return UnicodeStringToMultiByte(s, GetCurrentCodePage());
|
||||
}
|
||||
|
||||
FString fas2fs(const char *s)
|
||||
{
|
||||
return MultiByteToUnicodeString(s, GetCurrentCodePage());
|
||||
}
|
||||
|
||||
FString fas2fs(const AString &s)
|
||||
{
|
||||
return MultiByteToUnicodeString(s, GetCurrentCodePage());
|
||||
@@ -1551,9 +1641,14 @@ FString fas2fs(const AString &s)
|
||||
|
||||
#else
|
||||
|
||||
UString fs2us(const FChar *s)
|
||||
{
|
||||
return MultiByteToUnicodeString(s, GetCurrentCodePage());
|
||||
}
|
||||
|
||||
UString fs2us(const FString &s)
|
||||
{
|
||||
return MultiByteToUnicodeString((AString)s, GetCurrentCodePage());
|
||||
return MultiByteToUnicodeString(s, GetCurrentCodePage());
|
||||
}
|
||||
|
||||
FString us2fs(const wchar_t *s)
|
||||
|
||||
@@ -14,6 +14,26 @@
|
||||
#include "MyTypes.h"
|
||||
#include "MyVector.h"
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _NATIVE_WCHAR_T_DEFINED
|
||||
#define MY_NATIVE_WCHAR_T_DEFINED
|
||||
#endif
|
||||
#else
|
||||
#define MY_NATIVE_WCHAR_T_DEFINED
|
||||
#endif
|
||||
|
||||
/*
|
||||
native support for wchar_t:
|
||||
_MSC_VER == 1600 : /Zc:wchar_t is not supported
|
||||
_MSC_VER == 1310 (VS2003)
|
||||
? _MSC_VER == 1400 (VS2005) : wchar_t <- unsigned short
|
||||
/Zc:wchar_t : wchar_t <- __wchar_t, _WCHAR_T_DEFINED and _NATIVE_WCHAR_T_DEFINED
|
||||
_MSC_VER > 1400 (VS2008+)
|
||||
/Zc:wchar_t[-]
|
||||
/Zc:wchar_t is on by default
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#define IS_PATH_SEPAR(c) ((c) == '\\' || (c) == '/')
|
||||
#else
|
||||
@@ -60,6 +80,12 @@ inline void MyStringCopy(wchar_t *dest, const wchar_t *src)
|
||||
while ((*dest++ = *src++) != 0);
|
||||
}
|
||||
|
||||
inline void MyStringCat(wchar_t *dest, const wchar_t *src)
|
||||
{
|
||||
MyStringCopy(dest + MyStringLen(dest), src);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
inline wchar_t *MyWcpCpy(wchar_t *dest, const wchar_t *src)
|
||||
{
|
||||
@@ -88,13 +114,15 @@ int FindCharPosInString(const wchar_t *s, wchar_t c) throw();
|
||||
#define STRING_UNICODE_THROW throw()
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
inline char MyCharUpper_Ascii(char c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
return (char)(c - 0x20);
|
||||
return (char)((unsigned char)c - 0x20);
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
inline wchar_t MyCharUpper_Ascii(wchar_t c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
@@ -158,6 +186,7 @@ inline wchar_t MyCharLower(wchar_t c) throw()
|
||||
// char *MyStringUpper(char *s) throw();
|
||||
// char *MyStringLower(char *s) throw();
|
||||
|
||||
// void MyStringUpper_Ascii(char *s) throw();
|
||||
// void MyStringUpper_Ascii(wchar_t *s) throw();
|
||||
void MyStringLower_Ascii(char *s) throw();
|
||||
void MyStringLower_Ascii(wchar_t *s) throw();
|
||||
@@ -168,8 +197,11 @@ bool StringsAreEqualNoCase(const wchar_t *s1, const wchar_t *s2) throw();
|
||||
|
||||
bool IsString1PrefixedByString2(const char *s1, const char *s2) throw();
|
||||
bool IsString1PrefixedByString2(const wchar_t *s1, const wchar_t *s2) throw();
|
||||
bool IsString1PrefixedByString2(const wchar_t *s1, const char *s2) throw();
|
||||
bool IsString1PrefixedByString2_NoCase_Ascii(const wchar_t *u, const char *a) throw();
|
||||
bool IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_t *s2) throw();
|
||||
|
||||
#define MyStringCompare(s1, s2) wcscmp(s1, s2)
|
||||
int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2) throw();
|
||||
// int MyStringCompareNoCase_N(const wchar_t *s1, const wchar_t *s2, unsigned num) throw();
|
||||
|
||||
@@ -183,6 +215,33 @@ bool StringsAreEqualNoCase_Ascii(const wchar_t *s1, const wchar_t *s2) throw();
|
||||
#define MY_STRING_DELETE(_p_) delete []_p_;
|
||||
// #define MY_STRING_DELETE(_p_) my_delete(_p_);
|
||||
|
||||
|
||||
#define FORBID_STRING_OPS_2(cls, t) \
|
||||
void Find(t) const; \
|
||||
void Find(t, unsigned startIndex) const; \
|
||||
void ReverseFind(t) const; \
|
||||
void InsertAtFront(t); \
|
||||
void RemoveChar(t); \
|
||||
void Replace(t, t); \
|
||||
|
||||
#define FORBID_STRING_OPS(cls, t) \
|
||||
explicit cls(t); \
|
||||
explicit cls(const t *); \
|
||||
cls &operator=(t); \
|
||||
cls &operator=(const t *); \
|
||||
cls &operator+=(t); \
|
||||
cls &operator+=(const t *); \
|
||||
FORBID_STRING_OPS_2(cls, t); \
|
||||
|
||||
/*
|
||||
cls &operator+(t); \
|
||||
cls &operator+(const t *); \
|
||||
*/
|
||||
|
||||
#define FORBID_STRING_OPS_AString(t) FORBID_STRING_OPS(AString, t)
|
||||
#define FORBID_STRING_OPS_UString(t) FORBID_STRING_OPS(UString, t)
|
||||
#define FORBID_STRING_OPS_UString2(t) FORBID_STRING_OPS(UString2, t)
|
||||
|
||||
class AString
|
||||
{
|
||||
char *_chars;
|
||||
@@ -202,7 +261,7 @@ class AString
|
||||
void Grow_1();
|
||||
void Grow(unsigned n);
|
||||
|
||||
// AString(unsigned num, const char *s);
|
||||
AString(unsigned num, const char *s);
|
||||
AString(unsigned num, const AString &s);
|
||||
AString(const AString &s, char c); // it's for String + char
|
||||
AString(const char *s1, unsigned num1, const char *s2, unsigned num2);
|
||||
@@ -215,20 +274,24 @@ class AString
|
||||
friend AString operator+(const char *s1, const AString &s2);
|
||||
|
||||
// ---------- forbidden functions ----------
|
||||
AString &operator+=(wchar_t c);
|
||||
AString &operator=(wchar_t c);
|
||||
AString(wchar_t c);
|
||||
void Find(wchar_t c) const;
|
||||
void Find(wchar_t c, unsigned startIndex) const;
|
||||
void ReverseFind(wchar_t c) const;
|
||||
void InsertAtFront(wchar_t c);
|
||||
void RemoveChar(wchar_t ch);
|
||||
void Replace(wchar_t oldChar, wchar_t newChar);
|
||||
|
||||
#ifdef MY_NATIVE_WCHAR_T_DEFINED
|
||||
FORBID_STRING_OPS_AString(wchar_t)
|
||||
#endif
|
||||
|
||||
FORBID_STRING_OPS_AString(signed char)
|
||||
FORBID_STRING_OPS_AString(unsigned char)
|
||||
FORBID_STRING_OPS_AString(short)
|
||||
FORBID_STRING_OPS_AString(unsigned short)
|
||||
FORBID_STRING_OPS_AString(int)
|
||||
FORBID_STRING_OPS_AString(unsigned)
|
||||
FORBID_STRING_OPS_AString(long)
|
||||
FORBID_STRING_OPS_AString(unsigned long)
|
||||
|
||||
public:
|
||||
AString();
|
||||
AString(char c);
|
||||
AString(const char *s);
|
||||
explicit AString();
|
||||
explicit AString(char c);
|
||||
explicit AString(const char *s);
|
||||
AString(const AString &s);
|
||||
~AString() { MY_STRING_DELETE(_chars); }
|
||||
|
||||
@@ -240,7 +303,7 @@ public:
|
||||
const char *Ptr() const { return _chars; }
|
||||
const char *Ptr(unsigned pos) const { return _chars + pos; }
|
||||
const char *RightPtr(unsigned num) const { return _chars + _len - num; }
|
||||
char Back() const { return _chars[_len - 1]; }
|
||||
char Back() const { return _chars[(size_t)_len - 1]; }
|
||||
|
||||
void ReplaceOneCharAtPos(unsigned pos, char c) { _chars[pos] = c; }
|
||||
|
||||
@@ -292,16 +355,17 @@ public:
|
||||
|
||||
void Add_Space();
|
||||
void Add_Space_if_NotEmpty();
|
||||
void Add_OptSpaced(const char *s);
|
||||
void Add_LF();
|
||||
void Add_PathSepar() { operator+=(CHAR_PATH_SEPARATOR); }
|
||||
|
||||
AString &operator+=(const char *s);
|
||||
AString &operator+=(const AString &s);
|
||||
void AddAscii(const char *s) { operator+=(s); }
|
||||
|
||||
void Add_UInt32(UInt32 v);
|
||||
|
||||
void SetFrom(const char *s, unsigned len); // no check
|
||||
void SetFrom_CalcLen(const char *s, unsigned len);
|
||||
// void SetFromAscii(const char *s) { operator+=(s); }
|
||||
|
||||
AString Mid(unsigned startIndex, unsigned count) const { return AString(count, _chars + startIndex); }
|
||||
AString Left(unsigned count) const { return AString(count, *this); }
|
||||
@@ -444,28 +508,27 @@ class UString
|
||||
|
||||
// ---------- forbidden functions ----------
|
||||
|
||||
UString &operator+=(char c);
|
||||
UString &operator+=(unsigned char c);
|
||||
UString &operator=(char c);
|
||||
UString &operator=(unsigned char c);
|
||||
UString(char c);
|
||||
UString(unsigned char c);
|
||||
void Find(char c) const;
|
||||
void Find(unsigned char c) const;
|
||||
void Find(char c, unsigned startIndex) const;
|
||||
void Find(unsigned char c, unsigned startIndex) const;
|
||||
void ReverseFind(char c) const;
|
||||
void ReverseFind(unsigned char c) const;
|
||||
void InsertAtFront(char c);
|
||||
void InsertAtFront(unsigned char c);
|
||||
void RemoveChar(char ch);
|
||||
void RemoveChar(unsigned char ch);
|
||||
void Replace(char oldChar, char newChar);
|
||||
void Replace(unsigned char oldChar, unsigned char newChar);
|
||||
FORBID_STRING_OPS_UString(signed char)
|
||||
FORBID_STRING_OPS_UString(unsigned char)
|
||||
FORBID_STRING_OPS_UString(short)
|
||||
|
||||
#ifdef MY_NATIVE_WCHAR_T_DEFINED
|
||||
FORBID_STRING_OPS_UString(unsigned short)
|
||||
#endif
|
||||
|
||||
FORBID_STRING_OPS_UString(int)
|
||||
FORBID_STRING_OPS_UString(unsigned)
|
||||
FORBID_STRING_OPS_UString(long)
|
||||
FORBID_STRING_OPS_UString(unsigned long)
|
||||
|
||||
FORBID_STRING_OPS_2(UString, char)
|
||||
|
||||
public:
|
||||
UString();
|
||||
UString(wchar_t c);
|
||||
explicit UString(wchar_t c);
|
||||
explicit UString(char c);
|
||||
explicit UString(const char *s);
|
||||
// UString(const AString &s);
|
||||
UString(const wchar_t *s);
|
||||
UString(const UString &s);
|
||||
~UString() { MY_STRING_DELETE(_chars); }
|
||||
@@ -478,7 +541,7 @@ public:
|
||||
const wchar_t *Ptr() const { return _chars; }
|
||||
const wchar_t *Ptr(unsigned pos) const { return _chars + pos; }
|
||||
const wchar_t *RightPtr(unsigned num) const { return _chars + _len - num; }
|
||||
wchar_t Back() const { return _chars[_len - 1]; }
|
||||
wchar_t Back() const { return _chars[(size_t)_len - 1]; }
|
||||
|
||||
void ReplaceOneCharAtPos(unsigned pos, wchar_t c) { _chars[pos] = c; }
|
||||
|
||||
@@ -508,9 +571,13 @@ public:
|
||||
}
|
||||
|
||||
UString &operator=(wchar_t c);
|
||||
UString &operator=(char c) { return (*this)=((wchar_t)c); }
|
||||
UString &operator=(const wchar_t *s);
|
||||
UString &operator=(const UString &s);
|
||||
void SetFrom(const wchar_t *s, unsigned len); // no check
|
||||
void SetFromBstr(BSTR s);
|
||||
UString &operator=(const char *s);
|
||||
UString &operator=(const AString &s) { return operator=(s.Ptr()); }
|
||||
|
||||
UString &operator+=(wchar_t c)
|
||||
{
|
||||
@@ -524,6 +591,8 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
UString &operator+=(char c) { return (*this)+=((wchar_t)(unsigned char)c); }
|
||||
|
||||
void Add_Space();
|
||||
void Add_Space_if_NotEmpty();
|
||||
void Add_LF();
|
||||
@@ -531,11 +600,10 @@ public:
|
||||
|
||||
UString &operator+=(const wchar_t *s);
|
||||
UString &operator+=(const UString &s);
|
||||
UString &operator+=(const char *s);
|
||||
UString &operator+=(const AString &s) { return operator+=(s.Ptr()); }
|
||||
|
||||
void SetFrom(const wchar_t *s, unsigned len); // no check
|
||||
|
||||
void SetFromAscii(const char *s);
|
||||
void AddAscii(const char *s);
|
||||
void Add_UInt32(UInt32 v);
|
||||
|
||||
UString Mid(unsigned startIndex, unsigned count) const { return UString(count, _chars + startIndex); }
|
||||
UString Left(unsigned count) const { return UString(count, *this); }
|
||||
@@ -630,6 +698,12 @@ void operator==(const UString &s1, wchar_t c2);
|
||||
|
||||
void operator+(wchar_t c, const UString &s); // this function can be OK, but we don't use it
|
||||
|
||||
void operator+(const AString &s1, const UString &s2);
|
||||
void operator+(const UString &s1, const AString &s2);
|
||||
|
||||
void operator+(const UString &s1, const char *s2);
|
||||
void operator+(const char *s1, const UString &s2);
|
||||
|
||||
void operator+(const UString &s, char c);
|
||||
void operator+(const UString &s, unsigned char c);
|
||||
void operator+(char c, const UString &s);
|
||||
@@ -662,15 +736,16 @@ class UString2
|
||||
|
||||
// ---------- forbidden functions ----------
|
||||
|
||||
UString2 &operator=(char c);
|
||||
UString2 &operator=(unsigned char c);
|
||||
FORBID_STRING_OPS_UString2(char)
|
||||
FORBID_STRING_OPS_UString2(signed char)
|
||||
FORBID_STRING_OPS_UString2(unsigned char)
|
||||
FORBID_STRING_OPS_UString2(short)
|
||||
|
||||
UString2 &operator=(wchar_t c);
|
||||
UString2(char c);
|
||||
UString2(unsigned char c);
|
||||
UString2(wchar_t c);
|
||||
|
||||
public:
|
||||
UString2(): _chars(NULL), _len(0) {}
|
||||
// UString2(wchar_t c);
|
||||
UString2(const wchar_t *s);
|
||||
UString2(const UString2 &s);
|
||||
~UString2() { if (_chars) MY_STRING_DELETE(_chars); }
|
||||
@@ -682,6 +757,8 @@ public:
|
||||
// operator const wchar_t *() const { return _chars; }
|
||||
const wchar_t *GetRawPtr() const { return _chars; }
|
||||
|
||||
int Compare(const wchar_t *s) const { return wcscmp(_chars, s); }
|
||||
|
||||
wchar_t *GetBuf(unsigned minLen)
|
||||
{
|
||||
if (!_chars || minLen > _len)
|
||||
@@ -754,6 +831,7 @@ typedef CObjectVector<CSysString> CSysStringVector;
|
||||
|
||||
#define fs2us(_x_) (_x_)
|
||||
#define us2fs(_x_) (_x_)
|
||||
FString fas2fs(const char *s);
|
||||
FString fas2fs(const AString &s);
|
||||
AString fs2fas(const FChar *s);
|
||||
|
||||
@@ -764,6 +842,7 @@ typedef CObjectVector<CSysString> CSysStringVector;
|
||||
typedef char FChar;
|
||||
typedef AString FString;
|
||||
|
||||
UString fs2us(const FChar *s);
|
||||
UString fs2us(const FString &s);
|
||||
FString us2fs(const wchar_t *s);
|
||||
#define fas2fs(_x_) (_x_)
|
||||
@@ -775,8 +854,10 @@ typedef CObjectVector<CSysString> CSysStringVector;
|
||||
|
||||
#define FCHAR_PATH_SEPARATOR FTEXT(CHAR_PATH_SEPARATOR)
|
||||
#define FSTRING_PATH_SEPARATOR FTEXT(STRING_PATH_SEPARATOR)
|
||||
#define FCHAR_ANY_MASK FTEXT('*')
|
||||
#define FSTRING_ANY_MASK FTEXT("*")
|
||||
|
||||
// #define FCHAR_ANY_MASK FTEXT('*')
|
||||
// #define FSTRING_ANY_MASK FTEXT("*")
|
||||
|
||||
typedef const FChar *CFSTR;
|
||||
|
||||
typedef CObjectVector<FString> FStringVector;
|
||||
|
||||
@@ -22,7 +22,9 @@ class CRecordVector
|
||||
if (_size == _capacity)
|
||||
{
|
||||
unsigned newCapacity = _capacity + (_capacity >> 2) + 1;
|
||||
T *p = new T[newCapacity];
|
||||
T *p;
|
||||
MY_ARRAY_NEW(p, T, newCapacity);
|
||||
// p = new T[newCapacity];
|
||||
if (_size != 0)
|
||||
memcpy(p, _items, (size_t)_size * sizeof(T));
|
||||
delete []_items;
|
||||
@@ -54,7 +56,8 @@ public:
|
||||
{
|
||||
if (size != 0)
|
||||
{
|
||||
_items = new T[size];
|
||||
MY_ARRAY_NEW(_items, T, size)
|
||||
// _items = new T[size];
|
||||
_capacity = size;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +66,9 @@ public:
|
||||
{
|
||||
if (newCapacity > _capacity)
|
||||
{
|
||||
T *p = new T[newCapacity];
|
||||
T *p;
|
||||
MY_ARRAY_NEW(p, T, newCapacity);
|
||||
// p = new T[newCapacity];
|
||||
if (_size != 0)
|
||||
memcpy(p, _items, (size_t)_size * sizeof(T));
|
||||
delete []_items;
|
||||
@@ -80,7 +85,8 @@ public:
|
||||
delete []_items;
|
||||
_items = NULL;
|
||||
_capacity = 0;
|
||||
_items = new T[newCapacity];
|
||||
MY_ARRAY_NEW(_items, T, newCapacity)
|
||||
// _items = new T[newCapacity];
|
||||
_capacity = newCapacity;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +101,9 @@ public:
|
||||
{
|
||||
if (newSize > _capacity)
|
||||
{
|
||||
T *p = new T[newSize];
|
||||
T *p;
|
||||
MY_ARRAY_NEW(p, T, newSize)
|
||||
// p = new T[newSize];
|
||||
if (_size != 0)
|
||||
memcpy(p, _items, (size_t)_size * sizeof(T));
|
||||
delete []_items;
|
||||
@@ -230,8 +238,8 @@ public:
|
||||
T& operator[](unsigned index) { return _items[index]; }
|
||||
const T& Front() const { return _items[0]; }
|
||||
T& Front() { return _items[0]; }
|
||||
const T& Back() const { return _items[_size - 1]; }
|
||||
T& Back() { return _items[_size - 1]; }
|
||||
const T& Back() const { return _items[(size_t)_size - 1]; }
|
||||
T& Back() { return _items[(size_t)_size - 1]; }
|
||||
|
||||
/*
|
||||
void Swap(unsigned i, unsigned j)
|
||||
@@ -370,7 +378,7 @@ public:
|
||||
unsigned s = (k << 1);
|
||||
if (s > size)
|
||||
break;
|
||||
if (s < size && p[s + 1].Compare(p[s]) > 0)
|
||||
if (s < size && p[(size_t)s + 1].Compare(p[s]) > 0)
|
||||
s++;
|
||||
if (temp.Compare(p[s]) >= 0)
|
||||
break;
|
||||
@@ -453,8 +461,8 @@ public:
|
||||
T& operator[](unsigned index) { return *((T *)_v[index]); }
|
||||
const T& Front() const { return operator[](0); }
|
||||
T& Front() { return operator[](0); }
|
||||
const T& Back() const { return operator[](_v.Size() - 1); }
|
||||
T& Back() { return operator[](_v.Size() - 1); }
|
||||
const T& Back() const { return *(T *)_v.Back(); }
|
||||
T& Back() { return *(T *)_v.Back(); }
|
||||
|
||||
void MoveToFront(unsigned index) { _v.MoveToFront(index); }
|
||||
|
||||
@@ -521,7 +529,7 @@ public:
|
||||
|
||||
void DeleteBack()
|
||||
{
|
||||
delete (T *)_v[_v.Size() - 1];
|
||||
delete (T *)_v.Back();
|
||||
_v.DeleteBack();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,16 @@ typedef UINT32 ULONG;
|
||||
#undef DWORD
|
||||
typedef UINT32 DWORD;
|
||||
|
||||
typedef long BOOL;
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
// typedef size_t ULONG_PTR;
|
||||
typedef size_t DWORD_PTR;
|
||||
|
||||
typedef Int64 LONGLONG;
|
||||
typedef UInt64 ULONGLONG;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ static bool IsSpaceChar(char c)
|
||||
|
||||
#define SKIP_SPACES(s) while (IsSpaceChar(*s)) s++;
|
||||
|
||||
int CXmlItem::FindProp(const AString &propName) const throw()
|
||||
int CXmlItem::FindProp(const char *propName) const throw()
|
||||
{
|
||||
FOR_VECTOR (i, Props)
|
||||
if (Props[i].Name == propName)
|
||||
@@ -28,7 +28,7 @@ int CXmlItem::FindProp(const AString &propName) const throw()
|
||||
return -1;
|
||||
}
|
||||
|
||||
AString CXmlItem::GetPropVal(const AString &propName) const
|
||||
AString CXmlItem::GetPropVal(const char *propName) const
|
||||
{
|
||||
int index = FindProp(propName);
|
||||
if (index >= 0)
|
||||
@@ -36,12 +36,12 @@ AString CXmlItem::GetPropVal(const AString &propName) const
|
||||
return AString();
|
||||
}
|
||||
|
||||
bool CXmlItem::IsTagged(const AString &tag) const throw()
|
||||
bool CXmlItem::IsTagged(const char *tag) const throw()
|
||||
{
|
||||
return (IsTag && Name == tag);
|
||||
}
|
||||
|
||||
int CXmlItem::FindSubTag(const AString &tag) const throw()
|
||||
int CXmlItem::FindSubTag(const char *tag) const throw()
|
||||
{
|
||||
FOR_VECTOR (i, SubItems)
|
||||
if (SubItems[i].IsTagged(tag))
|
||||
@@ -71,7 +71,7 @@ const AString * CXmlItem::GetSubStringPtr() const throw()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AString CXmlItem::GetSubStringForTag(const AString &tag) const
|
||||
AString CXmlItem::GetSubStringForTag(const char *tag) const
|
||||
{
|
||||
int index = FindSubTag(tag);
|
||||
if (index >= 0)
|
||||
|
||||
@@ -21,13 +21,13 @@ public:
|
||||
|
||||
const char * ParseItem(const char *s, int numAllowedLevels);
|
||||
|
||||
bool IsTagged(const AString &tag) const throw();
|
||||
int FindProp(const AString &propName) const throw();
|
||||
AString GetPropVal(const AString &propName) const;
|
||||
bool IsTagged(const char *tag) const throw();
|
||||
int FindProp(const char *propName) const throw();
|
||||
AString GetPropVal(const char *propName) const;
|
||||
AString GetSubString() const;
|
||||
const AString * GetSubStringPtr() const throw();
|
||||
int FindSubTag(const AString &tag) const throw();
|
||||
AString GetSubStringForTag(const AString &tag) const;
|
||||
int FindSubTag(const char *tag) const throw();
|
||||
AString GetSubStringForTag(const char *tag) const;
|
||||
|
||||
void AppendTo(AString &s) const;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#ifndef DEBUG_MEMORY_LEAK
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _7ZIP_REDEFINE_OPERATOR_NEW
|
||||
|
||||
/*
|
||||
void * my_new(size_t size)
|
||||
|
||||
@@ -4,28 +4,29 @@
|
||||
#define __COMMON_NEW_HANDLER_H
|
||||
|
||||
/*
|
||||
This file must be included before any code that uses operators "delete" or "new".
|
||||
Also you must compile and link "NewHandler.cpp", if you use MSVC 6.0.
|
||||
The operator "new" in MSVC 6.0 doesn't throw exception "bad_alloc".
|
||||
So we define another version of operator "new" that throws "CNewException" on failure.
|
||||
NewHandler.h and NewHandler.cpp allows to solve problem with compilers that
|
||||
don't throw exception in operator new().
|
||||
|
||||
If you use compiler that throws exception in "new" operator (GCC or new version of MSVC),
|
||||
you can compile without "NewHandler.cpp". So standard exception "bad_alloc" will be used.
|
||||
This file must be included before any code that uses operators new() or delete()
|
||||
and you must compile and link "NewHandler.cpp", if you use some old MSVC compiler.
|
||||
|
||||
It's still allowed to use redefined version of operator "new" from "NewHandler.cpp"
|
||||
with any compiler. 7-Zip's code can work with "bad_alloc" and "CNewException" exceptions.
|
||||
The operator new() in some MSVC versions doesn't throw exception std::bad_alloc.
|
||||
MSVC 6.0 (_MSC_VER == 1200) doesn't throw exception.
|
||||
The code produced by some another MSVC compilers also can be linked
|
||||
to library that doesn't throw exception.
|
||||
We suppose that code compiled with VS2015+ (_MSC_VER >= 1900) throws exception std::bad_alloc.
|
||||
For older _MSC_VER versions we redefine operator new() and operator delete().
|
||||
Our version of operator new() throws CNewException() exception on failure.
|
||||
|
||||
It's still allowed to use redefined version of operator new() from "NewHandler.cpp"
|
||||
with any compiler. 7-Zip's code can work with std::bad_alloc and CNewException() exceptions.
|
||||
But if you use some additional code (outside of 7-Zip's code), you must check
|
||||
that redefined version of operator "new" (that throws CNewException) is not
|
||||
problem for your code.
|
||||
|
||||
Also we declare delete(void *p) throw() that creates smaller code.
|
||||
that redefined version of operator new() is not problem for your code.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
class CNewException {};
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
// We can compile my_new and my_delete with _fastcall
|
||||
/*
|
||||
void * my_new(size_t size);
|
||||
@@ -34,7 +35,19 @@ void my_delete(void *p) throw();
|
||||
*/
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||
// If you want to use default operator new(), you can disable the following line
|
||||
#define _7ZIP_REDEFINE_OPERATOR_NEW
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _7ZIP_REDEFINE_OPERATOR_NEW
|
||||
|
||||
// std::bad_alloc can require additional DLL dependency.
|
||||
// So we don't define CNewException as std::bad_alloc here.
|
||||
|
||||
class CNewException {};
|
||||
|
||||
void *
|
||||
#ifdef _MSC_VER
|
||||
@@ -48,6 +61,12 @@ __cdecl
|
||||
#endif
|
||||
operator delete(void *p) throw();
|
||||
|
||||
#else
|
||||
|
||||
#include <new>
|
||||
|
||||
#define CNewException std::bad_alloc
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,13 +8,11 @@
|
||||
#include "StringConvert.h"
|
||||
#include "UTFConvert.h"
|
||||
|
||||
static const char kNewLineChar = '\n';
|
||||
// #define kEOFMessage "Unexpected end of input stream"
|
||||
// #define kReadErrorMessage "Error reading input stream"
|
||||
// #define kIllegalCharMessage "Illegal zero character in input stream"
|
||||
|
||||
static const char *kEOFMessage = "Unexpected end of input stream";
|
||||
static const char *kReadErrorMessage ="Error reading input stream";
|
||||
static const char *kIllegalCharMessage = "Illegal character in input stream";
|
||||
|
||||
static LPCTSTR kFileOpenMode = TEXT("r");
|
||||
#define kFileOpenMode TEXT("r")
|
||||
|
||||
extern int g_CodePage;
|
||||
|
||||
@@ -36,59 +34,56 @@ bool CStdInStream::Close() throw()
|
||||
return !_streamIsOpen;
|
||||
}
|
||||
|
||||
AString CStdInStream::ScanStringUntilNewLine(bool allowEOF)
|
||||
bool CStdInStream::ScanAStringUntilNewLine(AString &s)
|
||||
{
|
||||
AString s;
|
||||
s.Empty();
|
||||
for (;;)
|
||||
{
|
||||
int intChar = GetChar();
|
||||
if (intChar == EOF)
|
||||
{
|
||||
if (allowEOF)
|
||||
break;
|
||||
throw kEOFMessage;
|
||||
}
|
||||
return true;
|
||||
char c = (char)intChar;
|
||||
if (c == 0)
|
||||
throw kIllegalCharMessage;
|
||||
if (c == kNewLineChar)
|
||||
break;
|
||||
return false;
|
||||
if (c == '\n')
|
||||
return true;
|
||||
s += c;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
UString CStdInStream::ScanUStringUntilNewLine()
|
||||
bool CStdInStream::ScanUStringUntilNewLine(UString &dest)
|
||||
{
|
||||
AString s = ScanStringUntilNewLine(true);
|
||||
dest.Empty();
|
||||
AString s;
|
||||
bool res = ScanAStringUntilNewLine(s);
|
||||
int codePage = g_CodePage;
|
||||
if (codePage == -1)
|
||||
codePage = CP_OEMCP;
|
||||
UString dest;
|
||||
if (codePage == CP_UTF8)
|
||||
ConvertUTF8ToUnicode(s, dest);
|
||||
else
|
||||
dest = MultiByteToUnicodeString(s, (UINT)codePage);
|
||||
return dest;
|
||||
MultiByteToUnicodeString2(dest, s, (UINT)codePage);
|
||||
return res;
|
||||
}
|
||||
|
||||
void CStdInStream::ReadToString(AString &resultString)
|
||||
/*
|
||||
bool CStdInStream::ReadToString(AString &resultString)
|
||||
{
|
||||
resultString.Empty();
|
||||
int c;
|
||||
while ((c = GetChar()) != EOF)
|
||||
resultString += (char)c;
|
||||
}
|
||||
|
||||
bool CStdInStream::Eof() throw()
|
||||
{
|
||||
return (feof(_stream) != 0);
|
||||
for (;;)
|
||||
{
|
||||
int intChar = GetChar();
|
||||
if (intChar == EOF)
|
||||
return !Error();
|
||||
char c = (char)intChar;
|
||||
if (c == 0)
|
||||
return false;
|
||||
resultString += c;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
int CStdInStream::GetChar()
|
||||
{
|
||||
int c = fgetc(_stream); // getc() doesn't work in BeOS?
|
||||
if (c == EOF && !Eof())
|
||||
throw kReadErrorMessage;
|
||||
return c;
|
||||
return fgetc(_stream); // getc() doesn't work in BeOS?
|
||||
}
|
||||
|
||||
@@ -20,11 +20,16 @@ public:
|
||||
bool Open(LPCTSTR fileName) throw();
|
||||
bool Close() throw();
|
||||
|
||||
AString ScanStringUntilNewLine(bool allowEOF = false);
|
||||
void ReadToString(AString &resultString);
|
||||
UString ScanUStringUntilNewLine();
|
||||
// returns:
|
||||
// false, if ZERO character in stream
|
||||
// true, if EOF or '\n'
|
||||
bool ScanAStringUntilNewLine(AString &s);
|
||||
bool ScanUStringUntilNewLine(UString &s);
|
||||
// bool ReadToString(AString &resultString);
|
||||
|
||||
bool Eof() const throw() { return (feof(_stream) != 0); }
|
||||
bool Error() const throw() { return (ferror(_stream) != 0); }
|
||||
|
||||
bool Eof() throw();
|
||||
int GetChar();
|
||||
};
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
#include "StringConvert.h"
|
||||
#include "UTFConvert.h"
|
||||
|
||||
static const char kNewLineChar = '\n';
|
||||
|
||||
static const char *kFileOpenMode = "wt";
|
||||
#define kFileOpenMode "wt"
|
||||
|
||||
extern int g_CodePage;
|
||||
|
||||
@@ -44,7 +42,7 @@ bool CStdOutStream::Flush() throw()
|
||||
|
||||
CStdOutStream & endl(CStdOutStream & outStream) throw()
|
||||
{
|
||||
return outStream << kNewLineChar;
|
||||
return outStream << '\n';
|
||||
}
|
||||
|
||||
CStdOutStream & CStdOutStream::operator<<(const wchar_t *s)
|
||||
|
||||
@@ -291,6 +291,12 @@ UString MultiByteToUnicodeString(const AString &src, UINT codePage)
|
||||
return dest;
|
||||
}
|
||||
|
||||
UString MultiByteToUnicodeString(const char *src, UINT codePage)
|
||||
{
|
||||
return MultiByteToUnicodeString(AString(src), codePage);
|
||||
}
|
||||
|
||||
|
||||
void UnicodeStringToMultiByte2(AString &dest, const UString &src, UINT codePage)
|
||||
{
|
||||
bool defaultCharWasUsed;
|
||||
|
||||
@@ -6,72 +6,83 @@
|
||||
#include "MyString.h"
|
||||
#include "MyWindows.h"
|
||||
|
||||
UString MultiByteToUnicodeString(const AString &srcString, UINT codePage = CP_ACP);
|
||||
UString MultiByteToUnicodeString(const AString &src, UINT codePage = CP_ACP);
|
||||
UString MultiByteToUnicodeString(const char *src, UINT codePage = CP_ACP);
|
||||
|
||||
// optimized versions that work faster for ASCII strings
|
||||
void MultiByteToUnicodeString2(UString &dest, const AString &srcString, UINT codePage = CP_ACP);
|
||||
void MultiByteToUnicodeString2(UString &dest, const AString &src, UINT codePage = CP_ACP);
|
||||
// void UnicodeStringToMultiByte2(AString &dest, const UString &s, UINT codePage, char defaultChar, bool &defaultCharWasUsed);
|
||||
void UnicodeStringToMultiByte2(AString &dest, const UString &srcString, UINT codePage);
|
||||
void UnicodeStringToMultiByte2(AString &dest, const UString &src, UINT codePage);
|
||||
|
||||
AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage, char defaultChar, bool &defaultCharWasUsed);
|
||||
AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage = CP_ACP);
|
||||
AString UnicodeStringToMultiByte(const UString &src, UINT codePage, char defaultChar, bool &defaultCharWasUsed);
|
||||
AString UnicodeStringToMultiByte(const UString &src, UINT codePage = CP_ACP);
|
||||
|
||||
inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString)
|
||||
{ return unicodeString; }
|
||||
inline const UString& GetUnicodeString(const UString &unicodeString)
|
||||
{ return unicodeString; }
|
||||
inline UString GetUnicodeString(const AString &ansiString)
|
||||
{ return MultiByteToUnicodeString(ansiString); }
|
||||
inline UString GetUnicodeString(const AString &multiByteString, UINT codePage)
|
||||
{ return MultiByteToUnicodeString(multiByteString, codePage); }
|
||||
inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString, UINT)
|
||||
{ return unicodeString; }
|
||||
inline const UString& GetUnicodeString(const UString &unicodeString, UINT)
|
||||
{ return unicodeString; }
|
||||
inline const wchar_t* GetUnicodeString(const wchar_t *u) { return u; }
|
||||
inline const UString& GetUnicodeString(const UString &u) { return u; }
|
||||
|
||||
inline const char* GetAnsiString(const char* ansiString)
|
||||
{ return ansiString; }
|
||||
inline const AString& GetAnsiString(const AString &ansiString)
|
||||
{ return ansiString; }
|
||||
inline AString GetAnsiString(const UString &unicodeString)
|
||||
{ return UnicodeStringToMultiByte(unicodeString); }
|
||||
inline UString GetUnicodeString(const AString &a) { return MultiByteToUnicodeString(a); }
|
||||
inline UString GetUnicodeString(const char *a) { return MultiByteToUnicodeString(a); }
|
||||
|
||||
inline const char* GetOemString(const char* oemString)
|
||||
{ return oemString; }
|
||||
inline const AString& GetOemString(const AString &oemString)
|
||||
{ return oemString; }
|
||||
inline AString GetOemString(const UString &unicodeString)
|
||||
{ return UnicodeStringToMultiByte(unicodeString, CP_OEMCP); }
|
||||
inline UString GetUnicodeString(const AString &a, UINT codePage)
|
||||
{ return MultiByteToUnicodeString(a, codePage); }
|
||||
inline UString GetUnicodeString(const char *a, UINT codePage)
|
||||
{ return MultiByteToUnicodeString(a, codePage); }
|
||||
|
||||
inline const wchar_t* GetUnicodeString(const wchar_t *u, UINT) { return u; }
|
||||
inline const UString& GetUnicodeString(const UString &u, UINT) { return u; }
|
||||
|
||||
inline const char* GetAnsiString(const char *a) { return a; }
|
||||
inline const AString& GetAnsiString(const AString &a) { return a; }
|
||||
|
||||
inline AString GetAnsiString(const wchar_t *u) { return UnicodeStringToMultiByte(UString(u)); }
|
||||
inline AString GetAnsiString(const UString &u) { return UnicodeStringToMultiByte(u); }
|
||||
|
||||
/*
|
||||
inline const char* GetOemString(const char* oem)
|
||||
{ return oem; }
|
||||
inline const AString& GetOemString(const AString &oem)
|
||||
{ return oem; }
|
||||
*/
|
||||
const char* GetOemString(const char* oem);
|
||||
const AString& GetOemString(const AString &oem);
|
||||
inline AString GetOemString(const UString &u)
|
||||
{ return UnicodeStringToMultiByte(u, CP_OEMCP); }
|
||||
|
||||
#ifdef _UNICODE
|
||||
inline const wchar_t* GetSystemString(const wchar_t* unicodeString)
|
||||
{ return unicodeString;}
|
||||
inline const UString& GetSystemString(const UString &unicodeString)
|
||||
{ return unicodeString;}
|
||||
inline const wchar_t* GetSystemString(const wchar_t* unicodeString, UINT /* codePage */)
|
||||
{ return unicodeString;}
|
||||
inline const UString& GetSystemString(const UString &unicodeString, UINT /* codePage */)
|
||||
{ return unicodeString;}
|
||||
inline UString GetSystemString(const AString &multiByteString, UINT codePage)
|
||||
{ return MultiByteToUnicodeString(multiByteString, codePage);}
|
||||
inline UString GetSystemString(const AString &multiByteString)
|
||||
{ return MultiByteToUnicodeString(multiByteString);}
|
||||
inline const wchar_t* GetSystemString(const wchar_t *u) { return u;}
|
||||
inline const UString& GetSystemString(const UString &u) { return u;}
|
||||
inline const wchar_t* GetSystemString(const wchar_t *u, UINT /* codePage */) { return u;}
|
||||
inline const UString& GetSystemString(const UString &u, UINT /* codePage */) { return u;}
|
||||
|
||||
inline UString GetSystemString(const AString &a, UINT codePage) { return MultiByteToUnicodeString(a, codePage); }
|
||||
inline UString GetSystemString(const char *a, UINT codePage) { return MultiByteToUnicodeString(a, codePage); }
|
||||
inline UString GetSystemString(const AString &a) { return MultiByteToUnicodeString(a); }
|
||||
inline UString GetSystemString(const char *a) { return MultiByteToUnicodeString(a); }
|
||||
#else
|
||||
inline const char* GetSystemString(const char *ansiString)
|
||||
{ return ansiString; }
|
||||
inline const AString& GetSystemString(const AString &multiByteString, UINT)
|
||||
{ return multiByteString; }
|
||||
inline const char * GetSystemString(const char *multiByteString, UINT)
|
||||
{ return multiByteString; }
|
||||
inline AString GetSystemString(const UString &unicodeString)
|
||||
{ return UnicodeStringToMultiByte(unicodeString); }
|
||||
inline AString GetSystemString(const UString &unicodeString, UINT codePage)
|
||||
{ return UnicodeStringToMultiByte(unicodeString, codePage); }
|
||||
inline const char* GetSystemString(const char *a) { return a; }
|
||||
inline const AString& GetSystemString(const AString &a) { return a; }
|
||||
inline const char* GetSystemString(const char *a, UINT) { return a; }
|
||||
inline const AString& GetSystemString(const AString &a, UINT) { return a; }
|
||||
|
||||
inline AString GetSystemString(const wchar_t *u) { return UnicodeStringToMultiByte(UString(u)); }
|
||||
inline AString GetSystemString(const UString &u) { return UnicodeStringToMultiByte(u); }
|
||||
inline AString GetSystemString(const UString &u, UINT codePage) { return UnicodeStringToMultiByte(u, codePage); }
|
||||
|
||||
|
||||
|
||||
/*
|
||||
inline AString GetSystemString(const wchar_t *u)
|
||||
{
|
||||
UString s;
|
||||
s = u;
|
||||
return UnicodeStringToMultiByte(s);
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef UNDER_CE
|
||||
AString SystemStringToOemString(const CSysString &srcString);
|
||||
AString SystemStringToOemString(const CSysString &src);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -61,7 +61,7 @@ bool GetTextConfig(const AString &s, CObjectVector<CTextConfigPair> &pairs)
|
||||
break;
|
||||
CTextConfigPair pair;
|
||||
unsigned finishPos;
|
||||
AString temp = GetIDString(((const char *)s) + pos, finishPos);
|
||||
const AString temp (GetIDString(((const char *)s) + pos, finishPos));
|
||||
if (!ConvertUTF8ToUnicode(temp, pair.ID))
|
||||
return false;
|
||||
if (finishPos == 0)
|
||||
@@ -107,15 +107,15 @@ bool GetTextConfig(const AString &s, CObjectVector<CTextConfigPair> &pairs)
|
||||
return true;
|
||||
}
|
||||
|
||||
int FindTextConfigItem(const CObjectVector<CTextConfigPair> &pairs, const UString &id) throw()
|
||||
int FindTextConfigItem(const CObjectVector<CTextConfigPair> &pairs, const char *id) throw()
|
||||
{
|
||||
FOR_VECTOR (i, pairs)
|
||||
if (pairs[i].ID == id)
|
||||
if (pairs[i].ID.IsEqualTo(id))
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
UString GetTextConfigValue(const CObjectVector<CTextConfigPair> &pairs, const UString &id)
|
||||
UString GetTextConfigValue(const CObjectVector<CTextConfigPair> &pairs, const char *id)
|
||||
{
|
||||
int index = FindTextConfigItem(pairs, id);
|
||||
if (index < 0)
|
||||
|
||||
@@ -13,7 +13,7 @@ struct CTextConfigPair
|
||||
|
||||
bool GetTextConfig(const AString &text, CObjectVector<CTextConfigPair> &pairs);
|
||||
|
||||
int FindTextConfigItem(const CObjectVector<CTextConfigPair> &pairs, const UString &id) throw();
|
||||
UString GetTextConfigValue(const CObjectVector<CTextConfigPair> &pairs, const UString &id);
|
||||
int FindTextConfigItem(const CObjectVector<CTextConfigPair> &pairs, const char *id) throw();
|
||||
UString GetTextConfigValue(const CObjectVector<CTextConfigPair> &pairs, const char *id);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,16 +22,18 @@ bool IsPath1PrefixedByPath2(const wchar_t *s1, const wchar_t *s2)
|
||||
int CompareFileNames(const wchar_t *s1, const wchar_t *s2) STRING_UNICODE_THROW
|
||||
{
|
||||
if (g_CaseSensitive)
|
||||
return wcscmp(s1, s2);
|
||||
return MyStringCompare(s1, s2);
|
||||
return MyStringCompareNoCase(s1, s2);
|
||||
}
|
||||
|
||||
#ifndef USE_UNICODE_FSTRING
|
||||
int CompareFileNames(const char *s1, const char *s2)
|
||||
{
|
||||
const UString u1 = fs2us(s1);
|
||||
const UString u2 = fs2us(s2);
|
||||
if (g_CaseSensitive)
|
||||
return wcscmp(fs2us(s1), fs2us(s2));
|
||||
return MyStringCompareNoCase(fs2us(s1), fs2us(s2));
|
||||
return MyStringCompare(u1, u2);
|
||||
return MyStringCompareNoCase(u1, u2);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -120,24 +122,16 @@ void SplitPathToParts_Smart(const UString &path, UString &dirPrefix, UString &na
|
||||
name = p;
|
||||
}
|
||||
|
||||
/*
|
||||
UString ExtractDirPrefixFromPath(const UString &path)
|
||||
{
|
||||
const wchar_t *start = path;
|
||||
const wchar_t *p = start + path.Len();
|
||||
for (; p != start; p--)
|
||||
if (IsPathSepar(*(p - 1)))
|
||||
break;
|
||||
return path.Left((unsigned)(p - start));
|
||||
return path.Left(path.ReverseFind_PathSepar() + 1));
|
||||
}
|
||||
*/
|
||||
|
||||
UString ExtractFileNameFromPath(const UString &path)
|
||||
{
|
||||
const wchar_t *start = path;
|
||||
const wchar_t *p = start + path.Len();
|
||||
for (; p != start; p--)
|
||||
if (IsPathSepar(*(p - 1)))
|
||||
break;
|
||||
return p;
|
||||
return UString(path.Ptr(path.ReverseFind_PathSepar() + 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -425,7 +419,7 @@ void CCensorNode::AddItem2(bool include, const UString &path, bool recursive, bo
|
||||
return;
|
||||
bool forFile = true;
|
||||
bool forFolder = true;
|
||||
UString path2 = path;
|
||||
UString path2 (path);
|
||||
if (IsPathSepar(path.Back()))
|
||||
{
|
||||
path2.DeleteBack();
|
||||
@@ -612,7 +606,7 @@ void CCensor::AddItem(ECensorPathMode pathMode, bool include, const UString &pat
|
||||
{
|
||||
// we create universal item, if we skip all parts as prefix (like \ or L:\ )
|
||||
pathParts.Clear();
|
||||
pathParts.Add(L"*");
|
||||
pathParts.Add(UString("*"));
|
||||
forFile = true;
|
||||
wildcardMatching = true;
|
||||
recursive = false;
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
}
|
||||
void AddPreItem_Wildcard()
|
||||
{
|
||||
AddPreItem(true, L"*", false, true);
|
||||
AddPreItem(true, UString("*"), false, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
7
CPP/Common/XzCrc64Init.cpp
Normal file
7
CPP/Common/XzCrc64Init.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
// XzCrc64Init.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../C/XzCrc64.h"
|
||||
|
||||
static struct CCrc64Gen { CCrc64Gen() { Crc64GenerateTable(); } } g_Crc64TableInit;
|
||||
Reference in New Issue
Block a user