Changeset 74170 in vbox for trunk/src/VBox/Runtime/common/rest
- Timestamp:
- Sep 10, 2018 7:26:17 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 124942
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/rest/rest-primary-object-types.cpp
r74161 r74170 306 306 307 307 308 /** Default destructor. */308 /** Default constructor. */ 309 309 RTCRestInt64::RTCRestInt64() 310 310 : RTCRestObjectBase() … … 470 470 471 471 472 /** Default destructor. */472 /** Default constructor. */ 473 473 RTCRestInt32::RTCRestInt32() 474 474 : RTCRestObjectBase() … … 640 640 641 641 642 /** Default destructor. */642 /** Default constructor. */ 643 643 RTCRestInt16::RTCRestInt16() 644 644 : RTCRestObjectBase() … … 809 809 } 810 810 811 /** Default destructor. */811 /** Default constructor. */ 812 812 RTCRestDouble::RTCRestDouble() 813 813 : RTCRestObjectBase() … … 881 881 char szValue[128]; 882 882 #ifdef _MSC_VER 883 _snprintf(szValue, sizeof(szValue), "% g", m_rdValue);883 _snprintf(szValue, sizeof(szValue), "%.18g", m_rdValue); 884 884 #else 885 snprintf(szValue, sizeof(szValue), "% g", m_rdValue);885 snprintf(szValue, sizeof(szValue), "%.18g", m_rdValue); 886 886 #endif 887 size_t cchValue = strlen(szValue); 888 while (cchValue > 0 && szValue[-1] == '0') 889 cchValue--; 890 szValue[cchValue] = '\0'; 891 887 892 a_rDst.printf("%s", szValue); 888 893 } … … 944 949 char szValue[128]; 945 950 #ifdef _MSC_VER 946 _snprintf(szValue, sizeof(szValue), "% g", m_rdValue);951 _snprintf(szValue, sizeof(szValue), "%.18g", m_rdValue); 947 952 #else 948 snprintf(szValue, sizeof(szValue), "% g", m_rdValue);953 snprintf(szValue, sizeof(szValue), "%.18g", m_rdValue); 949 954 #endif 950 size_t const cchValue = strlen(szValue); 955 size_t cchValue = strlen(szValue); 956 while (cchValue > 0 && szValue[-1] == '0') 957 cchValue--; 958 szValue[cchValue] = '\0'; 951 959 952 960 if (!(a_fFlags & kToString_Append)) … … 965 973 { 966 974 RT_NOREF(a_fFlags); 975 976 if (a_rValue.startsWithWord("null", RTCString::CaseInsensitive)) 977 { 978 m_rdValue = 0.0; 979 m_fNullIndicator = true; 980 return VINF_SUCCESS; 981 } 967 982 968 983 m_fNullIndicator = false; … … 972 987 char *pszNext = NULL; 973 988 m_rdValue = strtod(pszValue, &pszNext); 974 if (errno == 0) 975 return VINF_SUCCESS; 976 977 if (a_rValue.startsWithWord("null", RTCString::CaseInsensitive)) 978 { 979 m_rdValue = 0.0; 980 m_fNullIndicator = true; 981 return VINF_SUCCESS; 982 } 983 989 if (errno == 0 && pszNext != pszValue) 990 { 991 if (!pszNext || *pszNext == '\0') 992 return VINF_SUCCESS; 993 994 while (RT_C_IS_SPACE(*pszNext)) 995 pszNext++; 996 if (*pszNext == '\0') 997 return VINF_SUCCESS; 998 999 return RTErrInfoSetF(a_pErrInfo, VERR_TRAILING_CHARS, "%s: error VERR_TRAILING_CHARS parsing '%s' as double", 1000 a_pszName, a_rValue.c_str()); 1001 } 1002 1003 if (!RT_C_IS_DIGIT(*pszValue) && *pszValue != '.') 1004 return RTErrInfoSetF(a_pErrInfo, VERR_NO_DIGITS, "%s: error VERR_NO_DIGITS parsing '%s' as double", 1005 a_pszName, a_rValue.c_str()); 984 1006 int rc = RTErrConvertFromErrno(errno); 985 1007 return RTErrInfoSetF(a_pErrInfo, rc, "%s: error %Rrc parsing '%s' as double", a_pszName, rc, a_rValue.c_str()); … … 1011 1033 1012 1034 1013 /** Default destructor. */1035 /** Default constructor. */ 1014 1036 RTCRestString::RTCRestString() 1015 1037 : RTCString()
Note:
See TracChangeset
for help on using the changeset viewer.