From: dahyeong.kim Date: Wed, 10 Apr 2013 12:25:53 +0000 (+0900) Subject: [N_SE-33612] when the number has '-'(sign), Decod() works wrong X-Git-Tag: accepted/tizen_2.1/20130425.034849~103 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6fe9c9be95c31c19f72a1e25e0a4b9462cc3f787;p=platform%2Fframework%2Fnative%2Fappfw.git [N_SE-33612] when the number has '-'(sign), Decod() works wrong Change-Id: I6040ede618ef06e8bc699b4a66586f3377c40492 Signed-off-by: dahyeong.kim --- diff --git a/src/base/FBaseInt8.cpp b/src/base/FBaseInt8.cpp index ecf9bd5..284df62 100644 --- a/src/base/FBaseInt8.cpp +++ b/src/base/FBaseInt8.cpp @@ -104,20 +104,28 @@ Int8::Decode(const String& s, char& ret) long value = 0; int radix = 0; + int startIndex = 0; + int minLength = 2; wchar_t* pEnd = null; String str(s); + if (s[0] == L'-') + { + startIndex = 1; + minLength = 3; + } + // Find radix - if (s[0] == L'#') + if (s[startIndex] == L'#') { radix = Character::RADIX_HEXADECIMAL; // Remove '#' - str.Remove(0, 1); + str.Remove(startIndex, 1); } - else if (s[0] == L'0' && (s.GetLength() >= 2)) + else if (s[startIndex] == L'0' && (s.GetLength() >= minLength)) { - if (s[1] == L'x' || s[1] == L'X') + if (s[startIndex + 1] == L'x' || s[startIndex + 1] == L'X') { radix = Character::RADIX_HEXADECIMAL; }