Fix the boiler plate codes
[platform/framework/native/appfw.git] / src / base / FBaseShort.cpp
index f40452c..8740a9a 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
@@ -108,20 +107,28 @@ Short::Decode(const String& s, short& ret)
 
        long value = 0;
        int radix = 0;
+       int startIndex = 0;
+       int minLength = 2;
        wchar_t* pEnd = null;
        String str(s);
 
+       if (s[0] == L'-' || 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;
                }