Annotation of elwix/tools/oldlzma/SRC/Common/StringToInt.cpp, revision 1.1.1.1
1.1 misho 1: // Common/StringToInt.cpp
2:
3: #include "StdAfx.h"
4:
5: #include "StringToInt.h"
6:
7: UInt64 ConvertStringToUInt64(const char *s, const char **end)
8: {
9: UInt64 result = 0;
10: while(true)
11: {
12: char c = *s;
13: if (c < '0' || c > '9')
14: {
15: if (end != NULL)
16: *end = s;
17: return result;
18: }
19: result *= 10;
20: result += (c - '0');
21: s++;
22: }
23: }
24:
25: UInt64 ConvertStringToUInt64(const wchar_t *s, const wchar_t **end)
26: {
27: UInt64 result = 0;
28: while(true)
29: {
30: wchar_t c = *s;
31: if (c < '0' || c > '9')
32: {
33: if (end != NULL)
34: *end = s;
35: return result;
36: }
37: result *= 10;
38: result += (c - '0');
39: s++;
40: }
41: }
42:
43:
44: Int64 ConvertStringToInt64(const char *s, const char **end)
45: {
46: if (*s == '-')
47: return -(Int64)ConvertStringToUInt64(s + 1, end);
48: return ConvertStringToUInt64(s, end);
49: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>