diff options
author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2022-06-20 00:00:00 +0000 |
---|---|---|
committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-12-17 13:35:20 +0500 |
commit | a3e1d227377188734b82f023f96f8e25dc40f3e6 (patch) | |
tree | 23cad8d47eb23d26ea727b4f7f4a65124f724065 /CPP/Common/StringToInt.cpp | |
parent | f19f813537c7aea1c20749c914e756b54a9c3cf5 (diff) | |
download | 7zip-22.00.tar.gz 7zip-22.00.tar.bz2 7zip-22.00.zip |
22.0022.00
Diffstat (limited to '')
-rw-r--r-- | CPP/Common/StringToInt.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/CPP/Common/StringToInt.cpp b/CPP/Common/StringToInt.cpp index 839867a..bc4926e 100644 --- a/CPP/Common/StringToInt.cpp +++ b/CPP/Common/StringToInt.cpp | |||
@@ -26,6 +26,33 @@ CONVERT_STRING_TO_UINT_FUNC(UInt32, wchar_t, wchar_t) | |||
26 | CONVERT_STRING_TO_UINT_FUNC(UInt64, char, Byte) | 26 | CONVERT_STRING_TO_UINT_FUNC(UInt64, char, Byte) |
27 | CONVERT_STRING_TO_UINT_FUNC(UInt64, wchar_t, wchar_t) | 27 | CONVERT_STRING_TO_UINT_FUNC(UInt64, wchar_t, wchar_t) |
28 | 28 | ||
29 | /* | ||
30 | Int32 ConvertStringToInt32(const char *s, const char **end) throw() | ||
31 | { | ||
32 | if (end) | ||
33 | *end = s; | ||
34 | const char *s2 = s; | ||
35 | if (*s == '-') | ||
36 | s2++; | ||
37 | if (*s2 == 0) | ||
38 | return 0; | ||
39 | const char *end2; | ||
40 | UInt32 res = ConvertStringToUInt32(s2, &end2); | ||
41 | if (*s == '-') | ||
42 | { | ||
43 | if (res > ((UInt32)1 << (32 - 1))) | ||
44 | return 0; | ||
45 | } | ||
46 | else if ((res & ((UInt32)1 << (32 - 1))) != 0) | ||
47 | return 0; | ||
48 | if (end) | ||
49 | *end = end2; | ||
50 | if (*s == '-') | ||
51 | return -(Int32)res; | ||
52 | return (Int32)res; | ||
53 | } | ||
54 | */ | ||
55 | |||
29 | Int32 ConvertStringToInt32(const wchar_t *s, const wchar_t **end) throw() | 56 | Int32 ConvertStringToInt32(const wchar_t *s, const wchar_t **end) throw() |
30 | { | 57 | { |
31 | if (end) | 58 | if (end) |