aboutsummaryrefslogtreecommitdiff
path: root/CPP/Common
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2025-07-05 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2025-07-05 19:27:33 +0500
commit395149956d696e6e3099d8b76d797437f94a6942 (patch)
tree6ed5013a637078ae2dfdc4acf1ad93bf29cea356 /CPP/Common
parente5431fa6f5505e385c6f9367260717e9c47dc2ee (diff)
download7zip-25.00.tar.gz
7zip-25.00.tar.bz2
7zip-25.00.zip
25.0025.00
Diffstat (limited to 'CPP/Common')
-rw-r--r--CPP/Common/MyString.cpp29
-rw-r--r--CPP/Common/MyString.h13
-rw-r--r--CPP/Common/MyXml.cpp4
-rw-r--r--CPP/Common/Sha3Reg.cpp2
-rw-r--r--CPP/Common/Wildcard.cpp13
5 files changed, 17 insertions, 44 deletions
diff --git a/CPP/Common/MyString.cpp b/CPP/Common/MyString.cpp
index b5f7e52..10e2331 100644
--- a/CPP/Common/MyString.cpp
+++ b/CPP/Common/MyString.cpp
@@ -208,35 +208,6 @@ bool StringsAreEqualNoCase(const wchar_t *s1, const wchar_t *s2) throw()
208 208
209// ---------- ASCII ---------- 209// ---------- ASCII ----------
210 210
211bool AString::IsPrefixedBy_Ascii_NoCase(const char *s) const throw()
212{
213 const char *s1 = _chars;
214 for (;;)
215 {
216 const char c2 = *s++;
217 if (c2 == 0)
218 return true;
219 const char c1 = *s1++;
220 if (MyCharLower_Ascii(c1) !=
221 MyCharLower_Ascii(c2))
222 return false;
223 }
224}
225
226bool UString::IsPrefixedBy_Ascii_NoCase(const char *s) const throw()
227{
228 const wchar_t *s1 = _chars;
229 for (;;)
230 {
231 const char c2 = *s++;
232 if (c2 == 0)
233 return true;
234 const wchar_t c1 = *s1++;
235 if (MyCharLower_Ascii(c1) != (unsigned char)MyCharLower_Ascii(c2))
236 return false;
237 }
238}
239
240bool StringsAreEqual_Ascii(const char *u, const char *a) throw() 211bool StringsAreEqual_Ascii(const char *u, const char *a) throw()
241{ 212{
242 for (;;) 213 for (;;)
diff --git a/CPP/Common/MyString.h b/CPP/Common/MyString.h
index ba9914e..639b874 100644
--- a/CPP/Common/MyString.h
+++ b/CPP/Common/MyString.h
@@ -429,11 +429,11 @@ public:
429 // int CompareNoCase(const char *s) const { return MyStringCompareNoCase(_chars, s); } 429 // int CompareNoCase(const char *s) const { return MyStringCompareNoCase(_chars, s); }
430 // int CompareNoCase(const AString &s) const { return MyStringCompareNoCase(_chars, s._chars); } 430 // int CompareNoCase(const AString &s) const { return MyStringCompareNoCase(_chars, s._chars); }
431 bool IsPrefixedBy(const char *s) const { return IsString1PrefixedByString2(_chars, s); } 431 bool IsPrefixedBy(const char *s) const { return IsString1PrefixedByString2(_chars, s); }
432 bool IsPrefixedBy_Ascii_NoCase(const char *s) const throw(); 432 bool IsPrefixedBy_Ascii_NoCase(const char *s) const { return IsString1PrefixedByString2_NoCase_Ascii(_chars, s); }
433 433
434 bool IsAscii() const 434 bool IsAscii() const
435 { 435 {
436 unsigned len = Len(); 436 const unsigned len = Len();
437 const char *s = _chars; 437 const char *s = _chars;
438 for (unsigned i = 0; i < len; i++) 438 for (unsigned i = 0; i < len; i++)
439 if ((unsigned char)s[i] >= 0x80) 439 if ((unsigned char)s[i] >= 0x80)
@@ -727,22 +727,23 @@ public:
727 // int CompareNoCase(const wchar_t *s) const { return MyStringCompareNoCase(_chars, s); } 727 // int CompareNoCase(const wchar_t *s) const { return MyStringCompareNoCase(_chars, s); }
728 // int CompareNoCase(const UString &s) const { return MyStringCompareNoCase(_chars, s._chars); } 728 // int CompareNoCase(const UString &s) const { return MyStringCompareNoCase(_chars, s._chars); }
729 bool IsPrefixedBy(const wchar_t *s) const { return IsString1PrefixedByString2(_chars, s); } 729 bool IsPrefixedBy(const wchar_t *s) const { return IsString1PrefixedByString2(_chars, s); }
730 bool IsPrefixedBy(const char *s) const { return IsString1PrefixedByString2(_chars, s); }
730 bool IsPrefixedBy_NoCase(const wchar_t *s) const { return IsString1PrefixedByString2_NoCase(_chars, s); } 731 bool IsPrefixedBy_NoCase(const wchar_t *s) const { return IsString1PrefixedByString2_NoCase(_chars, s); }
731 bool IsPrefixedBy_Ascii_NoCase(const char *s) const throw(); 732 bool IsPrefixedBy_Ascii_NoCase(const char *s) const { return IsString1PrefixedByString2_NoCase_Ascii(_chars, s); }
732 733
733 bool IsAscii() const 734 bool IsAscii() const
734 { 735 {
735 unsigned len = Len(); 736 const unsigned len = Len();
736 const wchar_t *s = _chars; 737 const wchar_t *s = _chars;
737 for (unsigned i = 0; i < len; i++) 738 for (unsigned i = 0; i < len; i++)
738 if (s[i] >= 0x80) 739 if ((unsigned)(int)s[i] >= 0x80)
739 return false; 740 return false;
740 return true; 741 return true;
741 } 742 }
742 int Find(wchar_t c) const { return FindCharPosInString(_chars, c); } 743 int Find(wchar_t c) const { return FindCharPosInString(_chars, c); }
743 int Find(wchar_t c, unsigned startIndex) const 744 int Find(wchar_t c, unsigned startIndex) const
744 { 745 {
745 int pos = FindCharPosInString(_chars + startIndex, c); 746 const int pos = FindCharPosInString(_chars + startIndex, c);
746 return pos < 0 ? -1 : (int)startIndex + pos; 747 return pos < 0 ? -1 : (int)startIndex + pos;
747 } 748 }
748 749
diff --git a/CPP/Common/MyXml.cpp b/CPP/Common/MyXml.cpp
index cc891fc..8364aae 100644
--- a/CPP/Common/MyXml.cpp
+++ b/CPP/Common/MyXml.cpp
@@ -24,7 +24,7 @@ static bool IsSpaceChar(char c)
24int CXmlItem::FindProp(const char *propName) const throw() 24int CXmlItem::FindProp(const char *propName) const throw()
25{ 25{
26 FOR_VECTOR (i, Props) 26 FOR_VECTOR (i, Props)
27 if (Props[i].Name == propName) 27 if (Props[i].Name.IsEqualTo(propName))
28 return (int)i; 28 return (int)i;
29 return -1; 29 return -1;
30} 30}
@@ -39,7 +39,7 @@ AString CXmlItem::GetPropVal(const char *propName) const
39 39
40bool CXmlItem::IsTagged(const char *tag) const throw() 40bool CXmlItem::IsTagged(const char *tag) const throw()
41{ 41{
42 return (IsTag && Name == tag); 42 return (IsTag && Name.IsEqualTo(tag));
43} 43}
44 44
45int CXmlItem::FindSubTag(const char *tag) const throw() 45int CXmlItem::FindSubTag(const char *tag) const throw()
diff --git a/CPP/Common/Sha3Reg.cpp b/CPP/Common/Sha3Reg.cpp
index 95db25e..cd2e288 100644
--- a/CPP/Common/Sha3Reg.cpp
+++ b/CPP/Common/Sha3Reg.cpp
@@ -58,7 +58,7 @@ Z7_COM7F_IMF2(UInt32, CSha3Hasher::GetDigestSize())
58 static IHasher *CreateHasherSpec() \ 58 static IHasher *CreateHasherSpec() \
59 { return new CSha3Hasher(digestSize / 8, isShake, \ 59 { return new CSha3Hasher(digestSize / 8, isShake, \
60 SHA3_BLOCK_SIZE_FROM_DIGEST_SIZE(digestSize_for_blockSize / 8)); } \ 60 SHA3_BLOCK_SIZE_FROM_DIGEST_SIZE(digestSize_for_blockSize / 8)); } \
61 static const CHasherInfo g_HasherInfo = { CreateHasherSpec, id, name, digestSize }; \ 61 static const CHasherInfo g_HasherInfo = { CreateHasherSpec, id, name, digestSize / 8 }; \
62 struct REGISTER_HASHER_NAME(cls) { REGISTER_HASHER_NAME(cls)() { RegisterHasher(&g_HasherInfo); }}; \ 62 struct REGISTER_HASHER_NAME(cls) { REGISTER_HASHER_NAME(cls)() { RegisterHasher(&g_HasherInfo); }}; \
63 static REGISTER_HASHER_NAME(cls) g_RegisterHasher; } 63 static REGISTER_HASHER_NAME(cls) g_RegisterHasher; }
64 64
diff --git a/CPP/Common/Wildcard.cpp b/CPP/Common/Wildcard.cpp
index 798cbd9..b561a89 100644
--- a/CPP/Common/Wildcard.cpp
+++ b/CPP/Common/Wildcard.cpp
@@ -255,7 +255,8 @@ ForDir nonrec [0, M) same as ForBoth-File
255 255
256bool CItem::AreAllAllowed() const 256bool CItem::AreAllAllowed() const
257{ 257{
258 return ForFile && ForDir && WildcardMatching && PathParts.Size() == 1 && PathParts.Front() == L"*"; 258 return ForFile && ForDir && WildcardMatching
259 && PathParts.Size() == 1 && PathParts.Front().IsEqualTo("*");
259} 260}
260 261
261bool CItem::CheckPath(const UStringVector &pathParts, bool isFile) const 262bool CItem::CheckPath(const UStringVector &pathParts, bool isFile) const
@@ -542,7 +543,7 @@ unsigned GetNumPrefixParts_if_DrivePath(UStringVector &pathParts)
542 { 543 {
543 if (pathParts.Size() < 4 544 if (pathParts.Size() < 4
544 || !pathParts[1].IsEmpty() 545 || !pathParts[1].IsEmpty()
545 || pathParts[2] != L"?") 546 || !pathParts[2].IsEqualTo("?"))
546 return 0; 547 return 0;
547 testIndex = 3; 548 testIndex = 3;
548 } 549 }
@@ -574,11 +575,11 @@ static unsigned GetNumPrefixParts(const UStringVector &pathParts)
574 return 1; 575 return 1;
575 if (pathParts.Size() == 2) 576 if (pathParts.Size() == 2)
576 return 2; 577 return 2;
577 if (pathParts[2] == L".") 578 if (pathParts[2].IsEqualTo("."))
578 return 3; 579 return 3;
579 580
580 unsigned networkParts = 2; 581 unsigned networkParts = 2;
581 if (pathParts[2] == L"?") 582 if (pathParts[2].IsEqualTo("?"))
582 { 583 {
583 if (pathParts.Size() == 3) 584 if (pathParts.Size() == 3)
584 return 3; 585 return 3;
@@ -642,7 +643,7 @@ void CCensor::AddItem(ECensorPathMode pathMode, bool include, const UString &pat
642 if (pathParts.Size() >= 3 643 if (pathParts.Size() >= 3
643 && pathParts[0].IsEmpty() 644 && pathParts[0].IsEmpty()
644 && pathParts[1].IsEmpty() 645 && pathParts[1].IsEmpty()
645 && pathParts[2] == L"?") 646 && pathParts[2].IsEqualTo("?"))
646 ignoreWildcardIndex = 2; 647 ignoreWildcardIndex = 2;
647 // #endif 648 // #endif
648 649
@@ -665,7 +666,7 @@ void CCensor::AddItem(ECensorPathMode pathMode, bool include, const UString &pat
665 for (unsigned i = numPrefixParts; i < pathParts.Size(); i++) 666 for (unsigned i = numPrefixParts; i < pathParts.Size(); i++)
666 { 667 {
667 const UString &part = pathParts[i]; 668 const UString &part = pathParts[i];
668 if (part == L".." || part == L".") 669 if (part.IsEqualTo("..") || part.IsEqualTo("."))
669 dotsIndex = (int)i; 670 dotsIndex = (int)i;
670 } 671 }
671 672