diff options
Diffstat (limited to '')
-rw-r--r-- | CPP/7zip/Archive/VhdxHandler.cpp | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/CPP/7zip/Archive/VhdxHandler.cpp b/CPP/7zip/Archive/VhdxHandler.cpp index e3ddedd..ca450e5 100644 --- a/CPP/7zip/Archive/VhdxHandler.cpp +++ b/CPP/7zip/Archive/VhdxHandler.cpp | |||
@@ -7,6 +7,8 @@ | |||
7 | #include "../../../C/CpuArch.h" | 7 | #include "../../../C/CpuArch.h" |
8 | 8 | ||
9 | #include "../../Common/ComTry.h" | 9 | #include "../../Common/ComTry.h" |
10 | #include "../../Common/IntToString.h" | ||
11 | #include "../../Common/StringToInt.h" | ||
10 | #include "../../Common/MyBuffer.h" | 12 | #include "../../Common/MyBuffer.h" |
11 | 13 | ||
12 | #include "../../Windows/PropVariant.h" | 14 | #include "../../Windows/PropVariant.h" |
@@ -31,6 +33,7 @@ EXTERN_C_BEGIN | |||
31 | // CRC-32C (Castagnoli) : reversed for poly 0x1EDC6F41 | 33 | // CRC-32C (Castagnoli) : reversed for poly 0x1EDC6F41 |
32 | #define k_Crc32c_Poly 0x82f63b78 | 34 | #define k_Crc32c_Poly 0x82f63b78 |
33 | 35 | ||
36 | MY_ALIGN(64) | ||
34 | static UInt32 g_Crc32c_Table[256]; | 37 | static UInt32 g_Crc32c_Table[256]; |
35 | 38 | ||
36 | static void Z7_FASTCALL Crc32c_GenerateTable() | 39 | static void Z7_FASTCALL Crc32c_GenerateTable() |
@@ -91,31 +94,13 @@ static bool IsZeroArr(const Byte *p, size_t size) | |||
91 | } | 94 | } |
92 | 95 | ||
93 | 96 | ||
94 | #define ValToHex(t) ((char)(((t) < 10) ? ('0' + (t)) : ('a' + ((t) - 10)))) | ||
95 | |||
96 | static void AddByteToHex2(unsigned val, UString &s) | ||
97 | { | ||
98 | unsigned t; | ||
99 | t = val >> 4; | ||
100 | s += ValToHex(t); | ||
101 | t = val & 0xF; | ||
102 | s += ValToHex(t); | ||
103 | } | ||
104 | |||
105 | |||
106 | static int HexToVal(const wchar_t c) | ||
107 | { | ||
108 | if (c >= '0' && c <= '9') return c - '0'; | ||
109 | if (c >= 'a' && c <= 'z') return c - 'a' + 10; | ||
110 | if (c >= 'A' && c <= 'Z') return c - 'A' + 10; | ||
111 | return -1; | ||
112 | } | ||
113 | 97 | ||
98 | Z7_FORCE_INLINE | ||
114 | static int DecodeFrom2HexChars(const wchar_t *s) | 99 | static int DecodeFrom2HexChars(const wchar_t *s) |
115 | { | 100 | { |
116 | const int v0 = HexToVal(s[0]); if (v0 < 0) return -1; | 101 | unsigned v0 = (unsigned)s[0]; Z7_PARSE_HEX_DIGIT(v0, return -1;) |
117 | const int v1 = HexToVal(s[1]); if (v1 < 0) return -1; | 102 | unsigned v1 = (unsigned)s[1]; Z7_PARSE_HEX_DIGIT(v1, return -1;) |
118 | return (int)(((unsigned)v0 << 4) | (unsigned)v1); | 103 | return (int)((v0 << 4) | v1); |
119 | } | 104 | } |
120 | 105 | ||
121 | 106 | ||
@@ -161,8 +146,9 @@ struct CGuid | |||
161 | 146 | ||
162 | void CGuid::AddHexToString(UString &s) const | 147 | void CGuid::AddHexToString(UString &s) const |
163 | { | 148 | { |
164 | for (unsigned i = 0; i < 16; i++) | 149 | char temp[sizeof(Data) * 2 + 2]; |
165 | AddByteToHex2(Data[i], s); | 150 | ConvertDataToHex_Lower(temp, Data, sizeof(Data)); |
151 | s += temp; | ||
166 | } | 152 | } |
167 | 153 | ||
168 | 154 | ||
@@ -274,7 +260,7 @@ struct CRegion | |||
274 | }; | 260 | }; |
275 | 261 | ||
276 | 262 | ||
277 | static const unsigned kRegionSize = 1 << 16; | 263 | static const size_t kRegionSize = 1 << 16; |
278 | static const unsigned kNumRegionEntriesMax = (1 << 11) - 1; | 264 | static const unsigned kNumRegionEntriesMax = (1 << 11) - 1; |
279 | 265 | ||
280 | bool CRegion::Parse(Byte *p) | 266 | bool CRegion::Parse(Byte *p) |
@@ -1576,7 +1562,7 @@ static void AddComment_Name(UString &s, const char *name) | |||
1576 | static void AddComment_Bool(UString &s, const char *name, bool val) | 1562 | static void AddComment_Bool(UString &s, const char *name, bool val) |
1577 | { | 1563 | { |
1578 | AddComment_Name(s, name); | 1564 | AddComment_Name(s, name); |
1579 | s += val ? "+" : "-"; | 1565 | s.Add_Char(val ? '+' : '-'); |
1580 | s.Add_LF(); | 1566 | s.Add_LF(); |
1581 | } | 1567 | } |
1582 | 1568 | ||