Changeset 96161 in vbox for trunk/src/VBox/Runtime/common/string
- Timestamp:
- Aug 12, 2022 11:24:22 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 152967
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/nocrt-vsscanf.cpp
r96128 r96161 33 33 #include <iprt/nocrt/stdio.h> 34 34 #include <iprt/ctype.h> 35 #include <iprt/err.h> 35 36 #include <iprt/stdarg.h> 36 37 #include <iprt/string.h> … … 139 140 } 140 141 142 return pszString; 143 } 144 145 146 static const char *rtNoCrtScanFloat(const char *pszString, char chPrefix, int cchWidth, void *pvDst, int *pcMatches) 147 { 148 size_t const cchMax = cchWidth > 0 ? (unsigned)cchWidth : 0; 149 int rc; 150 switch (chPrefix) 151 { 152 default: 153 case '\0': 154 #ifndef RT_OS_WINDOWS /* Windows doesn't do float, only double and "long" double (same as double). */ 155 rc = RTStrToFloatEx(pszString, (char **)&pszString, cchMax, (float *)pvDst); 156 break; 157 #else 158 RT_FALL_THRU(); 159 #endif 160 case 'l': 161 rc = RTStrToDoubleEx(pszString, (char **)&pszString, cchMax, (double *)pvDst); 162 break; 163 164 case 'L': 165 rc = RTStrToLongDoubleEx(pszString, (char **)&pszString, cchMax, (long double *)pvDst); 166 break; 167 } 168 if (rc != VERR_NO_DIGITS) 169 *pcMatches += pvDst != NULL; 170 else 171 pszString = NULL; 141 172 return pszString; 142 173 } … … 271 302 void *pvDst = NULL; 272 303 if (fAssign) 273 pvDst = va_arg(va, void *); /* This ought to work most place... Probably standard conforming. */304 pvDst = va_arg(va, void *); /* This ought to work most place... Probably not standard conforming. */ 274 305 pszString = rtNoCrtScanInt(pszString, 275 306 chFmt == 'i' ? 0 : chFmt == 'd' || chFmt == 'u' ? 10 : chFmt == 'o' ? 8 : 16, … … 281 312 } 282 313 314 case 'a': 315 case 'A': 316 case 'e': 317 case 'E': 318 case 'f': 319 case 'F': 320 case 'g': 321 case 'G': 322 { 323 while (RT_C_IS_SPACE(*pszString)) 324 pszString++; 325 326 /* Note! We don't really give a hoot what input format type we're given, 327 we keep and open mind and acceept whatever we find that looks like 328 floating point. This is doubtfully standard compliant. */ 329 void *pvDst = NULL; 330 if (fAssign) 331 pvDst = va_arg(va, void *); /* This ought to work most place... Probably not standard conforming. */ 332 pszString = rtNoCrtScanFloat(pszString, chPrefix, cchWidth, pvDst, &cMatches); 333 if (!pszString) 334 return cMatches; 335 break; 336 } 337 283 338 case 'n': 284 339 {
Note:
See TracChangeset
for help on using the changeset viewer.