Changeset 73801 in vbox for trunk/src/VBox/Runtime/common/string/strformatrt.cpp
- Timestamp:
- Aug 21, 2018 1:32:45 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strformatrt.cpp
r69834 r73801 1288 1288 1289 1289 #ifdef IN_RING3 1290 1290 1291 /* 1291 1292 * Group 5, XML / HTML escapers. … … 1360 1361 break; 1361 1362 } 1363 1364 /* 1365 * Groups 6 - JSON. 1366 */ 1367 case 'J': 1368 { 1369 char chType = (*ppszFormat)[0]; 1370 *ppszFormat += 1; 1371 switch (chType) 1372 { 1373 case 's': 1374 { 1375 const char *pszStr = va_arg(*pArgs, char *); 1376 size_t cchOutput; 1377 ssize_t cchStr; 1378 ssize_t offCur; 1379 ssize_t offLast; 1380 1381 if (!VALID_PTR(pszStr)) 1382 pszStr = "<NULL>"; 1383 cchStr = RTStrNLen(pszStr, (unsigned)cchPrecision); 1384 1385 cchOutput = pfnOutput(pvArgOutput, "\"", 1); 1386 if (!(fFlags & RTSTR_F_LEFT)) 1387 while (--cchWidth >= cchStr) 1388 cchOutput += pfnOutput(pvArgOutput, " ", 1); 1389 1390 offLast = offCur = 0; 1391 while (offCur < cchStr) 1392 { 1393 unsigned int const uch = pszStr[offCur]; 1394 if ( uch >= 0x5d 1395 || (uch >= 0x20 && uch != 0x22 && uch != 0x5c)) 1396 offCur++; 1397 else 1398 { 1399 if (offLast < offCur) 1400 cchOutput += pfnOutput(pvArgOutput, &pszStr[offLast], offCur - offLast); 1401 switch ((char)uch) 1402 { 1403 case '"': cchOutput += pfnOutput(pvArgOutput, "\\\"", 2); break; 1404 case '\\': cchOutput += pfnOutput(pvArgOutput, "\\\\", 2); break; 1405 case '/': cchOutput += pfnOutput(pvArgOutput, "\\/", 2); break; 1406 case '\b': cchOutput += pfnOutput(pvArgOutput, "\\b", 2); break; 1407 case '\f': cchOutput += pfnOutput(pvArgOutput, "\\f", 2); break; 1408 case '\n': cchOutput += pfnOutput(pvArgOutput, "\\n", 2); break; 1409 case '\t': cchOutput += pfnOutput(pvArgOutput, "\\t", 2); break; 1410 default: 1411 cchOutput += pfnOutput(pvArgOutput, "\\u00", 2); 1412 cchOutput += pfnOutput(pvArgOutput, &g_szHexDigits[(uch >> 4) & 0xf], 1); 1413 cchOutput += pfnOutput(pvArgOutput, &g_szHexDigits[uch & 0xf], 1); 1414 break; 1415 } 1416 offLast = ++offCur; 1417 } 1418 } 1419 if (offLast < offCur) 1420 cchOutput += pfnOutput(pvArgOutput, &pszStr[offLast], offCur - offLast); 1421 1422 while (--cchWidth >= cchStr) 1423 cchOutput += pfnOutput(pvArgOutput, " ", 1); 1424 cchOutput += pfnOutput(pvArgOutput, "\"", 1); 1425 return cchOutput; 1426 } 1427 1428 default: 1429 AssertMsgFailed(("Invalid IPRT format type '%.10s'!\n", pszFormatOrg)); 1430 } 1431 break; 1432 } 1433 1362 1434 #endif /* IN_RING3 */ 1363 1435 1364 1365 1436 /* 1366 * Groups 6- CPU Architecture Register Formatters.1437 * Groups 7 - CPU Architecture Register Formatters. 1367 1438 * "%RAarch[reg]" 1368 1439 */
Note:
See TracChangeset
for help on using the changeset viewer.